|
1 | 1 | // RUN: %target-typecheck-verify-swift -enable-experimental-feature Macros -module-name MacrosTest
|
2 | 2 |
|
3 |
| -@expression macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro") |
| 3 | +@freestanding(expression) macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro") |
4 | 4 | // expected-note@-1 2{{'stringify' declared here}}
|
5 | 5 | // expected-warning@-2{{external macro implementation type}}
|
6 |
| -@expression macro missingMacro1(_: Any) = MissingModule.MissingType // expected-note{{'missingMacro1' declared here}} |
7 |
| -// expected-warning@-1{{external macro definitions are now written using #externalMacro}}{{43-68=#externalMacro(module: "MissingModule", type: "MissingType")}} |
| 6 | +@freestanding(expression) macro missingMacro1(_: Any) = MissingModule.MissingType // expected-note{{'missingMacro1' declared here}} |
| 7 | +// expected-warning@-1{{external macro definitions are now written using #externalMacro}}{{57-82=#externalMacro(module: "MissingModule", type: "MissingType")}} |
8 | 8 | // expected-warning@-2{{external macro implementation type}}
|
9 |
| -@expression macro missingMacro2(_: Any) = #externalMacro(module: "MissingModule", type: "MissingType") |
| 9 | +@freestanding(expression) macro missingMacro2(_: Any) = #externalMacro(module: "MissingModule", type: "MissingType") |
10 | 10 | // expected-warning@-1{{external macro implementation type}}
|
11 | 11 |
|
12 | 12 | protocol P { }
|
13 | 13 |
|
14 |
| -@expression macro tryToHide<T: P>(_: T) -> some P = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 14 | +@freestanding(expression) macro tryToHide<T: P>(_: T) -> some P = #externalMacro(module: "BuiltinMacros", type: "Blah") |
15 | 15 | // expected-error@-1{{some' types are only permitted in properties, subscripts, and functions}}
|
16 | 16 | // expected-error@-2{{generic parameter 'T' could not be inferred}}
|
17 | 17 |
|
18 | 18 | internal struct X { } // expected-note{{type declared here}}
|
19 | 19 |
|
20 |
| -@expression public macro createAnX: X = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 20 | +@freestanding(expression) public macro createAnX: X = #externalMacro(module: "BuiltinMacros", type: "Blah") |
21 | 21 | // expected-error@-1{{macro cannot be declared public because its result type uses an internal type}}
|
22 | 22 | // expected-warning@-2{{external macro implementation type}}
|
23 | 23 |
|
24 |
| -@expression macro m1: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 24 | +@freestanding(expression) macro m1: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") |
25 | 25 | // expected-warning@-1{{external macro implementation type}}
|
26 |
| -@expression macro m1: Float = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 26 | +@freestanding(expression) macro m1: Float = #externalMacro(module: "BuiltinMacros", type: "Blah") |
27 | 27 | // expected-warning@-1{{external macro implementation type}}
|
28 | 28 |
|
29 |
| -@expression macro m2: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-note{{'m2' previously declared here}} |
| 29 | +@freestanding(expression) macro m2: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-note{{'m2' previously declared here}} |
30 | 30 | // expected-warning@-1{{external macro implementation type}}
|
31 |
| -@expression macro m2: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-error{{invalid redeclaration of 'm2'}} |
| 31 | +@freestanding(expression) macro m2: Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-error{{invalid redeclaration of 'm2'}} |
32 | 32 | // expected-warning@-1{{external macro implementation type}}
|
33 | 33 |
|
34 |
| -@expression macro m3(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 34 | +@freestanding(expression) macro m3(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") |
35 | 35 | // expected-warning@-1{{external macro implementation type}}
|
36 |
| -@expression macro m3(_: Int) -> Float = #externalMacro(module: "BuiltinMacros", type: "Blah") |
| 36 | +@freestanding(expression) macro m3(_: Int) -> Float = #externalMacro(module: "BuiltinMacros", type: "Blah") |
37 | 37 | // expected-warning@-1{{external macro implementation type}}
|
38 | 38 |
|
39 |
| -@expression macro m4(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-note{{'m4' previously declared here}} |
| 39 | +@freestanding(expression) macro m4(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-note{{'m4' previously declared here}} |
40 | 40 | // expected-warning@-1{{external macro implementation type}}
|
41 |
| -@expression macro m4(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-error{{invalid redeclaration of 'm4'}} |
| 41 | +@freestanding(expression) macro m4(_: Int) -> Int = #externalMacro(module: "BuiltinMacros", type: "Blah") // expected-error{{invalid redeclaration of 'm4'}} |
42 | 42 | // expected-warning@-1{{external macro implementation type}}
|
43 | 43 |
|
44 | 44 | struct ZZZ {
|
45 | 45 | macro m5: Int = #externalMacro(module: "BuiltinMacros", type: "Blah")
|
46 | 46 | // expected-error@-1{{macro 'm5' can only be declared at file scope}}
|
47 |
| - // expected-error@-2{{macro 'm5' must declare its applicable contexts (e.g., '@expression')}} |
| 47 | + // expected-error@-2{{macro 'm5' must declare its applicable roles}} |
48 | 48 | // expected-warning@-3{{external macro implementation type}}
|
49 | 49 | }
|
50 | 50 |
|
51 |
| -@expression macro multiArgMacro(_: Any, second: Any) = #externalMacro(module: "MissingModule", type: "MissingType") |
| 51 | +@freestanding(expression) macro multiArgMacro(_: Any, second: Any) = #externalMacro(module: "MissingModule", type: "MissingType") |
52 | 52 | // expected-note@-1{{'multiArgMacro(_:second:)' declared here}}
|
53 | 53 | // expected-warning@-2{{external macro implementation type}}
|
54 | 54 |
|
55 |
| -@expression macro overloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingType") |
| 55 | +@freestanding(expression) macro overloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingType") |
56 | 56 | // expected-warning@-1{{external macro implementation type}}
|
57 | 57 |
|
58 | 58 | func overloaded1(_ p: Any) { }
|
59 | 59 |
|
60 |
| -@expression macro notOverloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingType") // expected-note{{'notOverloaded1' previously declared here}} |
| 60 | +@freestanding(expression) macro notOverloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingType") // expected-note{{'notOverloaded1' previously declared here}} |
61 | 61 | // expected-warning@-1{{external macro implementation type}}
|
62 |
| -@expression macro notOverloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingOtherType") // expected-error{{invalid redeclaration of 'notOverloaded1'}} |
| 62 | +@freestanding(expression) macro notOverloaded1(_ p: P) = #externalMacro(module: "MissingModule", type: "MissingOtherType") // expected-error{{invalid redeclaration of 'notOverloaded1'}} |
63 | 63 | // expected-warning@-1{{external macro implementation type}}
|
64 | 64 |
|
65 |
| -@expression macro intIdentity(value: Int, _: Float) -> Int = #externalMacro(module: "MissingModule", type: "MissingType") |
| 65 | +@freestanding(expression) macro intIdentity(value: Int, _: Float) -> Int = #externalMacro(module: "MissingModule", type: "MissingType") |
66 | 66 | // expected-note@-1{{macro 'intIdentity(value:_:)' declared here}}
|
67 | 67 | // expected-warning@-2{{external macro implementation type}}
|
68 | 68 |
|
@@ -114,7 +114,7 @@ func testMissing() {
|
114 | 114 | #missingMacro1("hello") // expected-error{{external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'; the type must be public and provided via '-load-plugin-library'}}
|
115 | 115 | }
|
116 | 116 |
|
117 |
| -@expression macro undefined() // expected-error{{macro 'undefined()' requires a definition}} |
| 117 | +@freestanding(expression) macro undefined() // expected-error{{macro 'undefined()' requires a definition}} |
118 | 118 |
|
119 | 119 | func testExternalMacroOutOfPlace() {
|
120 | 120 | let _: Int = #externalMacro(module: "A", type: "B")
|
|
0 commit comments