diff --git a/lib/SILGen/SILGenType.cpp b/lib/SILGen/SILGenType.cpp index 0486b0080fc09..d0d5157dc3e38 100644 --- a/lib/SILGen/SILGenType.cpp +++ b/lib/SILGen/SILGenType.cpp @@ -311,8 +311,14 @@ class SILGenVTable : public SILVTableVisitor { } void addPlaceholder(MissingMemberDecl *m) { - assert(m->getNumberOfVTableEntries() == 0 - && "Should not be emitting class with missing members"); +#ifndef NDEBUG + auto *classDecl = cast(m->getDeclContext()); + bool isResilient = + classDecl->isResilient(SGM.M.getSwiftModule(), + ResilienceExpansion::Maximal); + assert(isResilient || m->getNumberOfVTableEntries() == 0 && + "Should not be emitting fragile class with missing members"); +#endif } }; diff --git a/test/SILGen/vtable_implementation_only.swift b/test/SILGen/vtable_implementation_only.swift new file mode 100644 index 0000000000000..a298c7e08bb13 --- /dev/null +++ b/test/SILGen/vtable_implementation_only.swift @@ -0,0 +1,36 @@ +// RUN: %empty-directory(%t) + +// For convenience, this file includes the three different "files" used in this +// test. It selects one with -DCoreDishwasher, -DDishwasherKit, or neither. + +// RUN: %target-swift-frontend -emit-module %s -DCoreDishwasher -module-name CoreDishwasher -o %t/CoreDishwasher -emit-module-path %t/CoreDishwasher.swiftmodule -I %t +// 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 +// RUN: %target-swift-frontend -emit-silgen -I %t %s + +#if CoreDishwasher + + public struct SpimsterWicket { + public init() {} + } + +#elseif DishwasherKit + + @_implementationOnly import CoreDishwasher + + open class Dishwasher { + public init() {} + + var wicket = SpimsterWicket() + + open var modelName: String { "Dishwasher" } + } + +#else + + import DishwasherKit + + open class FancyDishwasher: Dishwasher { + open override var modelName: String { "Fancy \(super.modelName)" } + } + +#endif