Skip to content

Commit

Permalink
Fix #5411: varargs with intersection type elements
Browse files Browse the repository at this point in the history
We need to generate a ClassTag to construct a Java vararg array.
Just computing the class symbol of the element type is not enough,
as some types do not have class symbols. We need instead to compute
the class symbol on the erased element type.
  • Loading branch information
odersky committed Dec 17, 2018
1 parent fcc35d2 commit d1679c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Constants._
import Decorators._
import Denotations._, SymDenotations._
import dotty.tools.dotc.ast.tpd
import TypeErasure.erasure
import DenotTransformers._

object ElimRepeated {
Expand Down Expand Up @@ -92,7 +93,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
JavaSeqLiteral(elems, elemtpt)
case _ =>
val elemType = tree.tpe.elemType
var elemClass = elemType.classSymbol
var elemClass = erasure(elemType).classSymbol
if (defn.NotRuntimeClasses.contains(elemClass)) elemClass = defn.ObjectClass
ref(defn.DottyArraysModule)
.select(nme.seqToArray)
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i5411.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait A
trait B
object O {
def m(x: Seq[A & B]) = java.util.Arrays.asList(x: _*)
}

0 comments on commit d1679c3

Please sign in to comment.