Open m1entus opened 2 years ago
Reduced:
public struct Home {}
public actor MyActor {
private var home: Home {
get { Home() }
set { }
}
public init(home: Home) {
self.home = home
}
}
Reduced:
public struct Home {} public actor MyActor { private var home: Home { get { Home() } set { } } public init(home: Home) { self.home = home } }
???
It’s a smaller version of the code that triggers the same warning. It’s nothing to do with property wrappers specifically, but with using a computed property.
Aaa okay make sense now - thanks for explanation.
Found out that this workaround works for me (instead of using computed property i use reference to propertyWrapper):
public actor MyActor {
@MyPropertyWrapper
private var home: Home
public init(home: Home) {
_home = MyPropertyWrapper<Home>(wrappedValue: home)
}
}
You need to make sure home is a published property
@Published var home: Home? = nil
Describe the bug Compiler shows warnings about can not be mutated from a non-isolated context in Xcode 14.0 when assigning value when using custom
@propertyWrapper
.Steps To Reproduce
as a workaround it is possible to use
MyPropertyWrapper<Home>
and then warning dissapears.Expected behavior There should not be warning about
Actor-isolated property 'home' can not be mutated from a non-isolated context
when using@MyPropertyWrapper
Warning not appear in Xcode 13.4.0.Screenshots
Environment (please fill out the following information)
Additional context Add any other context about the problem here.