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
SR-6469 instantiating a generic in such a way that it references itself breaks compiler
Issue Description:
I recently spotted this pattern in UIKit
// Generic superclass
open class NSLayoutAnchor<AnchorType : AnyObject> : NSObject {}
// Non-generic subclasses with the pattern: `Sub : Super<Sub>`
open class NSLayoutXAxisAnchor : NSLayoutAnchor<NSLayoutXAxisAnchor> {}
open class NSLayoutYAxisAnchor : NSLayoutAnchor<NSLayoutYAxisAnchor> {}
open class NSLayoutDimension : NSLayoutAnchor<NSLayoutDimension> {}
If you try this patter, the compiler won't warn or raise an error:
This was closed as duplicate, but the issue that it was folded into (SR-263) does not resolve this bug. It should not be marked as duplicate, because crashes still happen with the currently released code (Apple Swift 4.2 release.)
derammo (JIRA User) Please try a 5.0 development snapshot. We resolve issues in the public tracker when the fix is checked in, not when Apple ships a formal release with the change.
I should have been more explicit. The Apple release I mentioned contains the fix for SR 263. However, that fix is for a slightly different issue, and does not resolve this bug. I don't have tooling to try a 5.0 dev snapshot and I am not using Swift at the moment, so this bug will die unless someone else picks it up.
deramm (JIRA User) I think I was too eager to dupe the two issues together, but both are fixed in 5.0. In 4.2 we implemented recursive value type metadata. There was additional work on class metadata initialization in 5.0 and I believe all the cases are handled correctly now. I tested the test case in the bug description and it works, and I can confirm similar ones also appear in our test suite.
That's exactly what I was trying to say. I had traced the bugs (in the 4.2 time frame?) and noticed the bug I had filed (SR 6469) got resolved by a fix that was actually for an adjacent issue. Since you have separately fixed it since then, I think everything is correct now. Thanks for taking the time to comment so this will be properly documented for the next person who comes here.
Environment
Xcode 7.3.1 or Xcode 8 beta 6, Swift 2.2 or latest Swift 3.0 dev snapshot
Additional Detail from JIRA
md5: 870d56ea45c052912195b3e9cdf64c43
duplicates:
is duplicated by:
Issue Description:
I recently spotted this pattern in UIKit
If you try this patter, the compiler won't warn or raise an error:
The example above will only print "1\n" and lock on `Foo()` without any error message or crash.
The text was updated successfully, but these errors were encountered: