Skip to content

Commit 6c015ca

Browse files
committed
Avoid double symbols unpickling PolySig
1 parent 2b7ceed commit 6c015ca

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,25 +1233,27 @@ class TreeUnpickler(reader: TastyReader,
12331233
val fn = readTerm()
12341234
val args = until(end)(readTerm())
12351235
if fn.symbol.isConstructor then constructorApply(fn, args)
1236-
else if defn.isPolymorphicSignature(fn.symbol) then
1237-
val info = MethodType(args.map(_.tpe.widen), defn.ObjectType)
1238-
val fun2 = fn.withType(fn.symbol.copy(info = info).termRef)
1239-
tpd.Apply(fun2, args)
1240-
else
1241-
tpd.Apply(fn, args)
1236+
else tpd.Apply(fn, args)
12421237
case TYPEAPPLY =>
12431238
tpd.TypeApply(readTerm(), until(end)(readTpt()))
12441239
case TYPED =>
1245-
val expr = readTerm()
1246-
val tpt = readTpt()
1247-
expr match
1248-
case Apply(fun, args) if defn.wasPolymorphicSignature(fun.symbol) =>
1240+
val rdr = fork
1241+
val start = rdr.reader.currentAddr
1242+
if rdr.reader.readByte() == APPLY then
1243+
val end = rdr.reader.readEnd()
1244+
val fn = rdr.readTerm()
1245+
if defn.isPolymorphicSignature(fn.symbol) then
1246+
skipTree() // expr
1247+
skipTree() // tpt
1248+
val args = rdr.reader.until(end)(rdr.readTerm())
1249+
val tpt = rdr.readTpt()
12491250
val info = MethodType(args.map(_.tpe.widen), tpt.tpe)
1250-
val fun2 = fun.withType(fun.symbol.copy(info = info).termRef)
1251-
val expr2 = tpd.cpy.Apply(expr)(fun2, args)
1252-
Typed(expr2, tpt)
1253-
case _ =>
1254-
Typed(expr, tpt)
1251+
val fun2 = fn.withType(fn.symbol.copy(info = info).termRef)
1252+
val app = Apply(fun2, args)
1253+
rdr.setSpan(start, app)
1254+
Typed(app, tpt)
1255+
else Typed(readTerm(), readTpt())
1256+
else Typed(readTerm(), readTpt())
12551257
case ASSIGN =>
12561258
Assign(readTerm(), readTerm())
12571259
case BLOCK =>

0 commit comments

Comments
 (0)