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 77
88public typealias Stringified < T> = ( T , String )
99
10- // expected-note@+2{{macro 'stringify' is not '@usableFromInline' or public}}
1110@freestanding ( expression)
1211macro stringify< T> ( _ value: T ) -> Stringified < T > = #externalMacro(
1312 module: " MacroDefinition " , type: " StringifyMacro "
@@ -56,8 +55,5 @@ func testIdentifier(notOkay: Stringified<String> = #stringify(myString)) {}
5655// expected-error@+1{{only literals are permitted}}
5756func testString( interpolated: Stringified < String > = #stringify ( " Hello \( 0b10001 ) " ) ) { }
5857
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-
6258// expected-error@+1{{default argument value of type '(Int, String)' cannot be converted to type 'Int'}}
6359func testReturn( wrongType: Int = #stringify ( 0 ) ) { }
You can’t perform that action at this time.
0 commit comments