Files
Aviva Ruben 7bfcc672a9 [Concurrency] Remove prohibition on actors conforming to isolated protocols
We can allow actors conforming to isolated protocols if we prevent
inferring the isolation of the protocol onto the actor. This leads to
some small source breaks (as far as I know).

This will stop compiling in `-default-isolation MainActor`:

```swift
@MainActor func mainActorFn() {}

protocol P {}

actor A: P {
	static func s() { mainActorFn() }
  // ^ now nonisolated, can't call @MainActor
}
```

This will stop compiling in Swift 5 without
`DisableOutwardActorInference`:

```swift
@MainActor func mainActorFn() {}

@propertyWrapper public struct W<T: Sendable> {
	@MainActor public var wrappedValue: T
	public init(wrappedValue: T) { self.wrappedValue = wrappedValue }
}

actor A {
	@W var x: Int = 0
	static func s() { mainActorFn() }
  // ^ now nonisolated, can't call @MainActor
}
```

There may be other cases relying on inferring a global actor onto an
actor that will be broken by this change... but they are (probably)
extremely incorrect, we reject the global actor annotation on an actor
in a `.swiftinterface` during typechecking. We should not accept code
that we later reject when typechecking the interface. Added an assertion
that we don't do this.

Allowing these conformances when it is safe makes actors more useful.
I suspect most practical uses are for async requirements, which can hop
isolations if they don't transfer non-Sendable state.

I'm not sure if lifting this restriction means we should allow
`nonisolated init` on actors, to allow them to avoid inits isolated to
a global actor (a `nonisolated init` can witness `@MainActor init`). We
already accept this code and infer an isolation for the actor init:

```swift
protocol P { @MainActor init() }
actor A: P {}
```

Preventing init off MainActor:

```swift
nonisolated func noniso() {
	A() // error!
}
```

And we don't allow preventing that isolation with `nonisolated`.
Separate issue I guess.

Resolves rdar://183069416
Resolves #90927
2026-08-04 10:20:23 -07:00

4.5 KiB