Skip to content

Commit

Permalink
Merge pull request #75659 from xymus/shadow-dont-warn-with-alias-work…
Browse files Browse the repository at this point in the history
…around

ModuleInterface: Don't warn on name conflict when the alias workaround is enabled
  • Loading branch information
xymus authored Aug 5, 2024
2 parents 661f368 + b4fb572 commit eea22c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Frontend/ModuleInterfaceSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ static void
diagnoseDeclShadowsModule(ModuleInterfaceOptions const &Opts,
TypeDecl *shadowingDecl, ModuleDecl *shadowedModule,
ModuleDecl *brokenModule) {
if (Opts.PreserveTypesAsWritten || shadowingDecl == shadowedModule)
if (Opts.PreserveTypesAsWritten || Opts.AliasModuleNames ||
shadowingDecl == shadowedModule)
return;

shadowingDecl->diagnose(
Expand Down
4 changes: 4 additions & 0 deletions test/ModuleInterface/module_shadowing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// RUN: %empty-directory(%t/subtest-2)
// 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

// alias-module-names-in-module-interface also disables this warning.
// RUN: %empty-directory(%t/subtest-2)
// 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

// Build this module in a different configuration where it will shadow itself.
// RUN: %empty-directory(%t/subtest-3)
// 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
Expand Down

0 comments on commit eea22c2

Please sign in to comment.