-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GADT: superclass' type param instantiated to union type in a subclass does not infer properly #17075
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
Comments
That does not seem to be a realistic expectation. From an abstract |
The compiler does remember that class Context[||[_, _]]:
enum Foo[A]:
case Bar[X, Y]() extends Foo[X || Y]
def go[A](foo: Foo[A]): Unit =
foo match
case b: Foo.Bar[x, y] =>
summon[(x || y) =:= A] // OK |
Your
Any treatment that relies on decomposing a union type is doomed to fail. |
The two examples (with I have previously hit the problem of not inferring Is it correct to say that the compiler wants (at most) one canonical decomposition of any type variable?
Am I getting this roughly right? Then, since trying to get a unique decomposition is futile anyway (as demonstrated by |
|
That itself sounds like a contradiction to me 😉. But you are probably just using the word "unique" in a different way. I'm going to call it a "good enough" decomposition for now. So I am guessing the reason to not consider
That one is tricky (and not the point of this ticket), but my hunch is there is an algorithm to infer this without conjuring up anything. |
Compiler version
3.2.2
3.3.0-RC3
Minimized code
Output
Expectation
Should compile.
The text was updated successfully, but these errors were encountered: