-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow poly-kinded GADT vars to infer constraints #19916
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
Conversation
Allowing the types to flow through in thirdTryNamed requires a tweak to baseType. Given "class C[T <: Int]" (from tests/pos-macros/i10864a) the basetype of a TypeRef of just "C", with the Any class symbol, shouldn't return Any because "C" is not a proper/value type. That is, in baseType, we need to short-circuit TypeProxy.superType (i.e. underlying), which is returns resultType for a HKLambda.
With this change, when typing |
if tp1.hasSimpleKind then | ||
if cls2 eq AnyClass then return true | ||
if cls2 == defn.SingletonClass && tp1.isStable then return true | ||
return tryBaseType(cls2) |
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.
Was this change actually necessary? Isn't tryBaseType
always going to fail anyway when tp1.hasSimpleKind
is false
? (given that you added the case HKTypeLambda => false
in baseType
, which makes sense)
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.
Yes, because then it cascades to more "tries", including allowing a gadt variable bounded by AnyKind inferring a gadt bound.
I have always found dubious that |
Not sure. And I wouldn't be surprised it's a battle to make that change. But we can try. |
Tried and it was as battle, so I gave up. |
Allowing the types to flow through in thirdTryNamed requires a tweak to
baseType. Given
class C[T <: Int]
(from tests/pos-macros/i10864a) thebasetype of a TypeRef of just "C", with the Any class symbol, shouldn't
return Any because "C" is not a proper/value type. That is, in
baseType, we need to short-circuit TypeProxy.superType (i.e.
underlying), which is returns resultType for a HKLambda.
Fixes #19904