Skip to content

Testpickling failure due to avoidance #2840

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
odersky opened this issue Jul 6, 2017 · 0 comments
Closed

Testpickling failure due to avoidance #2840

odersky opened this issue Jul 6, 2017 · 0 comments

Comments

@odersky
Copy link
Contributor

odersky commented Jul 6, 2017

Consider:

object Test {
  class Type
  def f(x: Type): Type = ???
  def g(xs: List[Type]): Int = {
    val ys = xs.map(f)
    ys.toSet.size
  }
}

If we run this with -Ytest-pickler like this:

dotc toSet.scala -Ytest-pickler -Xprint-types

We get:

 pickling difference for module class Test$ in toSet.scala, for details:
               |
               |  diff before-pickling.txt after-pickling.txt

The diff is here:

<       :scala.Int>@<106..164>
---
>       :=> scala.Int(scala.collection.immutable.Set[Test.Type]#size)>@<106..164>

The rhs of g has type Int before pickling but type Set[Type]#size after pickling.
The problem has to do with avoid. The type of the block before avoid
is ys.toSet.size.type. That type is illegal, because it refers to
the local variable ys. Typer fixes the type to be Int since
that's the expected type anyway. But the unpickler widens the type
to ys.toSet.size.type instead because it does not have an expected type.

The difference is minor and probably harmless for all purposes. But it raises a flag in the diffs. The best way to suppress this is probably by adding a case to PlainPrinter#homogenize to deal with this. But I am unsure what the right rule should be.

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

1 participant