Skip to content
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
}