Merge pull request #30251 from hborla/invalid-optional-chaining

[ConstraintSystem] Don't assume the lhs type is for a generic parameter in simplifyConformsToConstraint.
This commit is contained in:
Holly Borla
2020-03-05 16:45:37 -08:00
committed by GitHub
2 changed files with 13 additions and 5 deletions

View File

@@ -5175,11 +5175,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
// collection type couldn't be determined without unification to
// `Any` and `+` failing for all numeric overloads is just a consequence.
if (typeVar && type->isAny()) {
auto *GP = typeVar->getImpl().getGenericParameter();
if (auto *GPD = GP->getDecl()) {
auto *DC = GPD->getDeclContext();
if (DC->isTypeContext() && DC->getSelfInterfaceType()->isEqual(GP))
return SolutionKind::Error;
if (auto *GP = typeVar->getImpl().getGenericParameter()) {
if (auto *GPD = GP->getDecl()) {
auto *DC = GPD->getDeclContext();
if (DC->isTypeContext() && DC->getSelfInterfaceType()->isEqual(GP))
return SolutionKind::Error;
}
}
}