Files
swift-mirror/test/Concurrency/file_default_isolation_errors.swift
Aviva Ruben 019ddea691 Implement file-level isolation default
Leans on the previous refactor to apply file-level default isolation
via isolation inference. Follows the 'final' version of 478, so top
level globals are included in file-level default isolation. Adds
`effectivelyExplicit` method, to be used instead of checking for the
Explicit enum value directly, since a file-level default isolation
should be treated as effectively default for free un/adopt (the
non-explicit form would be unintuitive to express without the module
feature flag). This commit will diagnose @available or @diagnose until
the next commit...

Note that computeActorIsolation needs to be updated to accept isolation
on file-scope global stored properties, the old check was too broad,
and in (i think?) trying to reject isolation on computed properties of
types, also rejected it on top-level code.
2026-06-22 13:31:20 -07:00

21 lines
782 B
Swift

// RUN: %target-swift-frontend -enable-experimental-feature DefaultIsolationPerFile -typecheck -swift-version 6 -parse-as-library -verify %s
// REQUIRES: concurrency
// REQUIRES: swift_feature_DefaultIsolationPerFile
using nonisolated
// implicitly Sendable
@MainActor class Base {}
final class FinalSub: Base {}
// TODO: diagnostic would ideally provide more information in these cases...
// implicitly nonisolated
class Sub: Base {} // expected-error {{non-final class 'Sub' cannot conform to the 'Sendable' protocol}}
// implicitly nonisolated
// nonisolated subclass can't inherit Sendable from @MainActor even with @unchecked
class UncheckedSub: Base, @unchecked Sendable {} // expected-error {{non-final class 'UncheckedSub' cannot conform to the 'Sendable' protocol}}