-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathmacro_expand_conformances_xref.swift
48 lines (36 loc) · 1.65 KB
/
macro_expand_conformances_xref.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// REQUIRES: swift_swift_parser, executable_test
// RUN: %empty-directory(%t)
// 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
// Check for errors first
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking
// RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -I %t -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1
// RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
protocol P1 {}
protocol P2 {}
@attached(extension, conformances: P1, P2)
@attached(member, conformances: P1, P2, names: named(conformances))
macro ListConformances() = #externalMacro(module: "MacroDefinition", type: "ListConformancesMacro")
// CHECK-DUMP: [ "Root": [ "P1", "P2" ] ]
// CHECK-DUMP: extension Root: P1
// CHECK-DUMP: extension Root: P2
@ListConformances
class Root {
// CHECK-DUMP: extension OtherRoot: P1
// CHECK-DUMP: extension OtherRoot: P2
var other: OtherRoot?
}
// CHECK-DUMP: [ "P1Root": [ "P2" ] ]
// CHECK-DUMP-NOT: extension P1Root: P1
// CHECK-DUMP: extension P1Root: P2
@ListConformances
class P1Root: P1 { }
// CHECK-DUMP: [ "OtherRoot": [ "P1", "P2" ] ]
@ListConformances
class OtherRoot {
// CHECK-DUMP-NOT: extension OtherP1Root: P1
// CHECK-DUMP: extension OtherP1Root: P2
var other: OtherP1Root?
}
// CHECK-DUMP: [ "OtherP1Root": [ "P2" ] ]
@ListConformances
class OtherP1Root: P1 { }