Skip to content

Commit eea22c2

Browse files
authored
Merge pull request #75659 from xymus/shadow-dont-warn-with-alias-workaround
ModuleInterface: Don't warn on name conflict when the alias workaround is enabled
2 parents 661f368 + b4fb572 commit eea22c2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static void
184184
diagnoseDeclShadowsModule(ModuleInterfaceOptions const &Opts,
185185
TypeDecl *shadowingDecl, ModuleDecl *shadowedModule,
186186
ModuleDecl *brokenModule) {
187-
if (Opts.PreserveTypesAsWritten || shadowingDecl == shadowedModule)
187+
if (Opts.PreserveTypesAsWritten || Opts.AliasModuleNames ||
188+
shadowingDecl == shadowedModule)
188189
return;
189190

190191
shadowingDecl->diagnose(

test/ModuleInterface/module_shadowing.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
// RUN: %empty-directory(%t/subtest-2)
1616
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/mcp -emit-module-interface-path %t/subtest-2/module_shadowing.swiftinterface %s -enable-library-evolution -module-name module_shadowing -I %t/lib -module-interface-preserve-types-as-written -swift-version 5 -verify
1717

18+
// alias-module-names-in-module-interface also disables this warning.
19+
// RUN: %empty-directory(%t/subtest-2)
20+
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/mcp -emit-module-interface-path %t/subtest-2/module_shadowing.swiftinterface %s -enable-library-evolution -module-name module_shadowing -I %t/lib -alias-module-names-in-module-interface -swift-version 5 -verify
21+
1822
// Build this module in a different configuration where it will shadow itself.
1923
// RUN: %empty-directory(%t/subtest-3)
2024
// RUN: %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/mcp -emit-module-interface-path %t/subtest-3/ShadowyHorror.swiftinterface %s -enable-library-evolution -module-name ShadowyHorror -DSELF_SHADOW -swift-version 5 2>&1 | %FileCheck --check-prefix SELF --implicit-check-not TestModule %s

0 commit comments

Comments
 (0)