Skip to content

Commit 2c75762

Browse files
committed
Fix underlyingIfRepeated always assuming Scala repeated.
1 parent f06f3ed commit 2c75762

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/dotty/tools/dotc/core/TypeApplications.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,12 @@ class TypeApplications(val self: Type) extends AnyVal {
283283
/** If this is repeated parameter type, its underlying Seq type,
284284
* or, if isJava is true, Array type, else the type itself.
285285
*/
286-
def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type =
287-
if (self.isRepeatedParam) translateParameterized(defn.RepeatedParamClass, defn.SeqClass)
286+
def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type = {
287+
if (self.isRepeatedParam)
288+
if (isJava) translateParameterized(defn.RepeatedParamClass, defn.ArrayClass)
289+
else translateParameterized(defn.RepeatedParamClass, defn.SeqClass)
288290
else self
291+
}
289292

290293
/** If this is an encoding of a (partially) applied type, return its arguments,
291294
* otherwise return Nil.

src/dotty/tools/dotc/transform/ElimRepeated.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer { thisTransfo
6161
case tp @ MethodType(paramNames, paramTypes) =>
6262
val resultType1 = elimRepeated(tp.resultType)
6363
val paramTypes1 =
64-
if (paramTypes.nonEmpty && paramTypes.last.isRepeatedParam)
65-
paramTypes.init :+ paramTypes.last.underlyingIfRepeated(tp.isJava)
66-
else paramTypes
64+
if (paramTypes.nonEmpty && paramTypes.last.isRepeatedParam) {
65+
val last = paramTypes.last.underlyingIfRepeated(tp.isJava)
66+
paramTypes.init :+ last
67+
} else paramTypes
6768
tp.derivedMethodType(paramNames, paramTypes1, resultType1)
6869
case tp: PolyType =>
6970
tp.derivedPolyType(tp.paramNames, tp.paramBounds, elimRepeated(tp.resultType))

0 commit comments

Comments
 (0)