Skip to content

Commit

Permalink
Do not use '.as(Type.self)' syntax. Prefer using initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Jan 10, 2024
1 parent f3aaaaf commit 209f319
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension AttributeListSyntax {
guard let attribute = first(where: { element in
switch element {
case let .attribute(attribute):
return attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text == InstantiableVisitor.macroName
return IdentifierTypeSyntax(attribute.attributeName)?.name.text == InstantiableVisitor.macroName
case .ifConfigDecl:
return false
}
Expand All @@ -40,7 +40,7 @@ extension AttributeListSyntax {
guard let attribute = first(where: { element in
switch element {
case let .attribute(attribute):
return attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text == Dependency.Source.instantiated.rawValue
return IdentifierTypeSyntax(attribute.attributeName)?.name.text == Dependency.Source.instantiated.rawValue
case .ifConfigDecl:
return false
}
Expand All @@ -54,7 +54,7 @@ extension AttributeListSyntax {
guard let attribute = first(where: { element in
switch element {
case let .attribute(attribute):
return attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text == Dependency.Source.received.rawValue
return IdentifierTypeSyntax(attribute.attributeName)?.name.text == Dependency.Source.received.rawValue
case .ifConfigDecl:
return false
}
Expand All @@ -68,7 +68,7 @@ extension AttributeListSyntax {
compactMap { element in
switch element {
case let .attribute(attribute):
guard let identifierText = attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text else {
guard let identifierText = IdentifierTypeSyntax(attribute.attributeName)?.name.text else {
return nil
}
return (attribute: identifierText, node: element)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SafeDICoreTests/TypeDescriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ final class TypeDescriptionTests: XCTestCase {
// Note: ideally we'd visit a node of type FunctionTypeSyntax
// but there's no way to get a TypeSyntax from an object of that type.
override func visit(_ node: TypeAnnotationSyntax) -> SyntaxVisitorContinueKind {
functionIdentifier = node.type.as(TypeSyntax.self)?.typeDescription
functionIdentifier = TypeSyntax(node.type)?.typeDescription
return .skipChildren
}
}
Expand Down

0 comments on commit 209f319

Please sign in to comment.