mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Prevent missing call fix from recording fixes while matching types
We need to be very careful while matching types to test whether a fix is applicable or not to avoid adding extraneous fixes and failing the path early. This is a temporary workaround, the real fix would be to let `matchTypes` to propagate `TMF_ApplyingFixes` down. Resolves: rdar://154010220 Resolves: https://github.com/swiftlang/swift/issues/82397
This commit is contained in:
@@ -5365,6 +5365,11 @@ bool ConstraintSystem::repairFailures(
|
||||
matchKind = ConstraintKind::Conversion;
|
||||
}
|
||||
|
||||
// FIXME: There is currently no easy way to avoid attempting
|
||||
// fixes, matchTypes do not propagate `TMF_ApplyingFix` flag.
|
||||
llvm::SaveAndRestore<ConstraintSystemOptions> options(
|
||||
Options, Options - ConstraintSystemFlags::AllowFixes);
|
||||
|
||||
auto result = matchTypes(resultType, dstType, matchKind,
|
||||
TypeMatchFlags::TMF_ApplyingFix, locator);
|
||||
|
||||
|
||||
@@ -88,3 +88,16 @@ class С_56396 {
|
||||
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '(С_56396) -> Void'}}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/82397
|
||||
func testFunctionAssignsWithOptionals(fn: @escaping () -> () -> Void) {
|
||||
let _: (() -> () -> Void)? = fn
|
||||
let _: (() -> () -> Void)?? = fn
|
||||
|
||||
class Super {}
|
||||
class Sub: Super {}
|
||||
|
||||
let b: () -> () -> Sub = { { return Sub() } }
|
||||
let _: (() -> () -> Super)? = b
|
||||
let _: (() -> () -> Super)?? = b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user