Skip to content

Commit 4bc1323

Browse files
committed
Avoid double symbols unpickling PolySig
1 parent caef187 commit 4bc1323

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
@@ -1231,25 +1231,27 @@ class TreeUnpickler(reader: TastyReader,
12311231
val fn = readTerm()
12321232
val args = until(end)(readTerm())
12331233
if fn.symbol.isConstructor then constructorApply(fn, args)
1234-
else if defn.isPolymorphicSignature(fn.symbol) then
1235-
val info = MethodType(args.map(_.tpe.widen), defn.ObjectType)
1236-
val fun2 = fn.withType(fn.symbol.copy(info = info).termRef)
1237-
tpd.Apply(fun2, args)
1238-
else
1239-
tpd.Apply(fn, args)
1234+
else tpd.Apply(fn, args)
12401235
case TYPEAPPLY =>
12411236
tpd.TypeApply(readTerm(), until(end)(readTpt()))
12421237
case TYPED =>
1243-
val expr = readTerm()
1244-
val tpt = readTpt()
1245-
expr match
1246-
case Apply(fun, args) if defn.wasPolymorphicSignature(fun.symbol) =>
1238+
val rdr = fork
1239+
val start = rdr.reader.currentAddr
1240+
if rdr.reader.readByte() == APPLY then
1241+
val end = rdr.reader.readEnd()
1242+
val fn = rdr.readTerm()
1243+
if defn.isPolymorphicSignature(fn.symbol) then
1244+
skipTree() // expr
1245+
skipTree() // tpt
1246+
val args = rdr.reader.until(end)(rdr.readTerm())
1247+
val tpt = rdr.readTpt()
12471248
val info = MethodType(args.map(_.tpe.widen), tpt.tpe)
1248-
val fun2 = fun.withType(fun.symbol.copy(info = info).termRef)
1249-
val expr2 = tpd.cpy.Apply(expr)(fun2, args)
1250-
Typed(expr2, tpt)
1251-
case _ =>
1252-
Typed(expr, tpt)
1249+
val fun2 = fn.withType(fn.symbol.copy(info = info).termRef)
1250+
val app = Apply(fun2, args)
1251+
rdr.setSpan(start, app)
1252+
Typed(app, tpt)
1253+
else Typed(readTerm(), readTpt())
1254+
else Typed(readTerm(), readTpt())
12531255
case ASSIGN =>
12541256
Assign(readTerm(), readTerm())
12551257
case BLOCK =>

0 commit comments

Comments
 (0)