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