Skip to content

Subtyping breaks under a dependent prefix? #4908

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
Blaisorblade opened this issue Aug 8, 2018 · 1 comment
Open

Subtyping breaks under a dependent prefix? #4908

Blaisorblade opened this issue Aug 8, 2018 · 1 comment
Labels
area:typer backlog No work planned on this by the core team for the time being. itype:bug

Comments

@Blaisorblade
Copy link
Contributor

Split out of #4902.
In the code below, x.to(g.MSetFactory) works in v1 but not in f3, so it seems clear it's a bug, probably involving asSeenFrom somewhere. Sadly Scalac can't handle this either.

object Test {
  trait A
  trait B
  trait TestConstructor1 { type F[X <: A]
    trait FromSet[C[_ <: A with B]]

    trait MSetLike[X <: A with B, This <: MSet[X] with MSetLike[X, This]] {
      def to[C[X <: A with B] <: MSet[X] with MSetLike[X, C[X]]](fi: FromSet[C]): C[X] = ???
    }
    trait MSet[X <: A with B] extends MSetLike[X, MSet[X]]
    object MSetFactory extends FromSet[MSet]
  }

  trait TestConstructor4[D] {
    trait TestConstructor5[E] {
      trait FromSet[C[_ <: D with E]]

      trait MSetLike[X <: D with E, This <: MSet[X] with MSetLike[X, This]] {
        def to[C[X <: D with E] <: MSet[X] with MSetLike[X, C[X]]](fi: FromSet[C]): C[X] = ???
      }
      trait MSet[X <: D with E] extends MSetLike[X, MSet[X]]
      object MSetFactory extends FromSet[MSet]
    }
  }

  type C = A & B
  val v1: TestConstructor1 => Unit = { f =>
    type P[a <: A] = f.F[a]

    type P1[c <: C] = f.MSet[c]
      (f.MSetFactory: f.FromSet[f.MSet]): Unit
      (x: P1[C]) => x.to(f.MSetFactory)
  }

  def f3(f: TestConstructor4[A])(g: f.TestConstructor5[B]): Unit = {
    type P1[c <: C] = g.MSet[c]
      (g.MSetFactory: g.FromSet[g.MSet]): Unit
      (x: P1[C]) => x.to(g.MSetFactory)
      (x: P1[C]) => x.to[g.MSet](g.MSetFactory)
  }
}

gives

- [E007] Type Mismatch Error: tests/pos/i4884c.scala:37:9 ---------------------
37 |      (g.MSetFactory: g.FromSet[g.MSet]): Unit
   |       ^^^^^^^^^^^^^
   |       found:    g.MSetFactory.type
   |       required: g.FromSet[g.MSet]
   |
-- [E007] Type Mismatch Error: tests/pos/i4884c.scala:38:27 --------------------
38 |      (x: P1[C]) => x.to(g.MSetFactory)
   |                         ^^^^^^^^^^^^^
   |                         found:    g.MSetFactory.type
   |                         required: g.FromSet[g.MSet]
   |
-- [E007] Type Mismatch Error: tests/pos/i4884c.scala:39:35 --------------------
39 |      (x: P1[C]) => x.to[g.MSet](g.MSetFactory)
   |                                 ^^^^^^^^^^^^^
   |                                 found:    g.MSetFactory.type
   |                                 required: g.FromSet[g.MSet]
   |
three errors found

That's from some code in tests/run/colltest5/ that failed when I oversimplified typeApplications.

@odersky
Copy link
Contributor

odersky commented Oct 8, 2018

Can we minimize this further?

odersky added a commit to dotty-staging/dotty that referenced this issue Mar 8, 2020
@odersky odersky added the backlog No work planned on this by the core team for the time being. label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer backlog No work planned on this by the core team for the time being. itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants