Avatar
Avatar
417_72ki
@swift-6.0.3 -swift-version 6 enum Foo { @MainActor private(set) static var bar = "" } extension Foo { @MainActor static func setup(bar: String) { Self.bar = bar } } func foo() { print(Foo.bar) } foo() (edited)
exit status: 1 with <stdin>:12:15: error: main actor-isolated static property 'bar' can not be referenced from a nonisolated context 1 | enum Foo { 2 | @MainActor private(set) static var bar = "" | `- note: static property declared here 3 | } 4 | : 9 | } 10 | 11 | func foo() { | `- note: add '@MainActor' to make global function 'foo()' part of global actor 'MainActor' 12 | print(Foo.bar) | `- error: main actor-isolated static property 'bar' can not be referenced from a nonisolated context 13 | } 14 | (edited)