mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ConstraintSystem] Downgrade some invalid specialization uses to a warning until Swift 6 language mode
Some invalid specializations were previously allowed by the compiler and we found some existing code that used that (albeit invalid) syntax, so we need to stage that error as a warning until Swift 6 language mode to avoid source compatibility break. Resolves: rdar://134740240
This commit is contained in:
@@ -14069,6 +14069,13 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
|
||||
|
||||
auto genericParams = getGenericParams(decl);
|
||||
if (!decl->getAsGenericContext() || !genericParams) {
|
||||
if (isa<AbstractFunctionDecl>(decl)) {
|
||||
return recordFix(AllowFunctionSpecialization::create(
|
||||
*this, decl, getConstraintLocator(locator)))
|
||||
? SolutionKind::Error
|
||||
: SolutionKind::Solved;
|
||||
}
|
||||
|
||||
// Allow concrete macros to have specializations with just a warning.
|
||||
return recordFix(AllowConcreteTypeSpecialization::create(
|
||||
*this, type1, decl, getConstraintLocator(locator),
|
||||
@@ -14111,10 +14118,7 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
|
||||
// FIXME: We could support explicit function specialization.
|
||||
if (openedGenericParams.empty() ||
|
||||
(isa<AbstractFunctionDecl>(decl) && !hasParameterPack)) {
|
||||
if (!shouldAttemptFixes())
|
||||
return SolutionKind::Error;
|
||||
|
||||
return recordFix(AllowGenericFunctionSpecialization::create(
|
||||
return recordFix(AllowFunctionSpecialization::create(
|
||||
*this, decl, getConstraintLocator(locator)))
|
||||
? SolutionKind::Error
|
||||
: SolutionKind::Solved;
|
||||
@@ -15246,7 +15250,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::AllowAssociatedValueMismatch:
|
||||
case FixKind::GenericArgumentsMismatch:
|
||||
case FixKind::AllowConcreteTypeSpecialization:
|
||||
case FixKind::AllowGenericFunctionSpecialization:
|
||||
case FixKind::AllowFunctionSpecialization:
|
||||
case FixKind::IgnoreGenericSpecializationArityMismatch:
|
||||
case FixKind::IgnoreKeyPathSubscriptIndexMismatch:
|
||||
case FixKind::AllowMemberRefOnExistential: {
|
||||
|
||||
Reference in New Issue
Block a user