Skip to content

Conversation

@gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jul 7, 2025

The reason why this failed is that concurrently to @xedin landing
79af04c, I enabled
NonisolatedNonsendingByDefault on a bunch of other tests. That change broke the
test and so we needed to fix it.

This commit fixes a few issues that were exposed:

  1. We do not propagate nonisolated(nonsending) into a closure if its inferred
    context isolation is global actor isolated or if the closure captures an
    isolated parameter. We previously just always inferred
    nonisolated(nonsending). Unfortunately since we do not yet have capture
    information in CSApply, this required us to put the isolation change into
    TypeCheckConcurrency.cpp and basically have function conversions of the form:
(function_conversion_expr type="nonisolated(nonsending) () async -> Void"
   (closure_expr type="() async -> ()" isolated_to_caller_isolation))

Notice how we have a function conversion to nonisolated(nonsending) from a
closure expr that has an isolation that is isolated_to_caller.

  1. With this in hand, we found that this pattern caused us to first thunk a
    nonisolated(nonsending) function to an @Concurrent function and then thunk that
    back to nonisolated(nonsending), causing the final function to always be
    concurrent. I put into SILGen a peephole that recognizes this pattern and emits
    the correct code.

  2. With that in hand, we found that we were emitting nonisolated(nonsending)
    parameters for inheritActorContext functions. This was then fixed by @xedin in

With all this in hand, closure literal isolation and all of the other RBI tests
with nonisolated(nonsending) enabled pass.

rdar://154969621

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 7, 2025

@swift-ci smoke test

xedin and others added 2 commits July 7, 2025 17:21
…nt` on `@_inheritActorContext` parameters

`@_inheritActorContext` is a form of isolation which precludes
direct use of inference of `nonisolated(nonsending)` and `@concurrent`
just like other isolation attributes/modifiers would i.e. `isolated`
or `@isolated(any)`.
…iterals_isolationinference.swift now passes.

The reason why this failed is that concurrently to @xedin landing
79af04c, I enabled
NonisolatedNonsendingByDefault on a bunch of other tests. That change broke the
test and so we needed to fix it.

This commit fixes a few issues that were exposed:

1. We do not propagate nonisolated(nonsending) into a closure if its inferred
context isolation is global actor isolated or if the closure captures an
isolated parameter. We previously just always inferred
nonisolated(nonsending). Unfortunately since we do not yet have capture
information in CSApply, this required us to put the isolation change into
TypeCheckConcurrency.cpp and basically have function conversions of the form:

```
(function_conversion_expr type="nonisolated(nonsending) () async -> Void"
   (closure_expr type="() async -> ()" isolated_to_caller_isolation))
```

Notice how we have a function conversion to nonisolated(nonsending) from a
closure expr that has an isolation that is isolated_to_caller.

2. With this in hand, we found that this pattern caused us to first thunk a
nonisolated(nonsending) function to an @Concurrent function and then thunk that
back to nonisolated(nonsending), causing the final function to always be
concurrent. I put into SILGen a peephole that recognizes this pattern and emits
the correct code.

3. With that in hand, we found that we were emitting nonisolated(nonsending)
parameters for inheritActorContext functions. This was then fixed by @xedin in

With all this in hand, closure literal isolation and all of the other RBI tests
with nonisolated(nonsending) enabled pass.

rdar://154969621
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 8, 2025

@swift-ci smoke test

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.

2 participants