Skip to content

Commit f466aeb

Browse files
committed
Sema: Don't call bindExtension() in inferTypeWitnessesViaValueWitnesses()
Instead, call validateExtension(), but only after we've already ruled out the non-protocol extension case, because we can do that by using getExtendedNominal().
1 parent 7eed6c4 commit f466aeb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,19 @@ AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(
183183
if (extension == conformanceExtension)
184184
return true;
185185

186-
tc.bindExtension(extension);
186+
auto *extendedNominal = extension->getExtendedNominal();
187+
188+
// Invalid case.
189+
if (extendedNominal == nullptr)
190+
return true;
187191

188192
// Assume unconstrained concrete extensions we found witnesses in are
189193
// always viable.
190-
if (!extension->getExtendedType()->isAnyExistentialType()) {
191-
// TODO: When constrained extensions are a thing, we'll need an "is
192-
// as specialized as" kind of check here.
194+
if (!isa<ProtocolDecl>(extendedNominal))
193195
return !extension->isConstrainedExtension();
194-
}
196+
197+
// Build a generic signature.
198+
tc.validateExtension(extension);
195199

196200
// The extension may not have a generic signature set up yet, as a
197201
// recursion breaker, in which case we can't yet confidently reject its

0 commit comments

Comments
 (0)