@@ -163,6 +163,11 @@ class TreeUnpickler(reader: TastyReader,
163
163
def forkAt (start : Addr ): TreeReader = new TreeReader (subReader(start, endAddr))
164
164
def fork : TreeReader = forkAt(currentAddr)
165
165
166
+ def skipParentTree (tag : Int ): Unit = {
167
+ if tag == SPLITCLAUSE then ()
168
+ else skipTree(tag)
169
+ }
170
+ def skipParentTree (): Unit = skipParentTree(readByte())
166
171
def skipTree (tag : Int ): Unit = {
167
172
if (tag >= firstLengthTreeTag) goto(readEnd())
168
173
else if (tag >= firstNatASTTreeTag) { readNat(); skipTree() }
@@ -1011,7 +1016,7 @@ class TreeUnpickler(reader: TastyReader,
1011
1016
* parsed in this way as InferredTypeTrees.
1012
1017
*/
1013
1018
def readParents (withArgs : Boolean )(using Context ): List [Tree ] =
1014
- collectWhile(nextByte != SELFDEF && nextByte != DEFDEF ) {
1019
+ collectWhile({ val tag = nextByte; tag != SELFDEF && tag != DEFDEF && tag != SPLITCLAUSE } ) {
1015
1020
nextUnsharedTag match
1016
1021
case APPLY | TYPEAPPLY | BLOCK =>
1017
1022
if withArgs then readTree()
@@ -1038,7 +1043,8 @@ class TreeUnpickler(reader: TastyReader,
1038
1043
val bodyFlags = {
1039
1044
val bodyIndexer = fork
1040
1045
// The first DEFDEF corresponds to the primary constructor
1041
- while (bodyIndexer.reader.nextByte != DEFDEF ) bodyIndexer.skipTree()
1046
+ while ({val tag = bodyIndexer.reader.nextByte; tag != DEFDEF && tag != SPLITCLAUSE }) do
1047
+ bodyIndexer.skipParentTree()
1042
1048
bodyIndexer.indexStats(end)
1043
1049
}
1044
1050
val parentReader = fork
@@ -1057,7 +1063,38 @@ class TreeUnpickler(reader: TastyReader,
1057
1063
cls.owner.thisType, cls, parentTypes, cls.unforcedDecls,
1058
1064
selfInfo = if (self.isEmpty) NoType else self.tpt.tpe
1059
1065
).integrateOpaqueMembers
1060
- val constr = readIndexedDef().asInstanceOf [DefDef ]
1066
+
1067
+ val (constr, stats0) =
1068
+ if nextByte == SPLITCLAUSE then
1069
+ assert(unpicklingJava, s " unexpected SPLITCLAUSE at $start" )
1070
+ val tag = readByte()
1071
+ def ta = ctx.typeAssigner
1072
+ val flags = Flags .JavaDefined | Flags .PrivateLocal | Flags .Invisible
1073
+ val pflags = Flags .JavaDefined | Flags .Param
1074
+ val tdefRefs = tparams.map(_.symbol.asType)
1075
+ val ctorCompleter = new LazyType {
1076
+ def complete (denot : SymDenotation )(using Context ) =
1077
+ val sym = denot.symbol
1078
+ lazy val tparamSyms : List [TypeSymbol ] = tparams.map: tdef =>
1079
+ val completer = new LazyType {
1080
+ def complete (denot : SymDenotation )(using Context ) =
1081
+ denot.info = tdef.symbol.asType.info.subst(tdefRefs, tparamSyms.map(_.typeRef))
1082
+ }
1083
+ newSymbol(sym, tdef.name, pflags, completer, coord = cls.coord)
1084
+ val paramSym =
1085
+ newSymbol(sym, nme.syntheticParamName(1 ), pflags, defn.UnitType , coord = cls.coord)
1086
+ val paramSymss = tparamSyms :: List (paramSym) :: Nil
1087
+ val res = effectiveResultType(sym, paramSymss)
1088
+ denot.info = methodType(paramSymss, res)
1089
+ denot.setParamss(paramSymss)
1090
+ }
1091
+ val ctorSym = newSymbol(ctx.owner, nme.CONSTRUCTOR , flags, ctorCompleter, coord = coordAt(start))
1092
+ val accSym = newSymbol(cls, nme.syntheticParamName(1 ), flags, defn.UnitType , coord = ctorSym.coord)
1093
+ val ctorDef = tpd.DefDef (ctorSym, EmptyTree )
1094
+ val accessor = tpd.ValDef (accSym, ElidedTree (accSym.info))
1095
+ (ctorDef.setDefTree, accessor.setDefTree :: Nil )
1096
+ else
1097
+ readIndexedDef().asInstanceOf [DefDef ] -> Nil
1061
1098
val mappedParents : LazyTreeList =
1062
1099
if parents.exists(_.isInstanceOf [InferredTypeTree ]) then
1063
1100
// parents were not read fully, will need to be read again later on demand
@@ -1068,7 +1105,7 @@ class TreeUnpickler(reader: TastyReader,
1068
1105
1069
1106
val lazyStats = readLater(end, rdr => {
1070
1107
val stats = rdr.readIndexedStats(localDummy, end)
1071
- tparams ++ vparams ++ stats
1108
+ tparams ++ vparams ++ stats0 ++ stats
1072
1109
})
1073
1110
defn.patchStdLibClass(cls)
1074
1111
NamerOps .addConstructorProxies(cls)
@@ -1178,6 +1215,9 @@ class TreeUnpickler(reader: TastyReader,
1178
1215
1179
1216
// ------ Reading trees -----------------------------------------------------
1180
1217
1218
+ private def ElidedTree (tpe : Type )(using Context ): Tree =
1219
+ untpd.Ident (nme.WILDCARD ).withType(tpe)
1220
+
1181
1221
def readTree ()(using Context ): Tree = {
1182
1222
val sctx = sourceChangeContext()
1183
1223
if (sctx `ne` ctx) return readTree()(using sctx)
@@ -1234,7 +1274,7 @@ class TreeUnpickler(reader: TastyReader,
1234
1274
val msg =
1235
1275
s " Illegal elided tree in unpickler at $start without ${attributeTagToString(OUTLINEattr )}, ${ctx.source}"
1236
1276
report.error(msg)
1237
- untpd. Ident (nme. WILDCARD ).withType (readType())
1277
+ ElidedTree (readType())
1238
1278
case IDENTtpt =>
1239
1279
untpd.Ident (readName().toTypeName).withType(readType())
1240
1280
case SELECT =>
0 commit comments