Skip to content

Commit d85fbf6

Browse files
authored
Merge pull request swiftlang#68722 from kubamracek/embedded-extensions
[embedded] Stop emitting metadata for extensions
2 parents c5138a3 + 2babc5d commit d85fbf6

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5678,6 +5678,10 @@ static bool shouldEmitCategory(IRGenModule &IGM, ExtensionDecl *ext) {
56785678
void IRGenModule::emitExtension(ExtensionDecl *ext) {
56795679
emitNestedTypeDecls(ext->getMembers());
56805680

5681+
if (Context.LangOpts.hasFeature(Feature::Embedded)) {
5682+
return;
5683+
}
5684+
56815685
addLazyConformances(ext);
56825686

56835687
// Generate a category if the extension either introduces a

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ bool IRGenerator::canEmitWitnessTableLazily(SILWitnessTable *wt) {
12951295
}
12961296

12971297
void IRGenerator::addLazyWitnessTable(const ProtocolConformance *Conf) {
1298+
assert(!SIL.getASTContext().LangOpts.hasFeature(Feature::Embedded));
1299+
12981300
if (auto *wt = SIL.lookUpWitnessTable(Conf)) {
12991301
// Add it to the queue if it hasn't already been put there.
13001302
if (canEmitWitnessTableLazily(wt) &&

test/embedded/extensions.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
4+
// RUN: %target-swift-frontend -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift -parse-stdlib -enable-experimental-feature Embedded
5+
// RUN: %target-swift-frontend -emit-ir -I %t %t/Main.swift -parse-stdlib -enable-experimental-feature Embedded | %FileCheck %s
6+
7+
// REQUIRES: swift_in_compiler
8+
9+
// BEGIN MyModule.swift
10+
11+
public protocol MyProtocol {}
12+
13+
// BEGIN Main.swift
14+
15+
import MyModule
16+
17+
struct MyStruct {}
18+
19+
extension MyStruct: MyProtocol {}
20+
21+
// CHECK: define {{.*}}i32 @main(i32 %0, ptr %1)
22+
// CHECK-NOT: MyStruct
23+
// CHECK-NOT: MyProtocol

0 commit comments

Comments
 (0)