Skip to content

Commit cbaf558

Browse files
committed
[Tests] NFC: Add test-cases where typealias clashes with macro declaration
1 parent 42f80fb commit cbaf558

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/Macros/macro_and_typealias.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// REQUIRES: swift_swift_parser, executable_test
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/variadic_macros.swift -g -no-toolchain-stdlib-rpath
5+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5
6+
7+
@freestanding(expression) public macro Print<each Value>(_ value: repeat each Value) = #externalMacro(module: "MacroDefinition", type: "PrintMacro")
8+
@freestanding(expression) public macro OtherPrint<each Value>(_ value: repeat each Value) = #externalMacro(module: "MacroDefinition", type: "PrintMacro")
9+
10+
public struct Printer<Value> {
11+
init(_: (Value) -> Void) {}
12+
}
13+
14+
typealias Print = Printer
15+
typealias OtherPrint<T> = Printer<T>
16+
17+
struct Test {
18+
struct Object {
19+
var prop: Int
20+
}
21+
22+
func test() {
23+
let _ = Print<Object> { // Ok
24+
compute(root: $0, \.prop)
25+
}
26+
27+
let _ = OtherPrint<Object> { // Ok
28+
compute(root: $0, \.prop)
29+
}
30+
}
31+
32+
func compute<R, V>(root: R, _: KeyPath<R, V>) {}
33+
}

0 commit comments

Comments
 (0)