NSLayoutConstraint type hierarchy is broken

Originator:brianaking
Number:rdar://26805013 Date Originated:
Status: Resolved:
Product:iOS SDK Product Version:
Classification: Reproducible:
 
Summary:
NSLayout Subclasses use a recursive type description:

```obj-c
@interface NSLayoutYAxisAnchor :
NSLayoutAnchor<NSLayoutYAxisAnchor *>
@end
```

This sort of recursive declaration in swift will just infinitely recurse and hang the compiler.

I'm trying to write a function that will take an axis anchor and return an anchor.  IE:

```swift
func anchorForAxis(axis: NSLayoutYAxisAnchor) -> NSLayoutAnchor<AnyObject> {
    return axis
}
```
This fails with the error:

Cannot convert return expression of type 'NSLayoutYAxisAnchor' to return type 'NSLayoutAnchor<AnyObject>'

This type of failure severely limits the usability of NSLayoutAnchor in swift.

This is being problematic in a library to provide operator overloads:

https://github.com/raizlabs/anchorage

Steps to Reproduce:
Attempt to return an NSLayoutAnchor of an NSLayoutYAxisAnchor. IE:

func anchorForAxis(axis: NSLayoutYAxisAnchor) -> NSLayoutAnchor<AnyObject> {
    return axis
}


Expected Results:
It should work.

Actual Results:
Cannot convert return expression of type 'NSLayoutYAxisAnchor' to return type 'NSLayoutAnchor<AnyObject>'


Version:
Xcode Version 8.0 beta (8S128d)

Notes:


Configuration:
iOS 10

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!