Skip to content

[SE-0313] isolated parameters ABI #37944

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

Merged
merged 8 commits into from
Jun 16, 2021

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Jun 16, 2021

Explanation: Implements the core type checker, runtime, and ABI aspects of isolated parameters for SE-0313, so we can lock in the mangling and runtime representation for this feature.
Scope: Affects the modeling of actors in the type system, but should not change the semantics.
Radar/SR Issue: rdar://75389492
Risk: Low.
Testing: PR testing and CI on main.
Original PR: #37794

…ated'.

The notion of "actor-isolated" currently exists at the declaration level.
For functions, it is going to be captured in the function type itself,
where 'self' is declared to be 'isolated'. Model isolation both
ways: the 'self' of a method that is isolated to an actor instance
will be 'isolated' as well.

We are still using declaration-based checking of actor isolation.
However, by mirroring this information we can move more incrementally
over to doing checking based on 'isolated' parameters.

(cherry picked from commit 5004a54)
With isolated parameters being part of a function's type, check to
ensure that isolated and non-isolated parameters aren't incorrectly
matched. Specifically, it is okay to add `isolated` to a parameter
when there is a subtyping relationship, but not remove it:

```swift
actor A { }
func f(_: isolated A) { }
func g(_: A) { }

func test() {
  let _: (isolated A) -> Void = g    // okay to add 'isolated'
  let _: (A) -> Void = f             // error when removing 'isolated'
}
```

(cherry picked from commit 4afa371)
…ers.

Isolated parameters are part of function types. Encode them in function
type manglings and metadata, and ensure that they round-trip through
the various mangling and metadata facilities. This nails down the ABI
for isolated parameters.

(cherry picked from commit 58f4969)
Rework the checking of actor member access to rely on "isolated" parameters
(and captures thereof) to determine whether one can synchronously access
an actor or not. This allows synchronous access via an "isolated" parameter
as a general notion, which subsumes the declaration-based "self" access.

Simplify the checking of and diagnostic reporting for actor member
access by collapsing a number of redundant diagnostics down into a
single, parameterized diagnostic with a single point of emission. This
normalizes the logic a bit.

(cherry picked from commit 5bcd5a8)
Fixes a regression I introduced recently, rdar://79200626.

(cherry picked from commit caf843f)
@DougGregor DougGregor requested a review from a team as a code owner June 16, 2021 06:16
@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0e1638d

@DougGregor
Copy link
Member Author

Grrr. Unrelated failure on Linux

@DougGregor
Copy link
Member Author

@swift-ci please test Linux

@DougGregor
Copy link
Member Author

@swift-ci please nominate

@DougGregor DougGregor merged commit a2def15 into swiftlang:release/5.5 Jun 16, 2021
@DougGregor DougGregor deleted the isolated-parameters-abi branch June 16, 2021 21:51
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.

3 participants