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)
6
+
7
+ // 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
8
// 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
9
+ // 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
10
+ // 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
11
// RUN: %target-codesign %t/main
10
12
// RUN: %target-run %t/main | %FileCheck %s
11
13
@@ -15,10 +17,20 @@ macro Equatable() = #externalMacro(module: "MacroDefinition", type: "EquatableMa
15
17
@attached ( conformance)
16
18
macro Hashable( ) = #externalMacro( module: " MacroDefinition " , type: " HashableMacro " )
17
19
20
+ #if MODULE_EXPORTING_TYPE
21
+ @Equatable
22
+ public struct PublicEquatable {
23
+ public init ( ) { }
24
+ }
25
+
26
+ #else
27
+ import ModuleWithEquatable
28
+
18
29
func requireEquatable( _ value: some Equatable ) {
19
30
print ( value == value)
20
31
}
21
32
33
+ // expected-note@+1{{where 'some Hashable' = 'PublicEquatable'}}
22
34
func requireHashable( _ value: some Hashable ) {
23
35
print ( value. hashValue)
24
36
}
@@ -44,6 +56,13 @@ requireHashable(S2())
44
56
45
57
requireEquatable ( E . Nested ( ) )
46
58
59
+ #if TEST_DIAGNOSTICS
60
+ requireEquatable ( PublicEquatable ( ) )
61
+
62
+ requireHashable ( PublicEquatable ( ) )
63
+ //expected-error@-1{{global function 'requireHashable' requires that 'PublicEquatable' conform to 'Hashable'}}
64
+ #endif
65
+
47
66
@attached ( conformance)
48
67
@attached ( member, names: named ( requirement) )
49
68
macro DelegatedConformance( ) = #externalMacro( module: " MacroDefinition " , type: " DelegatedConformanceMacro " )
@@ -70,3 +89,4 @@ func requiresP(_ value: (some P).Type) {
70
89
71
90
// CHECK: Wrapped.requirement
72
91
requiresP ( Generic< Wrapped> . self )
92
+ #endif
0 commit comments