File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ class TypeApplications(val self: Type) extends AnyVal {
378378 self.derivedExprType(tp.translateParameterized(from, to))
379379 case _ =>
380380 if (self.derivesFrom(from)) {
381- def elemType (tp : Type ): Type = tp match
381+ def elemType (tp : Type ): Type = tp.widenDealias match
382382 case tp : AndOrType => tp.derivedAndOrType(elemType(tp.tp1), elemType(tp.tp2))
383383 case _ => tp.baseType(from).argInfos.head
384384 val arg = elemType(self)
@@ -404,6 +404,10 @@ class TypeApplications(val self: Type) extends AnyVal {
404404 translateParameterized(defn.RepeatedParamClass , seqClass, wildcardArg = toArray)
405405 else self
406406
407+ /** Translate a `From[T]` into a `*T`. */
408+ def translateToRepeated (from : ClassSymbol )(using Context ): Type =
409+ translateParameterized(from, defn.RepeatedParamClass )
410+
407411 /** If this is an encoding of a (partially) applied type, return its arguments,
408412 * otherwise return Nil.
409413 * Existential types in arguments are returned as TypeBounds instances.
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ trait TypeAssigner {
166166 else sym.info
167167
168168 private def toRepeated (tree : Tree , from : ClassSymbol )(using Context ): Tree =
169- Typed (tree, TypeTree (tree.tpe.widen.translateParameterized (from, defn. RepeatedParamClass )))
169+ Typed (tree, TypeTree (tree.tpe.widen.translateToRepeated (from)))
170170
171171 def seqToRepeated (tree : Tree )(using Context ): Tree = toRepeated(tree, defn.SeqClass )
172172
Original file line number Diff line number Diff line change @@ -737,12 +737,10 @@ class Typer extends Namer
737737 else pt.translateFromRepeated(toArray = false , translateWildcard = true ) |
738738 pt.translateFromRepeated(toArray = true , translateWildcard = true )
739739 val tpdExpr = typedExpr(tree.expr, ptArg)
740- tpdExpr.tpe.widenDealias match {
741- case defn.ArrayOf (_) =>
742- arrayToRepeated(tpdExpr)
743- case _ =>
744- seqToRepeated(tpdExpr)
745- }
740+ val expr1 = typedExpr(tree.expr, ptArg)
741+ val fromCls = if expr1.tpe.derivesFrom(defn.ArrayClass ) then defn.ArrayClass else defn.SeqClass
742+ val tpt1 = TypeTree (expr1.tpe.widen.translateToRepeated(fromCls)).withSpan(tree.tpt.span)
743+ assignType(cpy.Typed (tree)(expr1, tpt1), tpt1)
746744 }
747745 cases(
748746 ifPat = ascription(TypeTree (defn.RepeatedParamType .appliedTo(pt)), isWildcard = true ),
You can’t perform that action at this time.
0 commit comments