mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CS] Avoid solver-allocated inputs with typesSatisfyConstraint
Escaping solver-allocated types into a nested allocation arena is problematic since we can e.g lazily compute the `ContextSubMap` for a `NominalOrBoundGenericNominalType`, which is then destroyed when we exit the nested arena. Ensure we don't pass any types with type variables or placeholders to `typesSatisfyConstraint`. rdar://152763265
This commit is contained in:
@@ -4903,8 +4903,12 @@ static bool
|
||||
repairViaBridgingCast(ConstraintSystem &cs, Type fromType, Type toType,
|
||||
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
|
||||
ConstraintLocatorBuilder locator) {
|
||||
if (fromType->hasTypeVariable() || toType->hasTypeVariable())
|
||||
// Don't check if any of the types have type variables or placeholders,
|
||||
// `typeCheckCheckedCast` doesn't support checking solver-allocated types.
|
||||
if (fromType->hasTypeVariableOrPlaceholder() ||
|
||||
toType->hasTypeVariableOrPlaceholder()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto objectType1 = fromType->getOptionalObjectType();
|
||||
auto objectType2 = toType->getOptionalObjectType();
|
||||
@@ -9366,10 +9370,12 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
|
||||
if (locator.endsWith<LocatorPathElt::GenericArgument>())
|
||||
return nullptr;
|
||||
|
||||
// Both types have to be fixed.
|
||||
if (fromType->hasTypeVariable() || toType->hasTypeVariable() ||
|
||||
fromType->hasPlaceholder() || toType->hasPlaceholder())
|
||||
// Both types have to be resolved, `typeCheckCheckedCast` doesn't support
|
||||
// checking solver-allocated types.
|
||||
if (fromType->hasTypeVariableOrPlaceholder() ||
|
||||
toType->hasTypeVariableOrPlaceholder()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SmallVector<LocatorPathElt, 4> path;
|
||||
auto anchor = locator.getLocatorParts(path);
|
||||
|
||||
Reference in New Issue
Block a user