Skip to content

Commit e110221

Browse files
committed
SILGen: Ignore placeholders and missing methods during conformance emission.
Builds on #72286. Use a more forgiving strategy when handling potentially invalid conformances during SILGen. Conformances may be erroneously marked invalid during witness resolution, even when they can still be successfully emitted, so we can't bail out of witness table emission if the invalid bit is set. Instead, just ignore placeholders and missing methods in the witness table emitter and trust that if an error was diagnosed during resolution that compilation will be aborted. Resolves rdar://125947349
1 parent 9c4adb7 commit e110221

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,7 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
554554
PrettyStackTraceConformance trace("generating SIL witness table",
555555
Conformance);
556556

557-
// Check whether the conformance is valid first.
558557
Conformance->resolveValueWitnesses();
559-
if (Conformance->isInvalid())
560-
return nullptr;
561-
562558
auto *proto = Conformance->getProtocol();
563559
visitProtocolDecl(proto);
564560

@@ -619,13 +615,12 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
619615
return Conformance->getWitness(decl);
620616
}
621617

622-
void addPlaceholder(MissingMemberDecl *placeholder) {
623-
llvm_unreachable("generating a witness table with placeholders in it");
624-
}
625-
626-
void addMissingMethod(SILDeclRef requirement) {
627-
llvm_unreachable("generating a witness table with placeholders in it");
628-
}
618+
// Treat placeholders and missing methods as no-ops. These may be encountered
619+
// during lazy typechecking when SILGen triggers witness resolution and
620+
// discovers and invalid conformance. The diagnostics emitted during witness
621+
// resolution should cause compilation to fail.
622+
void addPlaceholder(MissingMemberDecl *placeholder) {}
623+
void addMissingMethod(SILDeclRef requirement) {}
629624

630625
void addMethodImplementation(SILDeclRef requirementRef,
631626
SILDeclRef witnessRef,

0 commit comments

Comments
 (0)