Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Dec 11, 2025

If the type variable prefers subtypes, diasambiguate a situation
when this type variable is simultaneously a supertype of @Sendable
function type and a subtype of a non-Sendable one by using a supertype
binding because it constitutes a "subtype" in this case.

For example:

@Sendable () -> Void conv $T
$T argument conv () -> Void

Either of the types could also be wrapped in a number of optionals. Even if
there is an optionality mismatch, let's still prefer a supertype binding
because that would be easier to diagnose.

In particular, this is helpful with ternary operators where the context is
non-Sendable, but one or both sides are.

Resolves: rdar://125948508
Resolves: rdar://136315240

…sertion methods

New `introduceBinding` method encapsulates all the checking and
calls `addBinding` variants to actually insert the binding into
the set when required.
…dings

If the type variable prefers subtypes, diasambiguate a situation
when this type variable is simultaneously a supertype of `@Sendable`
function type and a subtype of a non-Sendable one by using a supertype
binding because it constitutes a "subtype" in this case.

For example:

```
@sendable () -> Void conv $T
$T argument conv () -> Void
```

Either of the types could also be wrapped in a number of optionals. Even if
there is an optionality mismatch, let's still prefer a supertype binding
because that would be easier to diagnose.

In particular, this is helpful with ternary operators where the context is
non-Sendable, but one or both sides are.

Resolves: rdar://125948508
Resolves: rdar://136315240
@xedin xedin requested a review from slavapestov December 11, 2025 19:23
@xedin xedin requested review from hborla and ktoso as code owners December 11, 2025 19:23
@xedin
Copy link
Contributor Author

xedin commented Dec 11, 2025

@swift-ci please test source compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant