Skip to content

Commit 7b07414

Browse files
committed
Also set paramss for symbols coming from Scala-2 pickles
1 parent cff3167 commit 7b07414

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
176176
/** A map from symbols to their associated `decls` scopes */
177177
private val symScopes = mutable.AnyRefMap[Symbol, Scope]()
178178

179+
/** A dummy buffer to pass to `readType` when no `paramss` are collected */
180+
private val throwAwayBuffer = new ListBuffer[List[Symbol]]
181+
179182
protected def errorBadSignature(msg: String, original: Option[RuntimeException] = None)(implicit ctx: Context): Nothing = {
180183
val ex = new BadSignature(
181184
i"""error reading Scala signature of $classRoot from $source:
@@ -574,7 +577,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
574577
if (isSymbolRef(inforef)) inforef = readNat()
575578

576579
// println("reading type for " + denot) // !!! DEBUG
577-
val tp = at(inforef, () => readType()(ctx))
580+
val paramssBuf =
581+
if denot.is(Method) then new ListBuffer[List[Symbol]]
582+
else throwAwayBuffer
583+
val tp = at(inforef, () => readType(paramssBuf)(ctx))
584+
if denot.is(Method) then denot.paramss = paramssBuf.toList
578585

579586
denot match {
580587
case denot: ClassDenotation if !isRefinementClass(denot.symbol) =>
@@ -721,7 +728,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
721728
* the flag say that a type of kind * is expected, so that PolyType(tps, restpe) can be disambiguated to PolyType(tps, NullaryMethodType(restpe))
722729
* (if restpe is not a ClassInfoType, a MethodType or a NullaryMethodType, which leaves TypeRef/SingletonType -- the latter would make the polytype a type constructor)
723730
*/
724-
protected def readType()(implicit ctx: Context): Type = {
731+
protected def readType(paramssBuf: ListBuffer[List[Symbol]])(implicit ctx: Context): Type = {
725732
val tag = readByte()
726733
val end = readNat() + readIndex
727734
(tag: @switch) match {
@@ -790,14 +797,18 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
790797
case METHODtpe | IMPLICITMETHODtpe =>
791798
val restpe = readTypeRef()
792799
val params = until(end, () => readSymbolRef())
800+
if params.nonEmpty then paramssBuf += params
793801
val maker = MethodType.companion(
794802
isImplicit = tag == IMPLICITMETHODtpe || params.nonEmpty && params.head.is(Implicit))
795803
maker.fromSymbols(params, restpe)
796804
case POLYtpe =>
797805
val restpe = readTypeRef()
798806
val typeParams = until(end, () => readSymbolRef())
799-
if (typeParams.nonEmpty) TempPolyType(typeParams.asInstanceOf[List[TypeSymbol]], restpe.widenExpr)
800-
else ExprType(restpe)
807+
if typeParams.nonEmpty then
808+
paramssBuf += typeParams
809+
TempPolyType(typeParams.asInstanceOf[List[TypeSymbol]], restpe.widenExpr)
810+
else
811+
ExprType(restpe)
801812
case EXISTENTIALtpe =>
802813
val restpe = readTypeRef()
803814
val boundSyms = until(end, () => readSymbolRef())
@@ -881,7 +892,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
881892
at(readNat(), () => readDisambiguatedSymbol(p)())
882893

883894
protected def readNameRef()(implicit ctx: Context): Name = at(readNat(), () => readName())
884-
protected def readTypeRef()(implicit ctx: Context): Type = at(readNat(), () => readType()) // after the NMT_TRANSITION period, we can leave off the () => ... ()
895+
protected def readTypeRef()(implicit ctx: Context): Type = at(readNat(), () => readType(throwAwayBuffer)) // after the NMT_TRANSITION period, we can leave off the () => ... ()
885896
protected def readConstantRef()(implicit ctx: Context): Constant = at(readNat(), () => readConstant())
886897

887898
protected def readTypeNameRef()(implicit ctx: Context): TypeName = readNameRef().toTypeName

0 commit comments

Comments
 (0)