From 209f319e8adac2c70b0d822280cc8c2f8e66b160 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Wed, 10 Jan 2024 12:48:57 -0700 Subject: [PATCH] Do not use '.as(Type.self)' syntax. Prefer using initializers --- .../Extensions/AttributeListSyntaxExtensions.swift | 8 ++++---- Tests/SafeDICoreTests/TypeDescriptionTests.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/SafeDICore/Extensions/AttributeListSyntaxExtensions.swift b/Sources/SafeDICore/Extensions/AttributeListSyntaxExtensions.swift index 4a4cfd73..9a9b2257 100644 --- a/Sources/SafeDICore/Extensions/AttributeListSyntaxExtensions.swift +++ b/Sources/SafeDICore/Extensions/AttributeListSyntaxExtensions.swift @@ -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 } @@ -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 } @@ -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 } @@ -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) diff --git a/Tests/SafeDICoreTests/TypeDescriptionTests.swift b/Tests/SafeDICoreTests/TypeDescriptionTests.swift index 49e86248..09e068eb 100644 --- a/Tests/SafeDICoreTests/TypeDescriptionTests.swift +++ b/Tests/SafeDICoreTests/TypeDescriptionTests.swift @@ -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 } }