Skip to content

Commit fc810e1

Browse files
committed
SILGen: Relax assertion about missing vtable entries in a class
Since resilient class metadata is built at runtime, we don't actually care if there are missing vtable entries. The restriction was relaxed in Sema in 9117c57, but SILGen still had an assertion here. Add a test and relax the assertion. Fixes <rdar://problem/58644615>.
1 parent 7952f05 commit fc810e1

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

lib/SILGen/SILGenType.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,14 @@ class SILGenVTable : public SILVTableVisitor<SILGenVTable> {
311311
}
312312

313313
void addPlaceholder(MissingMemberDecl *m) {
314-
assert(m->getNumberOfVTableEntries() == 0
315-
&& "Should not be emitting class with missing members");
314+
#ifndef NDEBUG
315+
auto *classDecl = cast<ClassDecl>(m->getDeclContext());
316+
bool isResilient =
317+
classDecl->isResilient(SGM.M.getSwiftModule(),
318+
ResilienceExpansion::Maximal);
319+
assert(isResilient || m->getNumberOfVTableEntries() == 0 &&
320+
"Should not be emitting fragile class with missing members");
321+
#endif
316322
}
317323
};
318324

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// For convenience, this file includes the three different "files" used in this
4+
// test. It selects one with -DCoreDishwasher, -DDishwasherKit, or neither.
5+
6+
// RUN: %target-swift-frontend -emit-module %s -DCoreDishwasher -module-name CoreDishwasher -o %t/CoreDishwasher -emit-module-path %t/CoreDishwasher.swiftmodule -I %t
7+
// RUN: %target-swift-frontend -emit-module %s -DDishwasherKit -module-name DishwasherKit -o %t/DishwasherKit -emit-module-path %t/DishwasherKit.swiftmodule -enable-library-evolution -I %t
8+
// RUN: %target-swift-frontend -emit-silgen -I %t %s
9+
10+
#if CoreDishwasher
11+
12+
public struct SpimsterWicket {
13+
public init() {}
14+
}
15+
16+
#elseif DishwasherKit
17+
18+
@_implementationOnly import CoreDishwasher
19+
20+
open class Dishwasher {
21+
public init() {}
22+
23+
var wicket = SpimsterWicket()
24+
25+
open var modelName: String { "Dishwasher" }
26+
}
27+
28+
#else
29+
30+
import DishwasherKit
31+
32+
open class FancyDishwasher: Dishwasher {
33+
open override var modelName: String { "Fancy \(super.modelName)" }
34+
}
35+
36+
#endif

0 commit comments

Comments
 (0)