File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ // REQUIRES: swift_swift_parser, asserts
2
+ // REQUIRES: OS=macosx
3
+
4
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -module-name MacrosTest -target %target-cpu-apple-macos50
5
+
6
+ @freestanding ( expression)
7
+ macro overloadedOnAvailability( _: Any ) -> Int = #externalMacro( module: " MacroLibrary " , type: " MyOldMacro " )
8
+ //expected-warning@-1{{external macro implementation type 'MacroLibrary.MyOldMacro'}}
9
+ // expected-note@-2 2{{'overloadedOnAvailability' declared here}}
10
+
11
+ @available ( macOS 60 , * )
12
+ @freestanding ( expression)
13
+ macro overloadedOnAvailability( _: Int ) -> Double = #externalMacro( module: " MacroLibrary " , type: " MyNewMacro " )
14
+ //expected-warning@-1{{external macro implementation type 'MacroLibrary.MyNewMacro'}}
15
+ // expected-note@-2{{'overloadedOnAvailability' declared here}}
16
+
17
+
18
+ func mutateInt( _: inout Int ) { }
19
+ func mutateDouble( _: inout Double ) { }
20
+
21
+ func testAvailabilityOld( ) {
22
+ var a = #overloadedOnAvailability( 1 )
23
+ mutateInt ( & a)
24
+ // expected-error@-2{{external macro implementation type 'MacroLibrary.MyOldMacro'}}
25
+ }
26
+
27
+ @available ( macOS 60 , * )
28
+ func testAvailabilitNew( a: Any ) {
29
+ var a = #overloadedOnAvailability( 1 )
30
+ mutateDouble ( & a)
31
+ // expected-error@-2{{external macro implementation type 'MacroLibrary.MyNewMa}}
32
+
33
+ var b = #overloadedOnAvailability( a)
34
+ mutateInt ( & b)
35
+ // expected-error@-2{{external macro implementation type 'MacroLibrary.MyOldMacro'}}
36
+ }
You can’t perform that action at this time.
0 commit comments