From d136a8e528547d4791a643429276f8f04342d4c7 Mon Sep 17 00:00:00 2001 From: Greg Titus Date: Fri, 2 Aug 2024 15:58:35 -0700 Subject: [PATCH] Avoid getCalleeLocator() with inner call that is still variable type. --- lib/Sema/CSSimplify.cpp | 15 +++++++++------ test/Sema/diag_ambiguous_overloads.swift | 9 +++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 318bf82a9d5bd..3bfea7268ecbd 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -2080,13 +2080,16 @@ ConstraintSystem::matchFunctionResultTypes(Type expectedResult, Type fnResult, auto anchor = locator.getAnchor(); if (auto *callExpr = getAsExpr(anchor)) { if (auto *innerCall = getAsExpr(callExpr->getSemanticFn())) { - auto *innerCalleeLoc = + if (!simplifyType(getType(innerCall->getFn())) + ->is()) { + auto *innerCalleeLoc = getCalleeLocator(getConstraintLocator(innerCall)); - if (auto innerOverload = findSelectedOverloadFor(innerCalleeLoc)) { - auto choice = innerOverload->choice; - if (choice.getFunctionRefKind() == FunctionRefKind::DoubleApply) { - isSecondApply = true; - selected.emplace(*innerOverload); + if (auto innerOverload = findSelectedOverloadFor(innerCalleeLoc)) { + auto choice = innerOverload->choice; + if (choice.getFunctionRefKind() == FunctionRefKind::DoubleApply) { + isSecondApply = true; + selected.emplace(*innerOverload); + } } } } diff --git a/test/Sema/diag_ambiguous_overloads.swift b/test/Sema/diag_ambiguous_overloads.swift index bf8f13cb8e784..5ad8973d938cb 100644 --- a/test/Sema/diag_ambiguous_overloads.swift +++ b/test/Sema/diag_ambiguous_overloads.swift @@ -189,3 +189,12 @@ do { let _ = i16 -- i16 // expected-error@-1 {{ambiguous use of operator '--'}} } + +struct Issue75623 { + func f(p: String) {} + func f(_: Int) -> (Int) -> Void {} + + func g() { + f(0)(0) // was hitting assertion + } +}