@@ -425,7 +425,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
425
425
426
426
// symbols that were pickled with Pickler.writeSymInfo
427
427
val nameref = readNat()
428
- var name = at(nameref, readName)
428
+ var name = at(nameref, () => readName()(ctx) )
429
429
val owner = readSymbolRef()
430
430
431
431
var flags = unpickleScalaFlags(readLongNat(), name.isTypeName)
@@ -543,12 +543,12 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
543
543
denot.privateWithin =
544
544
if (! isSymbolRef(inforef)) NoSymbol
545
545
else {
546
- val pw = at(inforef, readSymbol)
546
+ val pw = at(inforef, () => readSymbol() )
547
547
inforef = readNat()
548
548
pw
549
549
}
550
550
// println("reading type for " + denot) // !!! DEBUG
551
- val tp = at(inforef, readType)
551
+ val tp = at(inforef, () => readType()(ctx) )
552
552
denot match {
553
553
case denot : ClassDenotation =>
554
554
val selfInfo = if (atEnd) NoType else readTypeRef()
@@ -599,11 +599,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
599
599
val end = readNat() + readIndex
600
600
if (tag == POLYtpe ) {
601
601
val unusedRestpeRef = readNat()
602
- until(end, readSymbolRef).asInstanceOf [List [TypeSymbol ]]
602
+ until(end, () => readSymbolRef()(ctx) ).asInstanceOf [List [TypeSymbol ]]
603
603
} else Nil
604
604
}
605
605
private def loadTypeParams (implicit ctx : Context ) =
606
- atReadPos(index(infoRef), readTypeParams)
606
+ atReadPos(index(infoRef), () => readTypeParams()(ctx) )
607
607
608
608
/** Force reading type params early, we need them in setClassInfo of subclasses. */
609
609
def init ()(implicit ctx : Context ) = loadTypeParams
@@ -741,7 +741,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
741
741
}
742
742
else
743
743
TypeRef (pre, sym.name.asTypeName)
744
- val args = until(end, readTypeRef)
744
+ val args = until(end, () => readTypeRef() )
745
745
if (sym == defn.ByNameParamClass2x ) ExprType (args.head)
746
746
else if (args.nonEmpty) tycon.safeAppliedTo(EtaExpandIfHK (sym.typeParams, args.map(translateTempPoly)))
747
747
else if (sym.typeParams.nonEmpty) tycon.EtaExpand (sym.typeParams)
@@ -752,7 +752,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
752
752
val clazz = readSymbolRef()
753
753
val decls = symScope(clazz)
754
754
symScopes(clazz) = EmptyScope // prevent further additions
755
- val parents = until(end, readTypeRef)
755
+ val parents = until(end, () => readTypeRef() )
756
756
val parent = parents.reduceLeft(AndType (_, _))
757
757
if (decls.isEmpty) parent
758
758
else {
@@ -765,26 +765,26 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
765
765
}
766
766
case CLASSINFOtpe =>
767
767
val clazz = readSymbolRef()
768
- TempClassInfoType (until(end, readTypeRef), symScope(clazz), clazz)
768
+ TempClassInfoType (until(end, () => readTypeRef() ), symScope(clazz), clazz)
769
769
case METHODtpe | IMPLICITMETHODtpe =>
770
770
val restpe = readTypeRef()
771
- val params = until(end, readSymbolRef).asInstanceOf [List [TermSymbol ]]
771
+ val params = until(end, () => readSymbolRef() ).asInstanceOf [List [TermSymbol ]]
772
772
def isImplicit =
773
773
tag == IMPLICITMETHODtpe ||
774
774
params.nonEmpty && (params.head is Implicit )
775
775
val maker = if (isImplicit) ImplicitMethodType else MethodType
776
776
maker.fromSymbols(params, restpe)
777
777
case POLYtpe =>
778
778
val restpe = readTypeRef()
779
- val typeParams = until(end, readSymbolRef)
779
+ val typeParams = until(end, () => readSymbolRef() )
780
780
if (typeParams.nonEmpty) TempPolyType (typeParams.asInstanceOf [List [TypeSymbol ]], restpe.widenExpr)
781
781
else ExprType (restpe)
782
782
case EXISTENTIALtpe =>
783
783
val restpe = readTypeRef()
784
- val boundSyms = until(end, readSymbolRef)
784
+ val boundSyms = until(end, () => readSymbolRef() )
785
785
elimExistentials(boundSyms, restpe)
786
786
case ANNOTATEDtpe =>
787
- AnnotatedType .make(readTypeRef(), until(end, readAnnotationRef))
787
+ AnnotatedType .make(readTypeRef(), until(end, () => readAnnotationRef() ))
788
788
case _ =>
789
789
noSuchTypeTag(tag, end)
790
790
}
@@ -795,7 +795,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
795
795
val end = readNat() + readIndex
796
796
if (tag == POLYtpe ) {
797
797
val unusedRestperef = readNat()
798
- until(end, readSymbolRef)
798
+ until(end, () => readSymbolRef() )
799
799
} else Nil
800
800
}
801
801
@@ -859,26 +859,26 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
859
859
}
860
860
861
861
protected def readDisambiguatedSymbolRef (p : Symbol => Boolean )(implicit ctx : Context ): Symbol =
862
- at(readNat(), readDisambiguatedSymbol(p))
862
+ at(readNat(), () => readDisambiguatedSymbol(p)( ))
863
863
864
- protected def readNameRef ()(implicit ctx : Context ): Name = at(readNat(), readName)
864
+ protected def readNameRef ()(implicit ctx : Context ): Name = at(readNat(), () => readName() )
865
865
protected def readTypeRef ()(implicit ctx : Context ): Type = at(readNat(), () => readType()) // after the NMT_TRANSITION period, we can leave off the () => ... ()
866
- protected def readConstantRef ()(implicit ctx : Context ): Constant = at(readNat(), readConstant)
866
+ protected def readConstantRef ()(implicit ctx : Context ): Constant = at(readNat(), () => readConstant() )
867
867
868
868
protected def readTypeNameRef ()(implicit ctx : Context ): TypeName = readNameRef().toTypeName
869
869
protected def readTermNameRef ()(implicit ctx : Context ): TermName = readNameRef().toTermName
870
870
871
- protected def readAnnotationRef ()(implicit ctx : Context ): Annotation = at(readNat(), readAnnotation)
871
+ protected def readAnnotationRef ()(implicit ctx : Context ): Annotation = at(readNat(), () => readAnnotation() )
872
872
873
873
protected def readModifiersRef (isType : Boolean )(implicit ctx : Context ): Modifiers = at(readNat(), () => readModifiers(isType))
874
- protected def readTreeRef ()(implicit ctx : Context ): Tree = at(readNat(), readTree)
874
+ protected def readTreeRef ()(implicit ctx : Context ): Tree = at(readNat(), () => readTree() )
875
875
876
876
/** Read an annotation argument, which is pickled either
877
877
* as a Constant or a Tree.
878
878
*/
879
879
protected def readAnnotArg (i : Int )(implicit ctx : Context ): Tree = bytes(index(i)) match {
880
- case TREE => at(i, readTree)
881
- case _ => Literal (at(i, readConstant))
880
+ case TREE => at(i, () => readTree() )
881
+ case _ => Literal (at(i, () => readConstant() ))
882
882
}
883
883
884
884
/** Read a ClassfileAnnotArg (argument to a classfile annotation)
@@ -899,8 +899,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
899
899
}
900
900
901
901
protected def readClassfileAnnotArg (i : Int )(implicit ctx : Context ): Tree = bytes(index(i)) match {
902
- case ANNOTINFO => at(i, readAnnotInfoArg)
903
- case ANNOTARGARRAY => at(i, readArrayAnnotArg)
902
+ case ANNOTINFO => at(i, () => readAnnotInfoArg() )
903
+ case ANNOTARGARRAY => at(i, () => readArrayAnnotArg() )
904
904
case _ => readAnnotArg(i)
905
905
}
906
906
@@ -916,7 +916,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
916
916
val argref = readNat()
917
917
t += {
918
918
if (isNameEntry(argref)) {
919
- val name = at(argref, readName)
919
+ val name = at(argref, () => readName() )
920
920
val arg = readClassfileAnnotArg(readNat())
921
921
NamedArg (name.asTermName, arg)
922
922
} else readAnnotArg(argref)
@@ -1007,13 +1007,13 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1007
1007
case PACKAGEtree =>
1008
1008
setSym()
1009
1009
val pid = readTreeRef().asInstanceOf [RefTree ]
1010
- val stats = until(end, readTreeRef)
1010
+ val stats = until(end, () => readTreeRef() )
1011
1011
PackageDef (pid, stats)
1012
1012
1013
1013
case CLASStree =>
1014
1014
setSymModsName()
1015
1015
val impl = readTemplateRef()
1016
- val tparams = until(end, readTypeDefRef)
1016
+ val tparams = until(end, () => readTypeDefRef() )
1017
1017
val cls = symbol.asClass
1018
1018
val ((constr : DefDef ) :: Nil , stats) =
1019
1019
impl.body.partition(_.symbol == cls.primaryConstructor)
@@ -1031,22 +1031,22 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1031
1031
1032
1032
case DEFDEFtree =>
1033
1033
setSymModsName()
1034
- val tparams = times(readNat(), readTypeDefRef)
1035
- val vparamss = times(readNat(), () => times(readNat(), readValDefRef))
1034
+ val tparams = times(readNat(), () => readTypeDefRef() )
1035
+ val vparamss = times(readNat(), () => times(readNat(), () => readValDefRef() ))
1036
1036
val tpt = readTreeRef()
1037
1037
val rhs = readTreeRef()
1038
1038
DefDef (symbol.asTerm, rhs)
1039
1039
1040
1040
case TYPEDEFtree =>
1041
1041
setSymModsName()
1042
1042
val rhs = readTreeRef()
1043
- val tparams = until(end, readTypeDefRef)
1043
+ val tparams = until(end, () => readTypeDefRef() )
1044
1044
TypeDef (symbol.asType)
1045
1045
1046
1046
case LABELtree =>
1047
1047
setSymName()
1048
1048
val rhs = readTreeRef()
1049
- val params = until(end, readIdentRef)
1049
+ val params = until(end, () => readIdentRef() )
1050
1050
val ldef = DefDef (symbol.asTerm, rhs)
1051
1051
def isCaseLabel (sym : Symbol ) = sym.name.startsWith(nme.CASEkw .toString)
1052
1052
if (isCaseLabel(symbol)) ldef
@@ -1067,15 +1067,15 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1067
1067
1068
1068
case TEMPLATEtree =>
1069
1069
setSym()
1070
- val parents = times(readNat(), readTreeRef)
1070
+ val parents = times(readNat(), () => readTreeRef() )
1071
1071
val self = readValDefRef()
1072
- val body = until(end, readTreeRef)
1072
+ val body = until(end, () => readTreeRef() )
1073
1073
untpd.Template (??? , parents, self, body) // !!! TODO: pull out primary constructor
1074
1074
.withType(symbol.namedType)
1075
1075
1076
1076
case BLOCKtree =>
1077
1077
val expr = readTreeRef()
1078
- val stats = until(end, readTreeRef)
1078
+ val stats = until(end, () => readTreeRef() )
1079
1079
Block (stats, expr)
1080
1080
1081
1081
case CASEtree =>
@@ -1085,7 +1085,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1085
1085
CaseDef (pat, guard, body)
1086
1086
1087
1087
case ALTERNATIVEtree =>
1088
- Alternative (until(end, readTreeRef))
1088
+ Alternative (until(end, () => readTreeRef() ))
1089
1089
1090
1090
case STARtree =>
1091
1091
readTreeRef()
@@ -1097,19 +1097,19 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1097
1097
1098
1098
case UNAPPLYtree =>
1099
1099
val fun = readTreeRef()
1100
- val args = until(end, readTreeRef)
1100
+ val args = until(end, () => readTreeRef() )
1101
1101
UnApply (fun, Nil , args, defn.AnyType ) // !!! this is wrong in general
1102
1102
1103
1103
case ARRAYVALUEtree =>
1104
1104
val elemtpt = readTreeRef()
1105
- val trees = until(end, readTreeRef)
1105
+ val trees = until(end, () => readTreeRef() )
1106
1106
SeqLiteral (trees, elemtpt)
1107
1107
// note can't deal with trees passed to Java methods as arrays here
1108
1108
1109
1109
case FUNCTIONtree =>
1110
1110
setSym()
1111
1111
val body = readTreeRef()
1112
- val vparams = until(end, readValDefRef)
1112
+ val vparams = until(end, () => readValDefRef() )
1113
1113
val applyType = MethodType (vparams map (_.name), vparams map (_.tpt.tpe), body.tpe)
1114
1114
val applyMeth = ctx.newSymbol(symbol.owner, nme.apply, Method , applyType)
1115
1115
Closure (applyMeth, Function .const(body.changeOwner(symbol, applyMeth)) _)
@@ -1127,7 +1127,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1127
1127
1128
1128
case MATCHtree =>
1129
1129
val selector = readTreeRef()
1130
- val cases = until(end, readCaseDefRef)
1130
+ val cases = until(end, () => readCaseDefRef() )
1131
1131
Match (selector, cases)
1132
1132
1133
1133
case RETURNtree =>
@@ -1137,7 +1137,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1137
1137
case TREtree =>
1138
1138
val block = readTreeRef()
1139
1139
val finalizer = readTreeRef()
1140
- val catches = until(end, readCaseDefRef)
1140
+ val catches = until(end, () => readCaseDefRef() )
1141
1141
Try (block, catches, finalizer)
1142
1142
1143
1143
case THROWtree =>
@@ -1153,12 +1153,12 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1153
1153
1154
1154
case TYPEAPPLYtree =>
1155
1155
val fun = readTreeRef()
1156
- val args = until(end, readTreeRef)
1156
+ val args = until(end, () => readTreeRef() )
1157
1157
TypeApply (fun, args)
1158
1158
1159
1159
case APPLYtree =>
1160
1160
val fun = readTreeRef()
1161
- val args = until(end, readTreeRef)
1161
+ val args = until(end, () => readTreeRef() )
1162
1162
/*
1163
1163
if (fun.symbol.isOverloaded) {
1164
1164
fun.setType(fun.symbol.info)
@@ -1170,7 +1170,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1170
1170
case APPLYDYNAMICtree =>
1171
1171
setSym()
1172
1172
val qual = readTreeRef()
1173
- val args = until(end, readTreeRef)
1173
+ val args = until(end, () => readTreeRef() )
1174
1174
unimplementedTree(" APPLYDYNAMIC" )
1175
1175
1176
1176
case SUPERtree =>
@@ -1218,7 +1218,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1218
1218
1219
1219
case APPLIEDTYPEtree =>
1220
1220
val tpt = readTreeRef()
1221
- val args = until(end, readTreeRef)
1221
+ val args = until(end, () => readTreeRef() )
1222
1222
AppliedTypeTree (tpt, args)
1223
1223
1224
1224
case TYPEBOUNDStree =>
@@ -1228,7 +1228,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
1228
1228
1229
1229
case EXISTENTIALTYPEtree =>
1230
1230
val tpt = readTreeRef()
1231
- val whereClauses = until(end, readTreeRef)
1231
+ val whereClauses = until(end, () => readTreeRef() )
1232
1232
TypeTree (tpe)
1233
1233
1234
1234
case _ =>
0 commit comments