diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala index 9935311d10c1..08452782fd66 100644 --- a/compiler/src/dotty/tools/dotc/core/Decorators.scala +++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala @@ -144,13 +144,13 @@ object Decorators { * `xs` to themselves. Also, it is required that `ys` is at least * as long as `xs`. */ - def zipWithConserve[U](ys: List[U])(f: (T, U) => T): List[T] = + def zipWithConserve[U, V <: T](ys: List[U])(f: (T, U) => V): List[V] = if (xs.isEmpty || ys.isEmpty) Nil else { val x1 = f(xs.head, ys.head) val xs1 = xs.tail.zipWithConserve(ys.tail)(f) - if ((x1.asInstanceOf[AnyRef] eq xs.head.asInstanceOf[AnyRef]) && - (xs1 eq xs.tail)) xs + if (x1.asInstanceOf[AnyRef] eq xs.head.asInstanceOf[AnyRef]) && (xs1 eq xs.tail) + then xs.asInstanceOf[List[V]] else x1 :: xs1 } diff --git a/compiler/src/dotty/tools/dotc/core/Signature.scala b/compiler/src/dotty/tools/dotc/core/Signature.scala index d9b5dcca81e3..bd744ec01846 100644 --- a/compiler/src/dotty/tools/dotc/core/Signature.scala +++ b/compiler/src/dotty/tools/dotc/core/Signature.scala @@ -71,9 +71,7 @@ case class Signature(paramsSig: List[ParamSig], resSig: TypeName) { else if (!this.paramsSig.hasSameLengthAs(that.paramsSig)) that else { val mapped = Signature( - // DOTTY: we shouldn't have to explicitly pass a type argument to `update`, - // see https://github.com/lampepfl/dotty/issues/4867 - this.paramsSig.zipWithConserve(that.paramsSig)(update[ParamSig]), + this.paramsSig.zipWithConserve(that.paramsSig)(update), update(this.resSig, that.resSig)) if (mapped == this) this else mapped } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala index 7752df9c3dd7..70bdec7780e2 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala @@ -54,9 +54,7 @@ class TastyUnpickler(reader: TastyReader) { val end = start + length def readSignedRest(original: TermName, target: TermName): TermName = val result = readName().toTypeName - // DOTTY: we shouldn't have to give an explicit type to paramsSig, - // see https://github.com/lampepfl/dotty/issues/4867 - val paramsSig: List[Signature.ParamSig] = until(end)(readParamSig()) + val paramsSig = until(end)(readParamSig()) val sig = Signature(paramsSig, result) SignedName(original, sig, target) diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index cd3b29d7e256..ab0c8d449d00 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -825,7 +825,6 @@ object Erasure { val args0 = outers ::: ownArgs val args1 = args0.zipWithConserve(xmt.paramInfos)(typedExpr) - .asInstanceOf[List[Tree]] def mkApply(finalFun: Tree, finalArgs: List[Tree]) = val app = untpd.cpy.Apply(tree)(finalFun, finalArgs) diff --git a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala index 959032426a21..4798563fab43 100644 --- a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala @@ -110,7 +110,7 @@ class ReTyper(nestingLevel: Int = 0) extends Typer(nestingLevel) with ReChecking override def handleUnexpectedFunType(tree: untpd.Apply, fun: Tree)(using Context): Tree = fun.tpe match { case mt: MethodType => - val args: List[Tree] = tree.args.zipWithConserve(mt.paramInfos)(typedExpr(_, _)).asInstanceOf[List[Tree]] + val args: List[Tree] = tree.args.zipWithConserve(mt.paramInfos)(typedExpr) assignType(untpd.cpy.Apply(tree)(fun, args), fun, args) case _ => super.handleUnexpectedFunType(tree, fun) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index e5aefd8a13d9..3d6b0c3038cd 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1969,7 +1969,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer } else desugaredArg.withType(UnspecifiedErrorType) } - args.zipWithConserve(tparams)(typedArg(_, _)).asInstanceOf[List[Tree]] + args.zipWithConserve(tparams)(typedArg) } val paramBounds = tparams.lazyZip(args).map { case (tparam, untpd.WildcardTypeBoundsTree()) =>