7
7
@attached ( peer) macro m1( ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
8
8
9
9
@attached ( peer) macro m2( _: Int ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
10
- // expected-note@-1{{candidate has partially matching parameter list (Int) }}
10
+ // expected-note@-1{{'m2' declared here }}
11
11
// expected-note@-2{{candidate expects value of type 'Int' for parameter #1 (got 'String')}}
12
12
13
13
@attached ( peer) macro m2( _: Double ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
14
- // expected-note@-1{{candidate has partially matching parameter list (Double)}}
15
- // expected-note@-2{{candidate expects value of type 'Double' for parameter #1 (got 'String')}}
14
+ // expected-note@-1{{candidate expects value of type 'Double' for parameter #1 (got 'String')}}
16
15
17
16
@attached ( peer) macro m3( message: String ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
17
+ // expected-note@-1{{'m3(message:)' declared here}}
18
+
19
+ @attached ( peer) macro m4( _ param1: Int , label2 param2: String ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
20
+ // expected-note@-1{{'m4(_:label2:)' declared here}}
21
+ // expected-note@-2{{'m4(_:label2:)' declared here}}
22
+ // expected-note@-3{{'m4(_:label2:)' declared here}}
23
+
24
+ @attached ( peer) macro m5( label1: Int , label2: String ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
25
+ // expected-note@-1{{'m5(label1:label2:)' declared here}}
26
+
27
+ @attached ( peer) macro m6( label: Int = 42 ) = #externalMacro( module: " MacroDefinition " , type: " EmptyPeerMacro " )
18
28
19
29
@freestanding ( expression) macro stringify< T> ( _ value: T ) -> ( T , String ) = #externalMacro( module: " MyMacros " , type: " StringifyMacro " )
20
30
// expected-warning@-1{{external macro implementation type 'MyMacros.StringifyMacro' could not be found for macro 'stringify'}}
21
31
// expected-note@-2{{'stringify' declared here}}
22
32
23
33
@m1 struct X1 { }
24
34
25
- @m2 struct X2 { } // expected-error{{no exact matches in call to macro 'm2'}}
35
+ @m2 struct X2 { } // expected-error{{missing argument for parameter #1 in macro expansion}}{{4-4=(<#Int#>)}}
36
+
37
+ @m3 struct X3 { } // expected-error{{missing argument for parameter 'message' in macro expansion}}{{4-4=(message: <#String#>)}}
38
+
39
+ @m4 struct X4 { } // expected-error{{missing arguments for parameters #1, 'label2' in macro expansion}}{{4-4=(<#Int#>, label2: <#String#>)}}
40
+
41
+ @m5 struct X5 { } // expected-error{{missing arguments for parameters 'label1', 'label2' in macro expansion}}{{4-4=(label1: <#Int#>, label2: <#String#>)}}
42
+
43
+ @m6 struct X6 { }
26
44
27
45
// Check for nesting rules.
28
46
struct SkipNestedType {
@@ -54,6 +72,10 @@ struct TestMacroArgs {
54
72
55
73
@m2 ( Nested . x) struct Args5 { }
56
74
75
+ @m4 ( 10 ) struct Args6 { } // expected-error{{missing argument for parameter 'label2' in macro expansion}}{{9-9=, label2: <#String#>}}
76
+
77
+ @m4 ( label2: " test " ) struct Args7 { } // expected-error{{missing argument for parameter #1 in macro expansion}}{{7-7=<#Int#>, }}
78
+
57
79
struct Nested {
58
80
static let x = 10
59
81
@@ -62,15 +84,15 @@ struct TestMacroArgs {
62
84
@m2 ( Nested . x) struct Args2 { }
63
85
}
64
86
65
- @m3 ( message: stringify ( Nested . x) . 1 ) struct Args6 { }
87
+ @m3 ( message: stringify ( Nested . x) . 1 ) struct Args8 { }
66
88
// expected-error@-1{{expansion of macro 'stringify' requires leading '#'}}
67
89
68
- @m3 ( message: #stringify ( ) . 1 ) struct Args7 { }
90
+ @m3 ( message: #stringify ( ) . 1 ) struct Args9 { }
69
91
// expected-error@-1{{missing argument for parameter #1 in macro expansion}}
70
92
71
- @m3 ( message: #stringify ( Nested . x) . 1 ) struct Args8 { }
93
+ @m3 ( message: #stringify ( Nested . x) . 1 ) struct Args10 { }
72
94
73
95
// Allow macros to have arbitrary generic specialization lists, but warn
74
96
// https://github.com/swiftlang/swift/issues/75500
75
- @m1 < UInt > struct Args9 { } // expected-warning {{cannot specialize a non-generic external macro 'm1()'}}
97
+ @m1 < UInt > struct Args11 { } // expected-warning {{cannot specialize a non-generic external macro 'm1()'}}
76
98
}
0 commit comments