-
Type:
Bug
-
Status: Closed
-
Priority:
Medium
-
Resolution: Done
-
Component/s: Compiler
-
Labels:None
-
Environment:
Xcode 7.3.1 or Xcode 8 beta 6, Swift 2.2 or latest Swift 3.0 dev snapshot
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:
print(1) class Test<T> {} class Foo : Test<Foo> { override init() { print(2) } func foo() { print(3) } } Foo().foo() print(4)
The example above will only print "1\n" and lock on `Foo()` without any error message or crash.
- duplicates
-
SR-263 Implement a general solution to prevent deadlocks when generic types rely on their own metadata recursively
-
- Closed
-