Skip to content

Commit c8ca517

Browse files
committed
[ModuleInterface] Don't alias the stdlib or builtin module
Not aliasing the stdlib should allows it to be used in inlinable code. Since builtin isn't imported explicitly, references to it shouldn't use the alias. rdar://104582241
1 parent 32d4eda commit c8ca517

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ static void printToolVersionAndFlagsComment(raw_ostream &out,
8181

8282
for (ImportedModule import: imports) {
8383
StringRef importedName = import.importedModule->getNameStr();
84+
// Skip Swift as it's commonly used in inlinable code,
85+
// and Builtin as it's imported implicitly by name.
86+
if (importedName == STDLIB_NAME ||
87+
importedName == BUILTIN_NAME)
88+
continue;
89+
8490
if (AliasModuleNamesTargets.insert(importedName).second) {
8591
out << " -module-alias " << MODULE_DISAMBIGUATING_PREFIX <<
8692
importedName << "=" << importedName;

test/ModuleInterface/ambiguous-aliases-workaround-swiftinterface.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// RUN: -emit-module-interface-path %t/Client.swiftinterface \
2020
// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface \
2121
// RUN: %t/Client.swift -I %t -experimental-spi-only-imports \
22-
// RUN: -alias-module-names-in-module-interface
22+
// RUN: -alias-module-names-in-module-interface -parse-stdlib
2323
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I%t
2424
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I%t
2525

@@ -48,3 +48,10 @@ import PublicLib
4848
// PUBLIC: import Module___PublicLib
4949
// PRIVATE: import Module___PublicLib
5050
// PRIVATE: import Module___SPILib
51+
52+
public func builtinUser(_ a: Builtin.Int32) {}
53+
54+
@inlinable
55+
public func builtinInlinableUser() {
56+
var a: Builtin.Int32
57+
}

test/ModuleInterface/ambiguous-aliases-workaround.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public struct SomeType {
7777
@inlinable
7878
public func inlinableFunc() {
7979
var x: AmbiguousClientName
80+
var y: Swift.Int
8081
}
8182
}
8283

0 commit comments

Comments
 (0)