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 @@ -7137,11 +7137,17 @@ void AttributeChecker::visitMacroRoleAttr(MacroRoleAttr *attr) {
7137
7137
break ;
7138
7138
case MacroRole::Peer:
7139
7139
break ;
7140
- case MacroRole::Conformance:
7140
+ case MacroRole::Conformance: {
7141
+ // Suppress the conformance macro error in swiftinterfaces.
7142
+ SourceFile *file = D->getDeclContext ()->getParentSourceFile ();
7143
+ if (file && file->Kind == SourceFileKind::Interface)
7144
+ break ;
7145
+
7141
7146
diagnoseAndRemoveAttr (attr, diag::conformance_macro)
7142
7147
.fixItReplace (attr->getRange (),
7143
7148
" @attached(extension, conformances: <#Protocol#>)" );
7144
7149
break ;
7150
+ }
7145
7151
case MacroRole::Extension:
7146
7152
break ;
7147
7153
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