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
Decrement depth in subtype check withTypeVars #7291
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Let's see if we can keep the depth bookkeeping in GlbLubs. Suggestion added, but not tested in depth.
@@ -528,7 +528,7 @@ trait TypeComparers { | |||
(rt2.parents forall (isSubType(tp1, _, depth))) && | |||
(rt2.decls forall (specializesSym(tp1, _, depth))) | |||
case et2: ExistentialType => | |||
et2.withTypeVars(isSubType(tp1, _, depth), depth) || fourthTry |
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.
This works, but I'd prefer to keep the depth bookkeeping logic in GlbLubs. How about adding a .decr
in this spot:
isSubType(t, lubRefined, depth) || { |
In my superficial local testing, this also seems to break the cycle for this test case. What do you think?
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.
Ah yes, you are right, that works too! I wonder if this check is even needed though. The comment about higher-order type parameters shouldn't be true anymore.
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! Definitely worth looking into getting rid of this additional check.
Ok I tried to disable the check entirely. Let's see what CI says. If it's all is green we can try a community build with this change. However the LUB looks weird now: |
That failed quickly. But the errors reveal some fishy code paths. val concretes = concreteTypes(tvar)
(concretes contains AnyRefClass) || (concretes contains site.memberType(tvar)) Checking if a list of types contains a symbol, for example? |
contains-Any strikes again! |
I made only the suggested changes now, which means the LUB is: Kili[_ >: A with B <: Kili[_ >: A with B <: Object]]{def fili: Fili[_ >: A with M]} I don't know why the type parameter Apart from that I don't have any rational argument of why I prefer decrementing in |
As far as I know, the |
The fact that |
But I agree the same can be said about LUB verification. As long as we know that it's not possible to constrain a quantified variable recursively with the existential type itself, it should be fine.
One bug at a time 😃 |
My rationale comes from having the structure of the computation of the maximal depth be reflected in how it's decremented. I don't see a link between existential subtyping and |
Fixes scala/bug#7612
The LUB becomes
Kili[_ >: A with B <: Kili[_ >: A with B <: Object]]
.That makes sense to me.