File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1281,6 +1281,21 @@ class ConstraintLocatorBuilder {
1281
1281
return false ;
1282
1282
}
1283
1283
1284
+ bool isForExistentialMemberAccessConversion () const {
1285
+ for (auto prev = this ; prev;
1286
+ prev = prev->previous .dyn_cast <ConstraintLocatorBuilder *>()) {
1287
+ if (auto elt = prev->element ) {
1288
+ if (elt->is <LocatorPathElt::ExistentialMemberAccessConversion>())
1289
+ return true ;
1290
+ }
1291
+
1292
+ if (auto locator = prev->previous .dyn_cast <ConstraintLocator *>())
1293
+ return bool (locator->findLast <
1294
+ LocatorPathElt::ExistentialMemberAccessConversion>());
1295
+ }
1296
+ return false ;
1297
+ }
1298
+
1284
1299
std::optional<std::pair</* witness=*/ ValueDecl *, GenericTypeParamType *>>
1285
1300
isForWitnessGenericParameterRequirement () const {
1286
1301
SmallVector<LocatorPathElt, 2 > path;
Original file line number Diff line number Diff line change @@ -14083,6 +14083,12 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
14083
14083
// This induces conversions to occur within closures instead of
14084
14084
// outside of them wherever possible.
14085
14085
if (locator.isFunctionConversion()) {
14086
+ // This conversion exists only to check adjustments in the member
14087
+ // type, so the fact that adjustments also cause a function conversion
14088
+ // is unrelated.
14089
+ if (locator.isForExistentialMemberAccessConversion())
14090
+ return;
14091
+
14086
14092
increaseScore(SK_FunctionConversion, locator);
14087
14093
}
14088
14094
};
Original file line number Diff line number Diff line change @@ -1062,4 +1062,11 @@ protocol PackExpansionResult {
1062
1062
func packExpansionResult( p: any PackExpansionResult ) {
1063
1063
p. foo ( t: 1 , " hi " )
1064
1064
// expected-error@-1 {{member 'foo' cannot be used on value of type 'any PackExpansionResult'; consider using a generic constraint instead}}
1065
- }
1065
+ }
1066
+
1067
+ // rdar://135974645 - invalid error: heterogeneous collection literal could only be inferred to '[Any]'
1068
+ extension StringProtocol {
1069
+ func test( target: any StringProtocol , idx: Int ) {
1070
+ let _ = [ target. prefix ( idx) , target. suffix ( idx) ] // Ok
1071
+ }
1072
+ }
You can’t perform that action at this time.
0 commit comments