-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow generic signature superclass constraints to contain type parameters #1263
Allow generic signature superclass constraints to contain type parameters #1263
Conversation
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
@@ -5,6 +5,12 @@ Swift 3 | |||
* Curried function syntax has been removed, and now produces a compile-time | |||
error. | |||
|
|||
* Generic signatures can now contain superclass requirements with dependent types, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Dependent types" might give people the wrong impression. 'Superclass requirements involving generic parameters' should be clearer.
@DougGregor You're right, I believe some compiler_crashers regressed because I was overwriting Superclass. I didn't realize it was an instance variable (can we have mandatory 'this' in C++? Just kidding :-) ) |
Just give your class a dependent template base class to get mandatory |
64cc6cb
to
581df72
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
diag::recursive_superclass_constraint, | ||
Superclass); | ||
|
||
superclass = Type(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not actually necessary.
…ontain type parameters There was a diagnostic to catch these, but it wasn't triggered reliably, and it sounds like users were already relying on this feature working in the few cases where it did. So instead, just map an archetype's superclass into context when building the archetype. Recursion is still not allowed and is diagnosed, for example <T, U where T : C<U>, U : C<T>>. Note that compiler_crashers_fixed/00022-no-stacktrace.swift no longer produces a diagnostic in Sema, despite the fact that the code is invalid. It does diagnose in IRGen when we map the type into context. Diagnosing in Sema requires fixing the declaration checker to correctly handle recursion through a generic signature. Right now, if recursion is detected, we bail out, but do not always diagnose. Alternatively, we could prohibit unbound generic types from appearing in generic signatures. This is a more principled fix for rdar://problem/24590570.
581df72
to
76011b9
Compare
@swift-ci Please test |
@DougGregor, @jckarter Can you take a quick look?
This is NOT for Swift 2.2.