@@ -25,8 +25,13 @@ class ReadTastyTreesFromClasses extends FrontEnd {
25
25
tree(className).flatMap {
26
26
case (clsd, unpickled) =>
27
27
if (unpickled.isEmpty) None
28
- else Some (CompilationUnit .mkCompilationUnit(clsd, unpickled, forceTrees = true ))
29
-
28
+ else {
29
+ val unit = CompilationUnit .mkCompilationUnit(clsd, unpickled, forceTrees = true )
30
+ val cls = clsd.symbol.asClass
31
+ unit.pickled += (cls -> cls.unpickler.unpickler.bytes)
32
+ cls.unpickler = null
33
+ Some (unit)
34
+ }
30
35
}
31
36
}
32
37
// The TASTY section in a/b/C.class may either contain a class a.b.C, an object a.b.C, or both.
@@ -41,12 +46,13 @@ class ReadTastyTreesFromClasses extends FrontEnd {
41
46
val clsd = ctx.base.staticRef(className)
42
47
ctx.base.staticRef(className) match {
43
48
case clsd : ClassDenotation =>
49
+ val cls = clsd.symbol.asClass
44
50
def cannotUnpickle (reason : String ) =
45
51
ctx.error(s " class $className cannot be unpickled because $reason" )
46
52
def tryToLoad = clsd.infoOrCompleter match {
47
53
case info : ClassfileLoader =>
48
54
info.load(clsd)
49
- Option (clsd.symbol.asClass .tree).orElse {
55
+ Option (cls .tree).orElse {
50
56
cannotUnpickle(s " its class file ${info.classfile} does not have a TASTY attribute " )
51
57
None
52
58
}
@@ -55,7 +61,7 @@ class ReadTastyTreesFromClasses extends FrontEnd {
55
61
cannotUnpickle(s " its info of type ${info.getClass} is not a ClassfileLoader " )
56
62
None
57
63
}
58
- Option (clsd.symbol.asClass .tree).orElse(tryToLoad).map(tree => (clsd, tree))
64
+ Option (cls .tree).orElse(tryToLoad).map(tree => (clsd, tree))
59
65
60
66
case _ =>
61
67
ctx.error(s " class not found: $className" )
0 commit comments