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
swift-ci opened this issue
Oct 30, 2019
· 4 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
I originally thought that adding final to C should stop the crashes, but even then the crash still occurs. This gives me hope that maybe this should have been allowed to type-check even without the as!, since I don't see a difference between returning Self and returning S<Self>.
Interestingly, private(set) lazy var s = S<Self>(boxed: self) doesn't type check even when C is final, as the compiler claims that it can't convert a value of type C to type Self, which doesn't make much sense to me, since it isn't even possible for Self to be a subclass of C in that context.
The text was updated successfully, but these errors were encountered:
/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of property type
private(set) lazy var s = S<Self>(boxed: self as! Self)
^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: mutable property cannot have covariant 'Self' type
private(set) lazy var s = S<Self>(boxed: self as! Self)
^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of method result type
private(set) lazy var s = S<Self>(boxed: self as! Self)
^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: covariant 'Self' can only appear at the top level of property type
private(set) lazy var s = S<Self>(boxed: self as! Self)
^
/Users/suyashsrijan/Desktop/test.swift:6:25: error: stored property cannot have covariant 'Self' type
private(set) lazy var s = S<Self>(boxed: self as! Self)
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Environment
Swift 5.1, Xcode 11.1
Additional Detail from JIRA
md5: 893a0517d6b87a11744a40e54193a693
Issue Description:
The following code crashes the compiler. It has no dependencies, you can paste it into a file and run `swiftc` to see the bug.
I originally thought that adding
final
toC
should stop the crashes, but even then the crash still occurs. This gives me hope that maybe this should have been allowed to type-check even without theas!
, since I don't see a difference between returningSelf
and returningS<Self>
.Interestingly,
private(set) lazy var s = S<Self>(boxed: self)
doesn't type check even whenC
isfinal
, as the compiler claims that it can't convert a value of typeC
to typeSelf
, which doesn't make much sense to me, since it isn't even possible forSelf
to be a subclass ofC
in that context.The text was updated successfully, but these errors were encountered: