Skip to content

Commit b147032

Browse files
authored
Merge pull request #82430 from xedin/issue-82397
[CSSimplify] Prevent `missing call` fix from recording fixes while ma…
2 parents 2066826 + 7ecb1fd commit b147032

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,6 +5365,11 @@ bool ConstraintSystem::repairFailures(
53655365
matchKind = ConstraintKind::Conversion;
53665366
}
53675367

5368+
// FIXME: There is currently no easy way to avoid attempting
5369+
// fixes, matchTypes do not propagate `TMF_ApplyingFix` flag.
5370+
llvm::SaveAndRestore<ConstraintSystemOptions> options(
5371+
Options, Options - ConstraintSystemFlags::AllowFixes);
5372+
53685373
auto result = matchTypes(resultType, dstType, matchKind,
53695374
TypeMatchFlags::TMF_ApplyingFix, locator);
53705375

test/Constraints/assignment.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,16 @@ class С_56396 {
8888
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '(С_56396) -> Void'}}
8989
}
9090
}
91+
92+
// https://github.com/swiftlang/swift/issues/82397
93+
func testFunctionAssignsWithOptionals(fn: @escaping () -> () -> Void) {
94+
let _: (() -> () -> Void)? = fn
95+
let _: (() -> () -> Void)?? = fn
96+
97+
class Super {}
98+
class Sub: Super {}
99+
100+
let b: () -> () -> Sub = { { return Sub() } }
101+
let _: (() -> () -> Super)? = b
102+
let _: (() -> () -> Super)?? = b
103+
}

0 commit comments

Comments
 (0)