You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Totally reasonable as long as it's a read-only property. I'm not quite going to tag this as a starter bug because I'm not sure what all the moving pieces would be, but I don't think it would be too hard.
if the subclass B had properties (e.g. var foo: Int = 0) and B().copy() instantiates parent A, which doesn't have foo property and only casts it to B, how come code doesn't crash on runtime when you do e.g. B().copy().foo = 5?
funccopy() -> Self {
letcopy = Self.init() // When call B().copy(), this is let copy = B.init(), so it can cast to B.print(type(of: copy)) // When call B().copy(), the type of copy is B not A.returncopy
}
Right, the required in the declaration of the init means it can be invoked on the dynamic type. If you just said A.init(), you'd get an error message about not returning the right type.
Environment
Swift Development Snapshot 2019-03-17
Additional Detail from JIRA
md5: e8e72fa6406e42baa338fec2b7c90afe
Issue Description:
The text was updated successfully, but these errors were encountered: