-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix/pickle homogenization #475
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/pickle homogenization #475
Conversation
Needed for next commit. Also homogenize types used in prefixes, and never drop "scala.", "Predef." in homogenized view.
Previously, package references could also be pickled as ThisTypes, which presented a problem for the scalac pickler.
@@ -187,8 +187,14 @@ class TreePickler(pickler: TastyPickler) { | |||
pickleName(tpe.name); pickleType(tpe.prefix) | |||
} | |||
case tpe: ThisType => | |||
writeByte(THIS) | |||
pickleType(tpe.tref) | |||
if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this normalization also affect modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why not do this for RootClass
?
@xeno-by: For modules we need the distinction: From inside a module, we prefer ThisType because |
The changes related to type pickling didn't help with the type duplication problem during the pickling. class Test2 {
def x: Int = 5
} Even using the updated version we have two pickled types that represent 'package scala'. This type is pickled during the processing of tpt of init (scala.Unit): This type is pickled during the processing of tpt of def x: The issue is that each of these types is already added to pickledTypes before the invocation of def pickleNewType, and has its address. Here is a part from the pickling log file: //Unit processing
pickleName: Unit
astTag: TERMREFpkg (67)
//at this moment ThisType(TypeRef(NoPrefix,scala)) is already in the *pickledTypes* map
pickleName(*): Simple(scala)
...
astTag: DEFDEF (130)
pickleName: x
astTag: TYPEREF (117)
pickleName: Int
astTag: TERMREF (115)
//at this moment TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala) also is in the *pickledTypes* map
pickleNameAndSig, name: scala
params: List()
result:
pickleName(*): Signed(NameRef(14),List(),NameRef(2)) To have only one instance of the type, the second passed type should be transformed to its equivalent to be found in the pickledTypes map during the invocation of pickleType. |
I see, thanks. I will be away from my computer for a couple of days. If you On Thu, Apr 16, 2015 at 3:39 AM, Vladimir Nikolaev <[email protected]
Martin Odersky |
The problem with this task is how to transform one type to its counterpart before its processing inside def pickleType (before the addition to pickledTypes map) . If we want to pickle only types of one definite form (for packages), the other form should be mapped to the first one. |
Previously, some references used TermRef and a name with signature, which gave two different ways to represent a package.
@VladimirNik can you check whether the last commit is what you need? |
I checked the same example: class Test {
def x: Int = 5
} With these changes for Dotty we have: //pickling for scala.Unit in the constructor
astTag: TYPEREF (117)
pickleName: Unit
astTag: TERMREFpkg (67)
pickleName(*): Simple(scala)
...
//pickling for tpt of the method
astTag: TYPEREF (117)
pickleName: Int
//scala package processing
astTag: TERMREFpkg (67)
pickleName(*): Simple(scala) Two instances (two forms) of scala package are represented similarly during the pickling, but they are both pickled and have their addresses in pickledTypes map. And in Scala log: //pickling for scala.Unit in the constructor
astTag: TYPEREF (117)
pickleName: Unit
astTag: TERMREFpkg (67)
pickleName(*): Simple(scala)
...
//pickling for tpt of the method
astTag: TYPEREF (117)
pickleName: Int
//scala package processing
astTag: SHARED (64) // No new type pickling The type for scala package is shared. There is only one address for this type. Maybe we should allow the different pickling results for Dotty and Scala? |
Yes, I think we should allow. Sharing is strictly an optimization; we
On Mon, Apr 20, 2015 at 12:42 PM, Vladimir Nikolaev <
Martin Odersky |
@VladimirNik Good to merge? |
@odersky LGTM, thank you! |
Standardize types pickled by packages as agreed in conversation with @VladimirNik.
Review by @VladimirNik, @xeno-by