Skip to content

Commit c183a5e

Browse files
committed
Return an IdentifierTypeSyntax in detectExpressionType
Not quite sure, but this returned a `MemberExpressionType` when using the literal, maybe that changed in 600?
1 parent ceca416 commit c183a5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/ManagedModelMacros/Utilities/ExpressionType.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import SwiftSyntax
88
extension ExprSyntax {
99

1010
func detectExpressionType() -> TypeSyntax? {
11+
guard let idType = detectExpressionTypeName() else { return nil }
12+
return TypeSyntax(IdentifierTypeSyntax(name: .identifier(idType)))
13+
}
14+
func detectExpressionTypeName() -> String? {
1115
// TODO: detect base types and such
1216
// - check function expressions, like:
1317
// - `Data()`?
@@ -18,7 +22,8 @@ extension ExprSyntax {
1822
case .integerLiteralExpr : return "Swift.Int"
1923
case .floatLiteralExpr : return "Swift.Double"
2024
case .booleanLiteralExpr : return "Swift.Bool"
21-
default: break
25+
default:
26+
break
2227
}
2328

2429
return nil

0 commit comments

Comments
 (0)