@@ -6600,7 +6600,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
66006600 SmallVector<Type, 4 > toOptionals, ConstraintSystem::TypeMatchOptions flags,
66016601 ConstraintLocatorBuilder locator) {
66026602
6603- if (flags.contains (ConstraintSystem::TypeMatchFlags::TMF_ApplyingFix))
6603+ auto last = locator.last ();
6604+ if (last && last->is <LocatorPathElt::GenericArgument>())
66046605 return nullptr ;
66056606
66066607 // Both types have to be fixed.
@@ -6777,9 +6778,11 @@ ConstraintSystem::simplifyCheckedCastConstraint(
67776778 case CheckedCastKind::ArrayDowncast: {
67786779 auto fromBaseType = *isArrayType (fromType);
67796780 auto toBaseType = *isArrayType (toType);
6780-
6781- auto result = simplifyCheckedCastConstraint (
6782- fromBaseType, toBaseType, subflags | TMF_ApplyingFix, locator);
6781+
6782+ auto elementLocator =
6783+ locator.withPathElement (LocatorPathElt::GenericArgument (0 ));
6784+ auto result = simplifyCheckedCastConstraint (fromBaseType, toBaseType,
6785+ subflags, elementLocator);
67836786 attemptRecordCastFixIfSolved (result);
67846787 return result;
67856788 }
@@ -6791,22 +6794,28 @@ ConstraintSystem::simplifyCheckedCastConstraint(
67916794 Type toKeyType, toValueType;
67926795 std::tie (toKeyType, toValueType) = *isDictionaryType (toType);
67936796
6794- if (simplifyCheckedCastConstraint (fromKeyType, toKeyType,
6795- subflags | TMF_ApplyingFix,
6796- locator) == SolutionKind::Error)
6797+ auto keyLocator =
6798+ locator.withPathElement (LocatorPathElt::GenericArgument (0 ));
6799+ if (simplifyCheckedCastConstraint (fromKeyType, toKeyType, subflags,
6800+ keyLocator) == SolutionKind::Error)
67976801 return SolutionKind::Error;
67986802
6799- auto result = simplifyCheckedCastConstraint (
6800- fromValueType, toValueType, subflags | TMF_ApplyingFix, locator);
6803+ auto valueLocator =
6804+ locator.withPathElement (LocatorPathElt::GenericArgument (1 ));
6805+ auto result = simplifyCheckedCastConstraint (fromValueType, toValueType,
6806+ subflags, valueLocator);
68016807 attemptRecordCastFixIfSolved (result);
68026808 return result;
68036809 }
68046810
68056811 case CheckedCastKind::SetDowncast: {
68066812 auto fromBaseType = *isSetType (fromType);
68076813 auto toBaseType = *isSetType (toType);
6808- auto result = simplifyCheckedCastConstraint (
6809- fromBaseType, toBaseType, subflags | TMF_ApplyingFix, locator);
6814+
6815+ auto elementLocator =
6816+ locator.withPathElement (LocatorPathElt::GenericArgument (0 ));
6817+ auto result = simplifyCheckedCastConstraint (fromBaseType, toBaseType,
6818+ subflags, elementLocator);
68106819 attemptRecordCastFixIfSolved (result);
68116820 return result;
68126821 }
0 commit comments