Skip to content

Commit 8cf9382

Browse files
authored
[ModuleInterface] Don't include 'import Builtin' for the stdlib (#19319)
The special 'Builtin' module is implicitly imported via -parse-stdlib, and can't be found via normal import resolution, so we shouldn't print it in a textual interface.
1 parent a87dfb5 commit 8cf9382

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/FrontendTool/TextualInterfaceGeneration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ static void printImports(raw_ostream &out, ModuleDecl *M) {
5757

5858
for (auto import : allImports) {
5959
if (import.second->isStdlibModule() ||
60-
import.second->isOnoneSupportModule()) {
60+
import.second->isOnoneSupportModule() ||
61+
import.second->isBuiltinModule()) {
6162
continue;
6263
}
6364

test/ModuleInterface/stdlib.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null -parse-stdlib %s | %FileCheck %s
2+
3+
// CHECK-NOT: import Builtin
4+
5+
// CHECK: func test() {
6+
// CHECK-NEXT: Builtin.sizeof
7+
// CHECK-NEXT: {{^}$}}
8+
@inlinable public func test() {
9+
Builtin.sizeof(Builtin.Int8.self)
10+
}

0 commit comments

Comments
 (0)