[ModuleInterface] Support aliasing a module loaded from a swiftinterface

This commit is contained in:
Alexis Laferrière
2022-11-04 10:28:54 -07:00
parent 3aa1c1afd8
commit 1ce67099de
2 changed files with 34 additions and 1 deletions

View File

@@ -1027,9 +1027,10 @@ class ModuleInterfaceLoaderImpl {
}
// Set up a builder if we need to build the module. It'll also set up
// the genericSubInvocation we'll need to use to compute the cache paths.
Identifier realName = ctx.getRealModuleName(ctx.getIdentifier(moduleName));
ImplicitModuleInterfaceBuilder builder(
ctx.SourceMgr, diagsToUse,
astDelegate, interfacePath, moduleName, cacheDir,
astDelegate, interfacePath, realName.str(), cacheDir,
prebuiltCacheDir, backupInterfaceDir, StringRef(),
Opts.disableInterfaceLock,
ctx.IgnoreAdjacentModules, diagnosticLoc,

View File

@@ -0,0 +1,32 @@
/// Check that we can alias a module imported from a swiftinterface
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -emit-module -module-name Lib \
// RUN: -swift-version 5 -enable-library-evolution \
// RUN: -o %t/Lib.swiftmodule \
// RUN: -emit-module-interface-path %t/Lib.swiftinterface \
// RUN: %t/Lib.swift
/// We can alias an imported module built from a swiftmodule
// RUN: %target-swift-frontend -typecheck -module-name Client \
// RUN: -swift-version 5 \
// RUN: -module-alias AliasedLib=Lib \
// RUN: %t/Client.swift -I%t
/// We can alias an imported module built from a swiftinterface
// RUN: rm %t/Lib.swiftmodule
// RUN: %target-swift-frontend -typecheck -module-name Client \
// RUN: -swift-version 5 \
// RUN: -module-alias AliasedLib=Lib \
// RUN: %t/Client.swift -I%t
//--- Lib.swift
public func foo() {}
//--- Client.swift
import AliasedLib
func main() {
AliasedLib.foo()
}