this compiles:
actor A
{
init() {}
}
extension A
{
nonisolated
func f() async
{
await { (self:isolated A) in } (self)
}
}
yet this does not:
actor A
{
init() {}
}
extension A
{
nonisolated
func f() async
{
- await { (self:isolated A) in } (self)
+ await { (self:isolated Self) in } (self)
}
}
error: 'isolated' parameter has non-actor type 'Self'
why?
1 Like
ktoso
(Konrad 'ktoso' Malawski ππ΄ββ οΈ)
2
The Distributed module actually uses such code so I'm surprised this is failing for you.
It is also not reproducing on main in the Swift repo -- nor in the Xcode I had at hand.
Where exactly is this failing (versions)?
iβm using the latest swift (5.9.2)
$ swiftc test.swift
test.swift:10:23: error: 'isolated' parameter has non-actor type 'Self'
await { (self:isolated Self) in } (self)
^
error: fatalError
$ swiftc --version
Swift version 5.9.2 (swift-5.9.2-RELEASE)
Target: x86_64-unknown-linux-gnu
iβm not using XCode, iβm using VSCode, but i doubt this is related to the IDE. i get the same error when i try it on godbolt.
ktoso
(Konrad 'ktoso' Malawski ππ΄ββ οΈ)
4
Okey managed to reproduce, I wonder why I didn't last evening.
Worth filing a bug imho, would you mind? GitHub - apple/swift: The Swift Programming Language
ktoso
(Konrad 'ktoso' Malawski ππ΄ββ οΈ)
6
2 Likes
wow, that was fast! thanks!
1 Like
ktoso
(Konrad 'ktoso' Malawski ππ΄ββ οΈ)
8
Yep, thanks.
Sadly it turns out nothing is ever that simple, and here's a follow up about handling self properly: [Concurrency] isolated fixes; ban Array<T> and handle Self in actor by ktoso Β· Pull Request #70955 Β· apple/swift Β· GitHub
Making it just workβ’ always would require an evolution proposal it seems.
1 Like