-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeChecker/SILGen] Allow any Sendable
to match Any
while matching generic arguments
#78171
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
Conversation
…ndable` Prevent generic arguments from being assigned `any Sendable` directly, that should only happen through inference. This is required because we allow `any Sendable` -> `Any` conversion in modes without strict concurrency enabled to maintain source compatibility and let the developers annotate existing APIs with `any Sendable` and other concurrency attributes.
…ic arguments Allow `any Sendable` to match `Any` constraint while matching generic arguments i.e. `[any Sendable]` -> `[Any]` when `any Sendable` type comes from context that involves `@preconcurrency` declarations in non-strict concurrency compiler mode. Note that it's currently impossible to figure out precisely where `any Sendable` type came from.
`UnsafeCastExpr` - A special kind of conversion that performs an unsafe bitcast from one type to the other. Note that this is an unsafe operation and type-checker is allowed to use this only in a limited number of cases like: `any Sendable` -> `Any` conversions in some positions, covariant conversions of function and function result types.
…c arguments In non-strict concurrency mode when `@preconcurrency` declarations are involved `any Sendable` should be treated as `Any` in generic argument positions to support passing types that (partially) adopted concurrency annotations to types that haven't yet done so.
…ith ManagedValue
Forwarding cast handles ownership correctly and doesn't disable optimizations unlike bitcast.
…ainst marker protocol This indicates that the type doesn't have appropriate annotations i.e. for concurrency or ownership.
…of generic arguments Conversion restrictions like "deep equality" could produce a more narrow/actionable fixes.
…e same This helps to avoid spurious failures pointing to involved pattern types because they won't match exactly if shape types are not the same.
…ion in non-strict concurrency contexts
We can use |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SILGenBuilder::createUncheckedForwardingCast
LGTM
@swift-ci please test |
cbcb24f
to
20a5a51
Compare
@swift-ci please test |
…ction argument/result positions in generic argument context
20a5a51
to
0de9e9c
Compare
@swift-ci please test |
@swift-ci please test source compatibility debug |
@swift-ci please test macOS platform |
…l language modes
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please smoke test macOS platform |
Allow
any Sendable
to matchAny
constraint while matchinggeneric arguments i.e.
[any Sendable]
->[Any]
whenany Sendable
type comes from context that involves
@preconcurrency
declarations.To facilitate that we need a new expression that models an unsafe bitcast
from one type to the other -
UnsafeCastExpr
. This expression is goingto be introduced by the solver during solution application phase to
erase
any Sendable
toAny
in generic argument positions.Resolves: rdar://140300022