You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scala2Unpickler: Don't trust the owner field of tparams
When a type parameter of a class external to the current pickle is
referenced, Scala 2 will sometimes pickle it as if it was a type
parameter of the current class. When we unpickle such a type parameter
on our side, we enter it in the class, this leads the compiler to
believe the class has more type parameters than it actually has. This
doesn't happen in Scala 2 itself because it never enters unpickled type
parameters in the class that owns them (it must be recreating them in
some way, but I don't know how).
It would be interesting to dig deeper to understand exactly how Scala 2
handles type parameter unpickling so we could emulate it given that this
is not the first time we run into trouble here (cf #12120), but for now
we fix the problem with the following heuristic: once we've loaded all
the type parameters of a class (which we do eagerly via
`ClassUnpickler#init()`), we simply stop from being entered any
subsequent type parameter we see for this class. Time will tell if this
is good enough.
While I was touching that code, I also made
ClassCompleter#completerTypeParams idempotent as one would expect it to
be.
Fixes#12641.
0 commit comments