Skip to content

Match Types arguments with bounds (yet another) #11205

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

Open
zraffer opened this issue Jan 24, 2021 · 5 comments
Open

Match Types arguments with bounds (yet another) #11205

zraffer opened this issue Jan 24, 2021 · 5 comments

Comments

@zraffer
Copy link

zraffer commented Jan 24, 2021

Compiler version

3.0.0-M3

Minimized code

object TMP:
  final class Tu1[Ar1]
  type Pr11[T <: Tu1[_]] =
    T match {case Tu1[ar1] => ar1}

  final class Tu2[Ar1 <: Tu1[_], Ar2 <: Pr11[Ar1]]
  type Pr21[T <: Tu2[_,_]] <: Tu1[_] =
    T match {case Tu2[ar1, ar2] => ar1}
  type Pr22[T <: Tu2[_,_]] <: Pr11[Pr21[T]] =
    T match {case Tu2[ar1, ar2] => ar2} // error here!

  type Copy[T <: Tu2[_,_]] = Tu2[Pr21[T], Pr22[T]]

emits error about ar2 bound

Expectation

The code should be typechecked well.

Note: it is modified version of #6697
The topic of these exercises are obvious typelevel copying of typelevel tuples via typelevel projections.
Now with bound of an argument being itself a projection.

@OlivierBlanvillain
Copy link
Contributor

Have you tried giving Pr21[T] a name? I'm not sure the compiler know how to unify wildcards that way...

@zraffer
Copy link
Author

zraffer commented Jan 29, 2021 via email

@dwijnand
Copy link
Member

Have you tried giving Pr21[T] a name? I'm not sure the compiler know how to unify wildcards that way...

I'm not 100% sure if "unify wildcards" and "capture conversion" are 1:1, but at least here I think I debugged that it fails because capture conversion fails, and that's because T (which is the "leftRoot") isn't stable. And a short attempt at overriding that still failed (but I forgot why now).

@OlivierBlanvillain do you think we should close this as "won't fix", or do you think it's something that should be made to work?

@dwijnand
Copy link
Member

Looked at this last week (with @Decel) and I recorded that I think this needs some "subtype reconstruction" (aka "GADT reasoning"), so that we record that in T match {case Tu2[ar1, ar2] => RHS1 ...} that T <: Tu2[ar1, ar2] while typing RHS1.

@dwijnand dwijnand assigned dwijnand and Decel and unassigned OlivierBlanvillain May 15, 2023
@dwijnand
Copy link
Member

dwijnand commented May 15, 2023

I mention that because I discovered that to fix #13741 I also need that inference.

@dwijnand dwijnand removed their assignment Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants