From 3898a7f02051be2db2135666cff88232b829af92 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Mon, 12 Feb 2024 06:38:01 +0900 Subject: [PATCH] fix(macro): use as instead of cast to reduces crash chance --- .../Package/Sources/iMastPackageMacros/PackageMacro.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Core/Package/Sources/iMastPackageMacros/PackageMacro.swift b/Sources/Core/Package/Sources/iMastPackageMacros/PackageMacro.swift index 607c8a73..98def364 100644 --- a/Sources/Core/Package/Sources/iMastPackageMacros/PackageMacro.swift +++ b/Sources/Core/Package/Sources/iMastPackageMacros/PackageMacro.swift @@ -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 {