Skip to content

Conversation

@gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 26, 2025

We were effectively working around this previously at the SIL level. This caused
us not to obey the semantics of the actual evolution proposal. As an example of
this, in the following, x should not be considered main actor isolated:

nonisolated(nonsending) func useValue<T>(_ t: T) async {}
@MainActor func test() async {
  let x = NS()
  await useValue(x)
  print(x)
}

we should just consider this to be a merge and since useValue does not have any
MainActor isolated parameters, x should not be main actor isolated and we should
not emit an error here.

I also fixed a separate issue where we were allowing for parameters of
nonisolated(nonsending) functions to be passed to @concurrent functions. We
cannot allow for this to happen since the nonisolated(nonsending) parameters
/could/ be actor isolated. Of course, we have lost that static information at
this point so we cannot allow for it. Given that we have the actual dynamic
actor isolation information, we could dynamically allow for the parameters to be
passed... but that is something that is speculative and is definitely outside of
the scope of this patch.

rdar://154139237

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ending of this discussion got omitted

gottesmm added 5 commits July 2, 2025 12:13
…ding) to be an actor isolation crossing point.

We were effectively working around this previously at the SIL level. This caused
us not to obey the semantics of the actual evolution proposal. As an example of
this, in the following, x should not be considered main actor isolated:

```swift
nonisolated(nonsending) func useValue<T>(_ t: T) async {}
@mainactor func test() async {
  let x = NS()
  await useValue(x)
  print(x)
}
```

we should just consider this to be a merge and since useValue does not have any
MainActor isolated parameters, x should not be main actor isolated and we should
not emit an error here.

I also fixed a separate issue where we were allowing for parameters of
nonisolated(nonsending) functions to be passed to @Concurrent functions. We
cannot allow for this to happen since the nonisolated(nonsending) parameters
/could/ be actor isolated. Of course, we have lost that static information at
this point so we cannot allow for it. Given that we have the actual dynamic
actor isolation information, we could dynamically allow for the parameters to be
passed... but that is something that is speculative and is definitely outside of
the scope of this patch.

rdar://154139237
…ault.

Going to update the tests in the next commit. This just makes it easier to
review.
…olationInfo::printActorIsolationForDiagnostics.

I am doing this so that I can change how we emit the diagnostics just for
SendNonSendable depending on if NonisolatedNonsendingByDefault is enabled
without touching the rest of the compiler.

This does not actually change any of the actual output though.
…ss LangOpts.Features so we can change how we print based off of NonisolatedNonsendingByDefault.

We do not actually use this information yet though... This is just to ease
review.
…sending) parameter and adjust printing as appropriate.

Specifically in terms of printing, if NonisolatedNonsendingByDefault is enabled,
we print out things as nonisolated/task-isolated and @concurrent/@Concurrent
task-isolated. If said feature is disabled, we print out things as
nonisolated(nonsending)/nonisolated(nonsending) task-isolated and
nonisolated/task-isolated. This ensures in the default case, diagnostics do not
change and we always print out things to match the expected meaning of
nonisolated depending on the mode.

I also updated the tests as appropriate/added some more tests/added to the
SendNonSendable education notes information about this.
@gottesmm gottesmm force-pushed the pr-b4de2f5d58d852cd3e9e606101e1b0ff42ce6092 branch from 96ab824 to c1bfc32 Compare July 2, 2025 20:24
@gottesmm gottesmm requested review from jckarter and xymus as code owners July 2, 2025 20:24
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 2, 2025

@swift-ci smoke test

@gottesmm gottesmm force-pushed the pr-b4de2f5d58d852cd3e9e606101e1b0ff42ce6092 branch from c1bfc32 to 14634b6 Compare July 2, 2025 20:51
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We should be careful about using StringRef in the diagnostic though, the arguments need to be owned by the ASTContext to make that the diagnostic doesn't outlive the argument.

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 2, 2025

I can fix that real quick. Just rerunning tests locally.

@xedin
Copy link
Contributor

xedin commented Jul 2, 2025

Thank you!

@gottesmm gottesmm force-pushed the pr-b4de2f5d58d852cd3e9e606101e1b0ff42ce6092 branch 2 times, most recently from d61f31e to 0c8b629 Compare July 2, 2025 23:43
…64>.

This makes the code easier to write and also prevents any lifetime issues from a
diagnostic outliving the SmallString due to diagnostic transactions.
@gottesmm gottesmm force-pushed the pr-b4de2f5d58d852cd3e9e606101e1b0ff42ce6092 branch from 0c8b629 to 010fa39 Compare July 2, 2025 23:50
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 2, 2025

@swift-ci smoke test

@gottesmm gottesmm enabled auto-merge July 3, 2025 07:56
@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 3, 2025

Failed in lldb

@gottesmm
Copy link
Contributor Author

gottesmm commented Jul 3, 2025

@swift-ci smoke test macOS platform

@gottesmm gottesmm merged commit 677b897 into swiftlang:main Jul 3, 2025
3 checks passed
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.

4 participants