Perhaps I'm being extremely dense, and I realize I'm supposed to know about this sort of thing, but I was taken by surprise by this:
class Wrapper<T> {
let value: T
var wrapper: Wrapper? // ok
init(value: T) {
self.value = value
}
}
class Thing {
var wrapper: Wrapper? // error
}
The error is that inside class Thing I have to resolve the Wrapper generic when I declare the type; I need to say, for instance,
var wrapper: Wrapper<String>?
Why is legal to declare that a property has type Wrapper plain and simple inside a Wrapper but not elsewhere? What makes the declaration inside Wrapper okay? Is it because the compiler just assumes that inside Wrapper, Wrapper means Wrapper<T>?