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 {
12811281 return false ;
12821282 }
12831283
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+
12841299 std::optional<std::pair</* witness=*/ ValueDecl *, GenericTypeParamType *>>
12851300 isForWitnessGenericParameterRequirement () const {
12861301 SmallVector<LocatorPathElt, 2 > path;
Original file line number Diff line number Diff line change @@ -14083,6 +14083,12 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
1408314083 // This induces conversions to occur within closures instead of
1408414084 // outside of them wherever possible.
1408514085 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+
1408614092 increaseScore(SK_FunctionConversion, locator);
1408714093 }
1408814094 };
Original file line number Diff line number Diff line change @@ -1062,4 +1062,11 @@ protocol PackExpansionResult {
10621062func packExpansionResult( p: any PackExpansionResult ) {
10631063 p. foo ( t: 1 , " hi " )
10641064 // 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