Skip to content

Flaw in type parameter encoding? #741

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

Closed
smarter opened this issue Jul 27, 2015 · 0 comments
Closed

Flaw in type parameter encoding? #741

smarter opened this issue Jul 27, 2015 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Jul 27, 2015

The following:

class Foo[A]

class Outer {
  class Bar[B] extends Foo[B]
}

object Test {
  def test = {
    val foo: Foo[Int] = {
      val o = new Outer
      new o.Bar[Int]
     }
  }
}

Fails with:

error: type mismatch:
 found   : Foo{A = Outer$Bar$$B; Outer$Bar$$B = Int}
 required: Foo[Int]
    val foo: Foo[Int] = {
                        ^

The issue is that in TypeAssigner#avoid we replace:

o.Bar { Outer$bar$$B = Int }

by (this is not the best solution, see #711, but that's a separate issue):

Foo { Foo$$A = Outer$bar$$B } { Outer$Bar$$B = Int }

But at this point we cannot infer that Foo$$A = Int because these refinements are not prefixed by RefinedThis so they're independent. It seems that we should either:

  • change the encoding of type parameters
  • or add a simple and robust method to go from o.Bar { Outer$Bar$$B = Int } to its "real" parent type which is Foo { Foo$$A = Int }.

@odersky : what do you think?

smarter added a commit to smarter/dotty that referenced this issue Oct 1, 2015
We need to use `baseTypeWithArgs` to replace `Bar` by its supertype
`Foo` in the type `Bar[Int]`.

Fixes scala#741.
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
We need to use `baseTypeWithArgs` to replace `Bar` by its supertype
`Foo` in the type `Bar[Int]`.

Fixes scala#741.
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant