Skip to content

Commit 1ce6709

Browse files
committed
[ModuleInterface] Support aliasing a module loaded from a swiftinterface
1 parent 3aa1c1a commit 1ce6709

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,10 @@ class ModuleInterfaceLoaderImpl {
10271027
}
10281028
// Set up a builder if we need to build the module. It'll also set up
10291029
// the genericSubInvocation we'll need to use to compute the cache paths.
1030+
Identifier realName = ctx.getRealModuleName(ctx.getIdentifier(moduleName));
10301031
ImplicitModuleInterfaceBuilder builder(
10311032
ctx.SourceMgr, diagsToUse,
1032-
astDelegate, interfacePath, moduleName, cacheDir,
1033+
astDelegate, interfacePath, realName.str(), cacheDir,
10331034
prebuiltCacheDir, backupInterfaceDir, StringRef(),
10341035
Opts.disableInterfaceLock,
10351036
ctx.IgnoreAdjacentModules, diagnosticLoc,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// Check that we can alias a module imported from a swiftinterface
2+
// RUN: %empty-directory(%t)
3+
// RUN: split-file %s %t
4+
5+
// RUN: %target-swift-frontend -emit-module -module-name Lib \
6+
// RUN: -swift-version 5 -enable-library-evolution \
7+
// RUN: -o %t/Lib.swiftmodule \
8+
// RUN: -emit-module-interface-path %t/Lib.swiftinterface \
9+
// RUN: %t/Lib.swift
10+
11+
/// We can alias an imported module built from a swiftmodule
12+
// RUN: %target-swift-frontend -typecheck -module-name Client \
13+
// RUN: -swift-version 5 \
14+
// RUN: -module-alias AliasedLib=Lib \
15+
// RUN: %t/Client.swift -I%t
16+
17+
/// We can alias an imported module built from a swiftinterface
18+
// RUN: rm %t/Lib.swiftmodule
19+
// RUN: %target-swift-frontend -typecheck -module-name Client \
20+
// RUN: -swift-version 5 \
21+
// RUN: -module-alias AliasedLib=Lib \
22+
// RUN: %t/Client.swift -I%t
23+
24+
//--- Lib.swift
25+
public func foo() {}
26+
27+
//--- Client.swift
28+
import AliasedLib
29+
30+
func main() {
31+
AliasedLib.foo()
32+
}

0 commit comments

Comments
 (0)