mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "[CS] Don't crash when default argument is magic literal and types don't match"
This commit is contained in:
@@ -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 ¶m = 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: {
|
||||
|
||||
Reference in New Issue
Block a user