@@ -6600,7 +6600,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6600
6600
SmallVector<Type, 4 > toOptionals, ConstraintSystem::TypeMatchOptions flags,
6601
6601
ConstraintLocatorBuilder locator) {
6602
6602
6603
- if (flags.contains (ConstraintSystem::TypeMatchFlags::TMF_ApplyingFix))
6603
+ auto last = locator.last ();
6604
+ if (last && last->is <LocatorPathElt::GenericArgument>())
6604
6605
return nullptr ;
6605
6606
6606
6607
// Both types have to be fixed.
@@ -6777,9 +6778,11 @@ ConstraintSystem::simplifyCheckedCastConstraint(
6777
6778
case CheckedCastKind::ArrayDowncast: {
6778
6779
auto fromBaseType = *isArrayType (fromType);
6779
6780
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);
6783
6786
attemptRecordCastFixIfSolved (result);
6784
6787
return result;
6785
6788
}
@@ -6791,22 +6794,28 @@ ConstraintSystem::simplifyCheckedCastConstraint(
6791
6794
Type toKeyType, toValueType;
6792
6795
std::tie (toKeyType, toValueType) = *isDictionaryType (toType);
6793
6796
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)
6797
6801
return SolutionKind::Error;
6798
6802
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);
6801
6807
attemptRecordCastFixIfSolved (result);
6802
6808
return result;
6803
6809
}
6804
6810
6805
6811
case CheckedCastKind::SetDowncast: {
6806
6812
auto fromBaseType = *isSetType (fromType);
6807
6813
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);
6810
6819
attemptRecordCastFixIfSolved (result);
6811
6820
return result;
6812
6821
}
0 commit comments