MuniekMg
(Tomasz)
1
Hi,
I was trying to experiment with Sendable from SE-0302. It was implemented in swift 5.7 so my thought was that it should be available in the latest Trunk Development Snapshot (March 22, 2022).
I wanted to see those restrictions on Sendables on my own instead of just reading about them:
class MyClass {
}
actor MyActor {
let myClass: MyClass = .init()
func doSomething() {
Task.detached {
self.myClass
}
}
}
For the code above I got a warnings about MyClass not being Sendable type, which is what I was expecting, but when I changed MyActor to be a class instead of an actor warnings disappeared.
So I have two two questions:
-
How do I experiment with the most recent Swift changes?
-
Why did those warnings disappear?
Thanks :)
You're doing the right thing. When you changed actor to class, your code no longer obviously "uses concurrency", which is a notion defined in SE-0337. If you want complete Sendable checking, use the flag -warn-concurrency.
Doug
3 Likes
MuniekMg
(Tomasz)
3
After adding -warn-concurrency everything works as expected!
Thank you :)