2
2
3
3
// RUN: %empty-directory(%t)
4
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
- // RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) %s -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1
5
+ // RUN: %target-swift-frontend -swift-version 5 -emit-module -o %t/ModuleWithEquatable.swiftmodule %s -DMODULE_EXPORTING_TYPE -module-name ModuleWithEquatable -load-plugin-library %t/%target-library-name(MacroDefinition) -emit-module-interface-path %t/ModuleWithEquatable.swiftinterface
6
+
7
+ // Check the generated .swiftinterface
8
+ // RUN: %FileCheck -check-prefix INTERFACE %s < %t/ModuleWithEquatable.swiftinterface
9
+
10
+ // 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
6
11
// RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
7
- // RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5
8
- // RUN: %target-build-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5 -emit-tbd -emit-tbd-path %t/MacroUser.tbd
12
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5 -I %t
13
+ // RUN: %target-build-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5 -emit-tbd -emit-tbd-path %t/MacroUser.tbd -I %t
9
14
// RUN: %target-codesign %t/main
10
15
// RUN: %target-run %t/main | %FileCheck %s
11
16
@@ -15,10 +20,23 @@ macro Equatable() = #externalMacro(module: "MacroDefinition", type: "EquatableMa
15
20
@attached ( conformance)
16
21
macro Hashable( ) = #externalMacro( module: " MacroDefinition " , type: " HashableMacro " )
17
22
23
+ #if MODULE_EXPORTING_TYPE
24
+ @Equatable
25
+ public struct PublicEquatable {
26
+ public init ( ) { }
27
+ }
28
+
29
+ // INTERFACE: public struct PublicEquatable
30
+ // INTERFACE: extension ModuleWithEquatable.PublicEquatable : Swift.Equatable
31
+
32
+ #else
33
+ import ModuleWithEquatable
34
+
18
35
func requireEquatable( _ value: some Equatable ) {
19
36
print ( value == value)
20
37
}
21
38
39
+ // expected-note@+1{{where 'some Hashable' = 'PublicEquatable'}}
22
40
func requireHashable( _ value: some Hashable ) {
23
41
print ( value. hashValue)
24
42
}
@@ -44,6 +62,13 @@ requireHashable(S2())
44
62
45
63
requireEquatable ( E . Nested ( ) )
46
64
65
+ #if TEST_DIAGNOSTICS
66
+ requireEquatable ( PublicEquatable ( ) )
67
+
68
+ requireHashable ( PublicEquatable ( ) )
69
+ //expected-error@-1{{global function 'requireHashable' requires that 'PublicEquatable' conform to 'Hashable'}}
70
+ #endif
71
+
47
72
@attached ( conformance)
48
73
@attached ( member, names: named ( requirement) )
49
74
macro DelegatedConformance( ) = #externalMacro( module: " MacroDefinition " , type: " DelegatedConformanceMacro " )
@@ -70,3 +95,4 @@ func requiresP(_ value: (some P).Type) {
70
95
71
96
// CHECK: Wrapped.requirement
72
97
requiresP ( Generic< Wrapped> . self )
98
+ #endif
0 commit comments