@@ -13,7 +13,7 @@ import ast.{untpd, tpd}
1313import Contexts .* , Symbols .* , Types .* , Names .* , Constants .* , Decorators .* , Annotations .* , Flags .*
1414import Comments .{Comment , docCtx }
1515import NameKinds .*
16- import StdNames .nme
16+ import StdNames .{ nme , tpnme }
1717import config .Config
1818import collection .mutable
1919import reporting .{Profile , NoProfile }
@@ -49,6 +49,9 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
4949
5050 private var profile : Profile = NoProfile
5151
52+ private val isOutlinePickle : Boolean = attributes.isOutline
53+ private val isJavaPickle : Boolean = attributes.isJava
54+
5255 def treeAnnots (tree : untpd.MemberDef ): List [Tree ] =
5356 val ts = annotTrees.lookup(tree)
5457 if ts == null then Nil else ts.toList
@@ -188,19 +191,19 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
188191 def pickleExternalRef (sym : Symbol ) = {
189192 val isShadowedRef =
190193 sym.isClass && tpe.prefix.member(sym.name).symbol != sym
191- if ( sym.is(Flags .Private ) || isShadowedRef) {
194+ if sym.is(Flags .Private ) || isShadowedRef then
192195 writeByte(if (tpe.isType) TYPEREFin else TERMREFin )
193196 withLength {
194197 pickleNameAndSig(sym.name, sym.signature, sym.targetName)
195198 pickleType(tpe.prefix)
196199 pickleType(sym.owner.typeRef)
197200 }
198- }
199- else {
201+ else if isJavaPickle && sym == defn.FromJavaObjectSymbol then
202+ pickleType(defn.ObjectType ) // when unpickling Java TASTy, replace by <FromJavaObject>
203+ else
200204 writeByte(if (tpe.isType) TYPEREF else TERMREF )
201205 pickleNameAndSig(sym.name, tpe.signature, sym.targetName)
202- pickleType(tpe.prefix)
203- }
206+ pickleType(tpe.prefix)
204207 }
205208 if (sym.is(Flags .Package )) {
206209 writeByte(if (tpe.isType) TYPEREFpkg else TERMREFpkg )
@@ -342,7 +345,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
342345 case _ : Template | _ : Hole => pickleTree(tpt)
343346 case _ if tpt.isType => pickleTpt(tpt)
344347 }
345- if attributes.isOutline && sym.isTerm && attributes.isJava then
348+ if isOutlinePickle && sym.isTerm && isJavaPickle then
346349 // TODO: if we introduce outline typing for Scala definitions
347350 // then we will need to update the check here
348351 pickleElidedUnlessEmpty(rhs, tpt.tpe)
0 commit comments