Skip to content

Commit b4fb572

Browse files
committed
ModuleInterface: Don't warn on name conflict when the alias workaround is enabled
This warning is designed to be an early report of name conflicts in swiftinterfaces caused by a type having the same name as a module. Make sure we silence this warning when the workaround -alias-module-names-in-module-interface is enabled. This is what we already do for -module-interface-preserve-types-as-written. rdar://132990400
1 parent 1311a80 commit b4fb572

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
@@ -163,7 +163,8 @@ static void
163163
diagnoseDeclShadowsModule(ModuleInterfaceOptions const &Opts,
164164
TypeDecl *shadowingDecl, ModuleDecl *shadowedModule,
165165
ModuleDecl *brokenModule) {
166-
if (Opts.PreserveTypesAsWritten || shadowingDecl == shadowedModule)
166+
if (Opts.PreserveTypesAsWritten || Opts.AliasModuleNames ||
167+
shadowingDecl == shadowedModule)
167168
return;
168169

169170
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)