Skip to content

Commit

Permalink
refactor handling of default values with literal type
Browse files Browse the repository at this point in the history
  • Loading branch information
p-x9 committed Jan 16, 2024
1 parent 4640b44 commit 96a811c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/AliasPlugin/AliasMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ extension AliasMacro {
typeAnnotation = specifiedType
} else if let defaultValue = binding.initializer?.value {
var type: TypeSyntax?
switch defaultValue {
case _ where defaultValue.is(StringLiteralExprSyntax.self):
switch defaultValue.kind {
case .stringLiteralExpr:
type = "Swift.String"
case _ where defaultValue.is(IntegerLiteralExprSyntax.self):
case .integerLiteralExpr:
type = "Swift.Int"
case _ where defaultValue.is(FloatLiteralExprSyntax.self):
case .floatLiteralExpr:
type = "Swift.Double"
case _ where defaultValue.is(BooleanLiteralExprSyntax.self):
case .booleanLiteralExpr:
type = "Swift.Bool"
default: break
}
Expand Down

0 comments on commit 96a811c

Please sign in to comment.