I'm not sure if this is a bug in Swift, but I noticed this will compile even if the @globalActor struct is declared as internal:
@globalActor struct CacheActor: GlobalActor {
actor ActorType {}
static var shared: ActorType = ActorType()
}
public protocol Cache {
static var cache: [String: Self] {
get
@CacheActor set
}
}
Obviously this should not compile, because CacheActor
is internal while Cache
is public .
Further, I noticed when running the code that the compiler allows conformances without the requiring writes to cache
to be isolated to CacheActor
.
So.. is this a bug or not?
I'm guessing since this is a static var it's threadsafe anyway so isn't worth worrying about, but just curious nonetheless.