File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -7131,11 +7131,17 @@ void AttributeChecker::visitMacroRoleAttr(MacroRoleAttr *attr) {
7131
7131
break ;
7132
7132
case MacroRole::Peer:
7133
7133
break ;
7134
- case MacroRole::Conformance:
7134
+ case MacroRole::Conformance: {
7135
+ // Suppress the conformance macro error in swiftinterfaces.
7136
+ SourceFile *file = D->getDeclContext ()->getParentSourceFile ();
7137
+ if (file && file->Kind == SourceFileKind::Interface)
7138
+ break ;
7139
+
7135
7140
diagnoseAndRemoveAttr (attr, diag::conformance_macro)
7136
7141
.fixItReplace (attr->getRange (),
7137
7142
" @attached(extension, conformances: <#Protocol#>)" );
7138
7143
break ;
7144
+ }
7139
7145
case MacroRole::Extension:
7140
7146
break ;
7141
7147
default :
Original file line number Diff line number Diff line change
1
+ // swift-interface-format-version: 1.0
2
+ // swift-module-flags: -module-name ConformanceMacroLib
3
+
4
+ @attached(conformance)
5
+ public macro Equatable() = #externalMacro(module: "MacroDefinition", type: "EquatableMacro")
Original file line number Diff line number Diff line change
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/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
5
+
6
+
7
+ // RUN: %target-swift-frontend -compile-module-from-interface -module-name ConformanceMacroLib %S/Inputs/ConformanceMacroLib.swiftinterface -o %t/ConformanceMacroLib.swiftmodule
8
+
9
+ // RUN: %target-swift-frontend -swift-version 5 -typecheck -I%t -verify %s -verify-ignore-unknown -load-plugin-library %t/%target-library-name(MacroDefinition) -dump-macro-expansions > %t/expansions-dump.txt 2>&1
10
+ // RUN: %FileCheck -check-prefix=CHECK-DUMP %s < %t/expansions-dump.txt
11
+
12
+ import ConformanceMacroLib
13
+
14
+ @Equatable
15
+ struct S { }
16
+
17
+ // CHECK-DUMP: extension S: Equatable {
18
+ // CHECK-DUMP: }
You can’t perform that action at this time.
0 commit comments