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 @@ -7121,11 +7121,17 @@ void AttributeChecker::visitMacroRoleAttr(MacroRoleAttr *attr) {
71217121 break ;
71227122 case MacroRole::Peer:
71237123 break ;
7124- case MacroRole::Conformance:
7124+ case MacroRole::Conformance: {
7125+ // Suppress the conformance macro error in swiftinterfaces.
7126+ SourceFile *file = D->getDeclContext ()->getParentSourceFile ();
7127+ if (file && file->Kind == SourceFileKind::Interface)
7128+ break ;
7129+
71257130 diagnoseAndRemoveAttr (attr, diag::conformance_macro)
71267131 .fixItReplace (attr->getRange (),
71277132 " @attached(extension, conformances: <#Protocol#>)" );
71287133 break ;
7134+ }
71297135 case MacroRole::Extension:
71307136 break ;
71317137 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