mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify. New separate fix for allow generic function specialization. Improve parse heuristic for isGenericTypeDisambiguatingToken.
This commit is contained in:
@@ -13926,6 +13926,8 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
|
||||
|
||||
// Bail out if we haven't selected an overload yet.
|
||||
auto simplifiedBoundType = simplifyType(type1, flags);
|
||||
if (simplifiedBoundType->isPlaceholder())
|
||||
return SolutionKind::Solved;
|
||||
if (simplifiedBoundType->isTypeVariableOrMember())
|
||||
return formUnsolved();
|
||||
|
||||
@@ -14018,13 +14020,12 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
|
||||
}
|
||||
}
|
||||
|
||||
if (!decl->getAsGenericContext())
|
||||
return SolutionKind::Error;
|
||||
|
||||
auto genericParams = getGenericParams(decl);
|
||||
if (!genericParams) {
|
||||
// FIXME: Record an error here that we're ignoring the parameters.
|
||||
return SolutionKind::Solved;
|
||||
if (!decl->getAsGenericContext() || !genericParams) {
|
||||
return recordFix(AllowConcreteTypeSpecialization::create(
|
||||
*this, type1, getConstraintLocator(locator)))
|
||||
? SolutionKind::Error
|
||||
: SolutionKind::Solved;
|
||||
}
|
||||
|
||||
// Map the generic parameters we have over to their opened types.
|
||||
@@ -14057,12 +14058,14 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
|
||||
}
|
||||
}
|
||||
|
||||
if (openedGenericParams.empty()) {
|
||||
// FIXME: We could support explicit function specialization.
|
||||
if (openedGenericParams.empty() ||
|
||||
(isa<AbstractFunctionDecl>(decl) && !hasParameterPack)) {
|
||||
if (!shouldAttemptFixes())
|
||||
return SolutionKind::Error;
|
||||
|
||||
return recordFix(AllowConcreteTypeSpecialization::create(
|
||||
*this, type1, getConstraintLocator(locator)))
|
||||
return recordFix(AllowGenericFunctionSpecialization::create(
|
||||
*this, decl, getConstraintLocator(locator)))
|
||||
? SolutionKind::Error
|
||||
: SolutionKind::Solved;
|
||||
}
|
||||
@@ -15193,6 +15196,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::AllowAssociatedValueMismatch:
|
||||
case FixKind::GenericArgumentsMismatch:
|
||||
case FixKind::AllowConcreteTypeSpecialization:
|
||||
case FixKind::AllowGenericFunctionSpecialization:
|
||||
case FixKind::IgnoreGenericSpecializationArityMismatch:
|
||||
case FixKind::IgnoreKeyPathSubscriptIndexMismatch:
|
||||
case FixKind::AllowMemberRefOnExistential: {
|
||||
|
||||
Reference in New Issue
Block a user