Files
swift-mirror/test/Concurrency/concurrency_attr_inference_on_closures.swift
Pavel Yaskevich c8690b34e7 [CSBindings] Don't prioritize closures that are assigned to overloaded members
Constraint generation uses a special pattern while generating
constraints for assignments to make sure that the source type
is convertible to r-value type of the destination.

`BindingSet::favoredOverDisjunction` needs to recognize this
pattern, where disjunction type variable is bound early, and
avoid prioritizing closure if it's connected to the "fixed type"
of the disjunction or risk losing annotations associated with
the member such as `@Sendable` or a global actor.

Resolves: rdar://131524246
2024-08-27 16:19:29 -07:00

23 lines
494 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5
// RUN: %target-typecheck-verify-swift -swift-version 5 -strict-concurrency=complete
// RUN: %target-typecheck-verify-swift -swift-version 6
// rdar://131524246
protocol P: Sendable {
typealias Block = @Sendable () -> Void
var block: Block? { get }
}
extension P {
var block: Block? { nil }
}
final class Impl: P, @unchecked Sendable {
var block: Block?
}
func test(_ v: Impl) {
v.block = {} // Ok, no warnings or errors
}