Merge pull request #37380 from hborla/property-wrapper-inference-crash

[ConstraintSystem] Fix a constraint system crash with property wrapper inference using the $ syntax.
This commit is contained in:
Holly Borla
2021-05-12 08:55:51 -07:00
committed by GitHub
8 changed files with 46 additions and 17 deletions

View File

@@ -8682,8 +8682,18 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
Type wrappedValueType;
if (paramDecl->hasImplicitPropertyWrapper()) {
backingType = getContextualParamAt(i)->getPlainType();
wrappedValueType = createTypeVariable(getConstraintLocator(locator),
if (auto contextualType = getContextualParamAt(i)) {
backingType = contextualType->getPlainType();
} else {
// There may not be a contextual parameter type if the contextual
// type is not a function type or if closure body declares too many
// parameters.
auto *paramLoc =
getConstraintLocator(closure, LocatorPathElt::TupleElement(i));
backingType = createTypeVariable(paramLoc, TVO_CanBindToHole);
}
wrappedValueType = createTypeVariable(getConstraintLocator(paramDecl),
TVO_CanBindToHole | TVO_CanBindToLValue);
} else {
auto *wrapperAttr = paramDecl->getAttachedPropertyWrappers().front();