Revert "[CS] Don't crash when default argument is magic literal and types don't match"

This commit is contained in:
Suyash Srijan
2019-08-31 00:54:37 +01:00
committed by GitHub
parent dcd0893efe
commit bd53fe355d
10 changed files with 2 additions and 131 deletions

View File

@@ -973,36 +973,9 @@ ConstraintSystem::TypeMatchResult constraints::matchCallArguments(
for (unsigned paramIdx = 0, numParams = parameterBindings.size();
paramIdx != numParams; ++paramIdx){
// If a parameter is unfulfilled, validate the default argument if it is a
// magic literal expression.
if (parameterBindings[paramIdx].empty()) {
if (!callee)
continue;
if (!callee->hasParameterList())
continue;
auto param = getParameterAt(callee, paramIdx);
auto defaultValueExpr = param->getDefaultValue();
if (!(defaultValueExpr &&
isa<MagicIdentifierLiteralExpr>(defaultValueExpr)))
continue;
if (defaultValueExpr->getType())
continue;
cs.generateConstraints(defaultValueExpr, param->getDeclContext());
auto defaultTy = cs.getType(defaultValueExpr);
auto paramTy = param->getType();
cs.addConstraint(
ConstraintKind::ArgumentConversion, defaultTy, paramTy,
locator.withPathElement(ConstraintLocator::DefaultArgument));
// Skip unfulfilled parameters. There's nothing to do for them.
if (parameterBindings[paramIdx].empty())
continue;
}
// Determine the parameter type.
const auto &param = params[paramIdx];
@@ -2628,12 +2601,6 @@ bool ConstraintSystem::repairFailures(
break;
}
case ConstraintLocator::DefaultArgument: {
conversionsOrFixes.push_back(IgnoreDefaultArgumentTypeMismatch::create(
*this, lhs, rhs, getConstraintLocator(anchor, path)));
break;
}
case ConstraintLocator::TypeParameterRequirement:
case ConstraintLocator::ConditionalRequirement: {
// If dependent members are present here it's because
@@ -7482,7 +7449,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
case FixKind::SkipSameTypeRequirement:
case FixKind::SkipSuperclassRequirement:
case FixKind::AddMissingArguments:
case FixKind::DefaultArgumentTypeMismatch:
case FixKind::SkipUnhandledConstructInFunctionBuilder:
case FixKind::UsePropertyWrapper:
case FixKind::UseWrappedValue: {