Skip to content

Commit 988e9d6

Browse files
authored
Merge pull request #29726 from slavapestov/fix-silgen-vtable-assertion
SILGen: Relax assertion about missing vtable entries in a class
2 parents 413b8d0 + fc810e1 commit 988e9d6

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 8 additions & 2 deletions
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

Lines changed: 36 additions & 0 deletions
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)