diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index 81f822811456..7c25ecd21ebf 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -533,6 +533,9 @@ class TypeApplications(val self: Type) extends AnyVal { case JavaArrayType(elemtp) => elemtp case tp: OrType if tp.tp1.isBottomType => tp.tp2.elemType case tp: OrType if tp.tp2.isBottomType => tp.tp1.elemType - case _ => self.baseType(defn.SeqClass).argInfos.headOption.getOrElse(NoType) + case _ => + self.baseType(defn.SeqClass) + .orElse(self.baseType(defn.ArrayClass)) + .argInfos.headOption.getOrElse(NoType) } } diff --git a/tests/pos/i16562.scala b/tests/pos/i16562.scala new file mode 100644 index 000000000000..752028aae9a3 --- /dev/null +++ b/tests/pos/i16562.scala @@ -0,0 +1,8 @@ +class Test: + val a: Array[Any] = Array[Any]() + val b: Array[Any] = Array[Any]() + + def ko(p: Boolean): Unit = foo((if p then a else b): _*) + def ok(p: Boolean): Unit = foo({ val x = if p then a else b; x }: _*) + + def foo(in: Any*): Unit = ()