Skip to content

[CSSimplify] Prevent missing call fix from recording fixes while ma… #82430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions test/Constraints/assignment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}