It's applicable to all enclosing types, not just the direct one:
Here's an example of using self
in a type context. You currently have the idea that this is "as if it were an instance property", but that's not the case. self
just means something different here, than it does in an instance member. And nobody ever uses it explicitly.
extension Struct1 {
static var staticComputedProperty: String { self.staticLetProperty }
}
Struct1
static members will trickle down to ChildClass
, but only in the definition. If you use extensions, you'll need to qualify where the static member is coming from. I consider the inconsistency a bug but there may be reasons it has to work that way.
extension Struct1.ChildClass {
func doThing() {
print(Struct1.staticLetProperty)
}
}