Skip to content

Commit b7a68b0

Browse files
authored
Merge pull request #83489 from xedin/rdar-157234317
[CSOptimizer] Fix a conditional that ignores function type parameters…
2 parents 61d60eb + 9588d51 commit b7a68b0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ static void determineBestChoicesInContext(
15981598
// FIXME: Let's skip matching function types for now
15991599
// because they have special rules for e.g. Concurrency
16001600
// (around @Sendable) and @convention(c).
1601-
if (paramType->is<FunctionType>())
1601+
if (paramType->lookThroughAllOptionalTypes()->is<FunctionType>())
16021602
continue;
16031603

16041604
// The idea here is to match the parameter type against

test/SILOptimizer/infinite_recursion.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,11 @@ func recursionMatchingTypeArgs2<T: P, V: P>(_ t: T.Type, _ v: V.Type) {
352352
recursionMatchingTypeArgs2(T.self, V.self) // expected-warning {{function call causes an infinite recursion}}
353353
}
354354

355+
func testNoInfiniteRecursionWithOverloadingOnOptional() {
356+
func test(handler: @escaping (Bool) -> Void) {
357+
}
358+
359+
func test(handler: ((Bool) -> Void)?) {
360+
test(handler: handler ?? { _ in }) // Ok
361+
}
362+
}

0 commit comments

Comments
 (0)