22
33// RUN: %empty-directory(%t)
44// 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
68// 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
911// RUN: %target-codesign %t/main
1012// RUN: %target-run %t/main | %FileCheck %s
1113
@@ -15,10 +17,20 @@ macro Equatable() = #externalMacro(module: "MacroDefinition", type: "EquatableMa
1517@attached ( conformance)
1618macro Hashable( ) = #externalMacro( module: " MacroDefinition " , type: " HashableMacro " )
1719
20+ #if MODULE_EXPORTING_TYPE
21+ @Equatable
22+ public struct PublicEquatable {
23+ public init ( ) { }
24+ }
25+
26+ #else
27+ import ModuleWithEquatable
28+
1829func requireEquatable( _ value: some Equatable ) {
1930 print ( value == value)
2031}
2132
33+ // expected-note@+1{{where 'some Hashable' = 'PublicEquatable'}}
2234func requireHashable( _ value: some Hashable ) {
2335 print ( value. hashValue)
2436}
@@ -44,6 +56,13 @@ requireHashable(S2())
4456
4557requireEquatable ( E . Nested ( ) )
4658
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+
4766@attached ( conformance)
4867@attached ( member, names: named ( requirement) )
4968macro DelegatedConformance( ) = #externalMacro( module: " MacroDefinition " , type: " DelegatedConformanceMacro " )
@@ -70,3 +89,4 @@ func requiresP(_ value: (some P).Type) {
7089
7190// CHECK: Wrapped.requirement
7291requiresP ( Generic< Wrapped> . self )
92+ #endif
0 commit comments