-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix typing of new #6097
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
Fix typing of new #6097
Conversation
Assume ``` class C[X] type A[X] = C[X] ``` The previous rule for `new A` overwrote the type of `A` with `C`, in order to satisfy the condition that the type of `new` should be a class type. Overwriting types like that in Typer is wrong, since it is not preserved by pickling. We tried to patch up things in RefinedPrinter, but this is not enough, as test case `alias-new.scala` shows. This test caused the type in a `new` to be unpickled as a <notype>. The fix is to treat eta-reduction in new types in a purely functional way, applied in both Typer and TypeAssigner. The problem was encountered when systematically testing creation methods, but it has nothing to do with them.
The fix breaks FromTasty tests. i0306.scala first, and once that it blacklisted a bunch of others where the decompiled source is not compilable. Wrt the example above, we'd see new nodes like:
We should leave this as either Note: Previously this problem was hidden because we overwrote the alias type |
... awaiting a fix for scala#6097.
920a03f
to
463b2de
Compare
463b2de
to
ff63727
Compare
Now |
... awaiting a fix for scala#6097.
Assume
The previous rule for
new A
overwrote the type ofA
with
C
, in order to satisfy the condition that the typeof
new
should be a class type. Overwriting types likethat in Typer is wrong, since it is not preserved by pickling.
We tried to patch up things in RefinedPrinter, but this is not
enough, as test case
alias-new.scala
shows. This test causedthe type in a
new
to be unpickled as a<notype>
.The fix is to treat eta-reduction in new types in a purely functional
way, applied in both Typer and TypeAssigner.
The problem was encountered when systematically testing creation methods,
but it has nothing to do with them.