@@ -168,6 +168,11 @@ class TreeUnpickler(reader: TastyReader,
168
168
def forkAt (start : Addr ): TreeReader = new TreeReader (subReader(start, endAddr))
169
169
def fork : TreeReader = forkAt(currentAddr)
170
170
171
+ def skipParentTree (tag : Int ): Unit = {
172
+ if tag == SPLITCLAUSE then ()
173
+ else skipTree(tag)
174
+ }
175
+ def skipParentTree (): Unit = skipParentTree(readByte())
171
176
def skipTree (tag : Int ): Unit = {
172
177
if (tag >= firstLengthTreeTag) goto(readEnd())
173
178
else if (tag >= firstNatASTTreeTag) { readNat(); skipTree() }
@@ -1016,7 +1021,7 @@ class TreeUnpickler(reader: TastyReader,
1016
1021
* parsed in this way as InferredTypeTrees.
1017
1022
*/
1018
1023
def readParents (withArgs : Boolean )(using Context ): List [Tree ] =
1019
- collectWhile(nextByte != SELFDEF && nextByte != DEFDEF ) {
1024
+ collectWhile({ val tag = nextByte; tag != SELFDEF && tag != DEFDEF && tag != SPLITCLAUSE } ) {
1020
1025
nextUnsharedTag match
1021
1026
case APPLY | TYPEAPPLY | BLOCK =>
1022
1027
if withArgs then readTree()
@@ -1043,7 +1048,8 @@ class TreeUnpickler(reader: TastyReader,
1043
1048
val bodyFlags = {
1044
1049
val bodyIndexer = fork
1045
1050
// The first DEFDEF corresponds to the primary constructor
1046
- while (bodyIndexer.reader.nextByte != DEFDEF ) bodyIndexer.skipTree()
1051
+ while ({val tag = bodyIndexer.reader.nextByte; tag != DEFDEF && tag != SPLITCLAUSE }) do
1052
+ bodyIndexer.skipParentTree()
1047
1053
bodyIndexer.indexStats(end)
1048
1054
}
1049
1055
val parentReader = fork
@@ -1062,7 +1068,38 @@ class TreeUnpickler(reader: TastyReader,
1062
1068
cls.owner.thisType, cls, parentTypes, cls.unforcedDecls,
1063
1069
selfInfo = if (self.isEmpty) NoType else self.tpt.tpe
1064
1070
).integrateOpaqueMembers
1065
- val constr = readIndexedDef().asInstanceOf [DefDef ]
1071
+
1072
+ val (constr, stats0) =
1073
+ if nextByte == SPLITCLAUSE then
1074
+ assert(unpicklingJava, s " unexpected SPLITCLAUSE at $start" )
1075
+ val tag = readByte()
1076
+ def ta = ctx.typeAssigner
1077
+ val flags = Flags .JavaDefined | Flags .PrivateLocal | Flags .Invisible
1078
+ val pflags = Flags .JavaDefined | Flags .Param
1079
+ val tdefRefs = tparams.map(_.symbol.asType)
1080
+ val ctorCompleter = new LazyType {
1081
+ def complete (denot : SymDenotation )(using Context ) =
1082
+ val sym = denot.symbol
1083
+ lazy val tparamSyms : List [TypeSymbol ] = tparams.map: tdef =>
1084
+ val completer = new LazyType {
1085
+ def complete (denot : SymDenotation )(using Context ) =
1086
+ denot.info = tdef.symbol.asType.info.subst(tdefRefs, tparamSyms.map(_.typeRef))
1087
+ }
1088
+ newSymbol(sym, tdef.name, pflags, completer, coord = cls.coord)
1089
+ val paramSym =
1090
+ newSymbol(sym, nme.syntheticParamName(1 ), pflags, defn.UnitType , coord = cls.coord)
1091
+ val paramSymss = tparamSyms :: List (paramSym) :: Nil
1092
+ val res = effectiveResultType(sym, paramSymss)
1093
+ denot.info = methodType(paramSymss, res)
1094
+ denot.setParamss(paramSymss)
1095
+ }
1096
+ val ctorSym = newSymbol(ctx.owner, nme.CONSTRUCTOR , flags, ctorCompleter, coord = coordAt(start))
1097
+ val accSym = newSymbol(cls, nme.syntheticParamName(1 ), flags, defn.UnitType , coord = ctorSym.coord)
1098
+ val ctorDef = tpd.DefDef (ctorSym, EmptyTree )
1099
+ val accessor = tpd.ValDef (accSym, ElidedTree (accSym.info))
1100
+ (ctorDef.setDefTree, accessor.setDefTree :: Nil )
1101
+ else
1102
+ readIndexedDef().asInstanceOf [DefDef ] -> Nil
1066
1103
val mappedParents : LazyTreeList =
1067
1104
if parents.exists(_.isInstanceOf [InferredTypeTree ]) then
1068
1105
// parents were not read fully, will need to be read again later on demand
@@ -1073,7 +1110,7 @@ class TreeUnpickler(reader: TastyReader,
1073
1110
1074
1111
val lazyStats = readLater(end, rdr => {
1075
1112
val stats = rdr.readIndexedStats(localDummy, end)
1076
- tparams ++ vparams ++ stats
1113
+ tparams ++ vparams ++ stats0 ++ stats
1077
1114
})
1078
1115
defn.patchStdLibClass(cls)
1079
1116
NamerOps .addConstructorProxies(cls)
@@ -1183,6 +1220,9 @@ class TreeUnpickler(reader: TastyReader,
1183
1220
1184
1221
// ------ Reading trees -----------------------------------------------------
1185
1222
1223
+ private def ElidedTree (tpe : Type )(using Context ): Tree =
1224
+ untpd.Ident (nme.WILDCARD ).withType(tpe)
1225
+
1186
1226
def readTree ()(using Context ): Tree = {
1187
1227
val sctx = sourceChangeContext()
1188
1228
if (sctx `ne` ctx) return readTree()(using sctx)
@@ -1239,7 +1279,7 @@ class TreeUnpickler(reader: TastyReader,
1239
1279
val msg =
1240
1280
s " Illegal elided tree in unpickler at $start without ${attributeTagToString(OUTLINEattr )}, ${ctx.source}"
1241
1281
report.error(msg)
1242
- untpd. Ident (nme. WILDCARD ).withType (readType())
1282
+ ElidedTree (readType())
1243
1283
case IDENTtpt =>
1244
1284
untpd.Ident (readName().toTypeName).withType(readType())
1245
1285
case SELECT =>
0 commit comments