File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change
1
+ // REQUIRES: swift_swift_parser
2
+
3
+ // RUN: %empty-directory(%t)
4
+ // RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
5
+
6
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -enable-experimental-feature ExpressionMacroDefaultArguments
7
+
8
+ public typealias Stringified < T> = ( T , String )
9
+
10
+ @freestanding ( expression)
11
+ public macro publicStringify< T> ( _ value: T ) -> Stringified < T > = #externalMacro(
12
+ module: " MacroDefinition " , type: " StringifyMacro "
13
+ )
14
+
15
+ public func publicUsePublic( okay: Stringified < Int > = #publicStringify ( 0 ) ) { }
16
+ func internalUsePublic( okay: Stringified < Int > = #publicStringify ( 0 ) ) { }
17
+
18
+ // expected-note@+2{{macro 'stringify' is not '@usableFromInline' or public}}
19
+ @freestanding ( expression)
20
+ macro stringify< T> ( _ value: T ) -> Stringified < T > = #externalMacro(
21
+ module: " MacroDefinition " , type: " StringifyMacro "
22
+ )
23
+
24
+ // expected-error@+1{{macro 'stringify' is internal and cannot be referenced from a default argument value}}
25
+ public func publicUseInternal( fail: Stringified < Int > = #stringify ( 0 ) ) { }
26
+ func internalUseInternal( okay: Stringified < Int > = #stringify ( 0 ) ) { }
Original file line number Diff line number Diff line change 7
7
8
8
public typealias Stringified < T> = ( T , String )
9
9
10
- // expected-note@+2{{macro 'stringify' is not '@usableFromInline' or public}}
11
10
@freestanding ( expression)
12
11
macro stringify< T> ( _ value: T ) -> Stringified < T > = #externalMacro(
13
12
module: " MacroDefinition " , type: " StringifyMacro "
@@ -56,8 +55,5 @@ func testIdentifier(notOkay: Stringified<String> = #stringify(myString)) {}
56
55
// expected-error@+1{{only literals are permitted}}
57
56
func testString( interpolated: Stringified < String > = #stringify ( " Hello \( 0b10001 ) " ) ) { }
58
57
59
- // expected-error@+1{{macro 'stringify' is internal and cannot be referenced from a default argument value}}
60
- public func testAccess( internal: Stringified < Int > = #stringify ( 0 ) ) { }
61
-
62
58
// expected-error@+1{{default argument value of type '(Int, String)' cannot be converted to type 'Int'}}
63
59
func testReturn( wrongType: Int = #stringify ( 0 ) ) { }
You can’t perform that action at this time.
0 commit comments