Skip to content

Commit 865bf1e

Browse files
committed
Test for diagnostics on access level and type
1 parent 7cc84f6 commit 865bf1e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/Macros/macro_default_argument_diagnostics.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -enable-experimental-feature ExpressionMacroDefaultArguments -enable-bare-slash-regex
77

8-
typealias Stringified<T> = (T, String)
8+
public typealias Stringified<T> = (T, String)
9+
10+
// expected-note@+2{{macro 'stringify' is not '@usableFromInline' or public}}
911
@freestanding(expression)
1012
macro stringify<T>(_ value: T) -> Stringified<T> = #externalMacro(
1113
module: "MacroDefinition", type: "StringifyMacro"
@@ -53,3 +55,9 @@ func testIdentifier(notOkay: Stringified<String> = #stringify(myString)) {}
5355

5456
// expected-error@+1{{argument to macro used as default argument must be literal}}
5557
func testString(interpolated: Stringified<String> = #stringify("Hello \(0b10001)")) {}
58+
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+
// expected-error@+1{{default argument value of type '(Int, String)' cannot be converted to type 'Int'}}
63+
func testReturn(wrongType: Int = #stringify(0)) {}

0 commit comments

Comments
 (0)