Skip to content

When unpickling from Tasty, we cannot distinguish between overloaded alternatives with the same signature #7022

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 Aug 10, 2019 · 3 comments

Comments

@smarter
Copy link
Member

smarter commented Aug 10, 2019

This code compiles fine:

trait P[A] {
  def foo[T](x: Int): A = ???
}

class C extends P[Int] {
  def foo(x: Int): Int = x
}

object Test {
  def test(p: C): Unit = {
    p.foo(1)
  }
}

But if we run it through the pickler/unpickler (easiest way is to do dotc -Ythrough-tasty Test.scala), we get:

-- Error: /home/smarter/opt/dotty/try/tt.scala:9:4 -----------------------------
9 |    p.foo(1)
  |    ^^^^^^^
  |    overloaded alternatives of method foo in class C with types
  |     (x: Int): Int
  |     [T](x: Int): Int does not take parameters

The problem is that in Tasty, we use this representation:

SELECT 32 [foo[Signed Signature(List(scala.Int),scala.Int)]]

This uses the denotation signature and not the symbol signature, so both alternatives have the same signature.
Fixing this is necessary to switch to the 2.13 collections.

@smarter
Copy link
Member Author

smarter commented Aug 10, 2019

Possible fixes:

  • store the symbol signature instead of the denotation signature in tasty and use that to choose the alternative, not sure if that would always work
  • store the full type of the alternative in tasty if we detect that the signature is not unique

/cc @odersky

@odersky
Copy link
Contributor

odersky commented Aug 26, 2019

@smarter Is this one fixed now?

@smarter
Copy link
Member Author

smarter commented Aug 26, 2019

Yes, fixed by f951534

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

2 participants