Fix crash in member lookup when base type contains type variables.

We were crashing during performTypoCorrection if the base type contained
type variables.

rdar://problem/28387684
This commit is contained in:
Mark Lacey
2016-11-02 17:46:03 -07:00
parent 4c96f64b64
commit 18c809d1d4
6 changed files with 19 additions and 12 deletions

View File

@@ -3084,7 +3084,10 @@ bool swift::isExtensionApplied(DeclContext &DC, Type BaseTy,
ConstraintSystemOptions Options;
NominalTypeDecl *Nominal = BaseTy->getNominalOrBoundGenericNominal();
if (!Nominal || !BaseTy->isSpecialized() ||
ED->getGenericRequirements().empty())
ED->getGenericRequirements().empty() ||
// We'll crash if we leak type variables from one constraint
// system into the new one created below.
BaseTy->hasTypeVariable())
return true;
std::unique_ptr<TypeChecker> CreatedTC;
// If the current ast context has no type checker, create one for it.
@@ -3101,11 +3104,6 @@ bool swift::isExtensionApplied(DeclContext &DC, Type BaseTy,
bool Failed = false;
SmallVector<Type, 3> TypeScratch;
// Don't allow type variables from an existing constraint system to
// leak into the new constraint system created below.
assert(!BaseTy->hasTypeVariable() &&
"Unexpected type variable in base type!");
// Prepare type substitution map.
TypeSubstitutionMap Substitutions = BaseTy->getMemberSubstitutions(ED);
auto resolveType = [&](Type Ty) {