Skip to content

Commit

Permalink
fix(macro): use as instead of cast to reduces crash chance
Browse files Browse the repository at this point in the history
  • Loading branch information
rinsuki committed Feb 11, 2024
1 parent 46caca6 commit 3898a7f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public struct UserInfoPropertyMacro: AccessorMacro {
// TODO: throw error like "type annotation is required"
return []
}
let optionalInnerType = typeAnot.type.cast(OptionalTypeSyntax.self).wrappedType
guard let optionalInnerType = typeAnot.type.as(OptionalTypeSyntax.self)?.wrappedType else {
// TODO: throw error like "type should be optional wrapped"
return []
}
return [
"""
get {
Expand Down

0 comments on commit 3898a7f

Please sign in to comment.