Skip to content

Commit 4c4ed53

Browse files
authored
Merge pull request #80367 from xedin/rdar-137825558
[ConstraintSystem] Use `findSelectedOverloadFor` in `isArgumentGeneri…
2 parents 04d3f33 + 62d19c5 commit 4c4ed53

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4984,14 +4984,12 @@ bool ConstraintSystem::isArgumentGenericFunction(Type argType, Expr *argExpr) {
49844984

49854985
// Have we bound an overload for the argument already?
49864986
if (argExpr) {
4987-
auto locator = getConstraintLocator(argExpr);
4988-
auto knownOverloadBinding = ResolvedOverloads.find(locator);
4989-
if (knownOverloadBinding != ResolvedOverloads.end()) {
4987+
if (auto selectedOverload = findSelectedOverloadFor(argExpr)) {
49904988
// If the overload choice is a generic function, then we have a generic
49914989
// function reference.
4992-
auto choice = knownOverloadBinding->second;
4993-
if (auto func = dyn_cast_or_null<AbstractFunctionDecl>(
4994-
choice.choice.getDeclOrNull())) {
4990+
auto choice = selectedOverload->choice;
4991+
if (auto func =
4992+
dyn_cast_or_null<AbstractFunctionDecl>(choice.getDeclOrNull())) {
49954993
if (func->isGeneric())
49964994
return true;
49974995
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 6
2+
3+
// rdar://137825558 - crash due to attempted existential opening
4+
5+
protocol FS {
6+
func exists(_ str: String) -> Bool
7+
}
8+
9+
class Obj {
10+
var property: String = ""
11+
}
12+
13+
func checkFunctionCall<T, Arg0>(
14+
_ lhs: T, calling functionCall: (T, Arg0) throws -> Bool, _ argument0: Arg0
15+
) {
16+
}
17+
18+
func checkFunctionCall<T, Arg0, R>(
19+
_ lhs: T, calling functionCall: (T, Arg0) throws -> R?, _ argument0: Arg0
20+
) {
21+
}
22+
23+
func test(fs: any FS, obj: Obj!) {
24+
checkFunctionCall(fs, calling: { $0.exists($1) }, obj.property)
25+
}

0 commit comments

Comments
 (0)