Skip to content

Commit be11dc6

Browse files
authored
Merge pull request #69338 from ahoppen/ahoppen/macro-def-warnings
[test] Fix warnings in syntax_macro_definitions.swift
2 parents fdc8e7d + 1178ae1 commit be11dc6

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct ColorLiteralMacro: ExpressionMacro {
2222
in context: some MacroExpansionContext
2323
) -> ExprSyntax {
2424
let argList = replaceFirstLabel(
25-
of: macro.argumentList, with: "_colorLiteralRed"
25+
of: macro.arguments, with: "_colorLiteralRed"
2626
)
2727
let initSyntax: ExprSyntax = ".init(\(argList))"
2828
return initSyntax
@@ -51,7 +51,7 @@ public struct AssertMacro: ExpressionMacro {
5151
of macro: some FreestandingMacroExpansionSyntax,
5252
in context: some MacroExpansionContext
5353
) -> ExprSyntax {
54-
guard let argument = macro.argumentList.first?.expression else {
54+
guard let argument = macro.arguments.first?.expression else {
5555
fatalError("boom")
5656
}
5757

@@ -64,7 +64,7 @@ public struct StringifyMacro: ExpressionMacro {
6464
of macro: some FreestandingMacroExpansionSyntax,
6565
in context: some MacroExpansionContext
6666
) -> ExprSyntax {
67-
guard let argument = macro.argumentList.first?.expression else {
67+
guard let argument = macro.arguments.first?.expression else {
6868
fatalError("boom")
6969
}
7070

@@ -77,7 +77,7 @@ public struct ExprAndDeclMacro: ExpressionMacro, DeclarationMacro {
7777
of macro: some FreestandingMacroExpansionSyntax,
7878
in context: some MacroExpansionContext
7979
) -> ExprSyntax {
80-
guard let argument = macro.argumentList.first?.expression else {
80+
guard let argument = macro.arguments.first?.expression else {
8181
fatalError("boom")
8282
}
8383

@@ -97,7 +97,7 @@ public struct StringifyAndTryMacro: ExpressionMacro {
9797
of macro: some FreestandingMacroExpansionSyntax,
9898
in context: some MacroExpansionContext
9999
) -> ExprSyntax {
100-
guard let argument = macro.argumentList.first?.expression else {
100+
guard let argument = macro.arguments.first?.expression else {
101101
fatalError("boom")
102102
}
103103

@@ -180,7 +180,7 @@ public enum AddBlocker: ExpressionMacro {
180180
context.diagnose(diag)
181181
}
182182

183-
return result.asProtocol(FreestandingMacroExpansionSyntax.self)!.argumentList.first!.expression
183+
return result.asProtocol(FreestandingMacroExpansionSyntax.self)!.arguments.first!.expression
184184
}
185185
}
186186

@@ -189,7 +189,7 @@ public class RecursiveMacro: ExpressionMacro {
189189
of macro: some FreestandingMacroExpansionSyntax,
190190
in context: some MacroExpansionContext
191191
) -> ExprSyntax {
192-
guard let argument = macro.argumentList.first?.expression,
192+
guard let argument = macro.arguments.first?.expression,
193193
argument.description == "false" else {
194194
return "\(macro)"
195195
}
@@ -237,7 +237,7 @@ public struct DefineBitwidthNumberedStructsMacro: DeclarationMacro {
237237
of node: some FreestandingMacroExpansionSyntax,
238238
in context: some MacroExpansionContext
239239
) throws -> [DeclSyntax] {
240-
guard let firstElement = node.argumentList.first,
240+
guard let firstElement = node.arguments.first,
241241
let stringLiteral = firstElement.expression.as(StringLiteralExprSyntax.self),
242242
stringLiteral.segments.count == 1,
243243
case let .stringSegment(prefix) = stringLiteral.segments.first else {
@@ -333,7 +333,7 @@ public struct WarningMacro: ExpressionMacro {
333333
of macro: some FreestandingMacroExpansionSyntax,
334334
in context: some MacroExpansionContext
335335
) throws -> ExprSyntax {
336-
guard let firstElement = macro.argumentList.first,
336+
guard let firstElement = macro.arguments.first,
337337
let stringLiteral = firstElement.expression
338338
.as(StringLiteralExprSyntax.self),
339339
stringLiteral.segments.count == 1,
@@ -362,13 +362,13 @@ public struct ErrorMacro: ExpressionMacro {
362362
of macro: some FreestandingMacroExpansionSyntax,
363363
in context: some MacroExpansionContext
364364
) throws -> ExprSyntax {
365-
guard let firstElement = macro.argumentList.first,
365+
guard let firstElement = macro.arguments.first,
366366
let stringLiteral = firstElement.expression.as(StringLiteralExprSyntax.self),
367367
stringLiteral.segments.count == 1,
368368
case let .stringSegment(messageString)? = stringLiteral.segments.first
369369
else {
370370
let errorNode: Syntax
371-
if let firstElement = macro.argumentList.first {
371+
if let firstElement = macro.arguments.first {
372372
errorNode = Syntax(firstElement)
373373
} else {
374374
errorNode = Syntax(macro)
@@ -470,6 +470,8 @@ extension AccessorBlockSyntax {
470470
return false
471471
case .getter:
472472
return true
473+
@unknown default:
474+
return false
473475
}
474476
}
475477
}
@@ -512,12 +514,6 @@ public struct WillSetMacro: AccessorMacro {
512514
providingAccessorsOf declaration: some DeclSyntaxProtocol,
513515
in context: some MacroExpansionContext
514516
) throws -> [AccessorDeclSyntax] {
515-
guard let varDecl = declaration.as(VariableDeclSyntax.self),
516-
let binding = varDecl.bindings.first,
517-
let identifier = binding.pattern.as(IdentifierPatternSyntax.self)?.identifier else {
518-
return []
519-
}
520-
521517
return [
522518
"""
523519
willSet { }
@@ -854,7 +850,7 @@ public enum LeftHandOperandFinderMacro: ExpressionMacro {
854850
let visitor = Visitor(context: context)
855851
visitor.walk(node)
856852

857-
return node.argumentList.first!.expression
853+
return node.arguments.first!.expression
858854
}
859855
}
860856

@@ -995,7 +991,7 @@ public struct CoerceToIntMacro: ExpressionMacro {
995991
of node: some FreestandingMacroExpansionSyntax,
996992
in context: some MacroExpansionContext
997993
) -> ExprSyntax {
998-
"\(node.argumentList.first!.expression) as Int"
994+
"\(node.arguments.first!.expression) as Int"
999995
}
1000996
}
1001997

@@ -1660,7 +1656,7 @@ public struct DefineAnonymousTypesMacro: DeclarationMacro {
16601656
}
16611657

16621658
let accessSpecifier: String
1663-
if let _ = node.argumentList.first(labeled: "public") {
1659+
if let _ = node.arguments.first(labeled: "public") {
16641660
accessSpecifier = "public "
16651661
} else {
16661662
accessSpecifier = ""
@@ -1695,7 +1691,7 @@ public struct DefineAnonymousTypesMacro: DeclarationMacro {
16951691
"""
16961692
]
16971693

1698-
if let _ = node.argumentList.first(labeled: "causeErrors") {
1694+
if let _ = node.arguments.first(labeled: "causeErrors") {
16991695

17001696
results += ["""
17011697
@@ -1836,7 +1832,7 @@ public struct UseIdentifierMacro: DeclarationMacro {
18361832
of node: some FreestandingMacroExpansionSyntax,
18371833
in context: some MacroExpansionContext
18381834
) throws -> [DeclSyntax] {
1839-
guard let argument = node.argumentList.first?.expression.as(StringLiteralExprSyntax.self) else {
1835+
guard let argument = node.arguments.first?.expression.as(StringLiteralExprSyntax.self) else {
18401836
fatalError("boom")
18411837
}
18421838
return [

0 commit comments

Comments
 (0)