Skip to content

Commit 0b82c37

Browse files
committed
Better typing of seqLiteral in erasure.
Fixed two problems with previous commit.
1 parent 042cee2 commit 0b82c37

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,11 @@ class TypeApplications(val self: Type) extends AnyVal {
367367
}
368368

369369
/** The element type of a sequence or array */
370-
def elemType(implicit ctx: Context): Type =
371-
firstBaseArgInfo(defn.SeqClass) orElse firstBaseArgInfo(defn.ArrayClass)
370+
def elemType(implicit ctx: Context): Type = self match {
371+
case defn.ArrayType(elemtp) => elemtp
372+
case JavaArrayType(elemtp) => elemtp
373+
case _ => firstBaseArgInfo(defn.SeqClass)
374+
}
372375

373376
/** Given a type alias
374377
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ object Erasure extends TypeTestsCasts{
375375
}
376376

377377
override def typedSeqLiteral(tree: untpd.SeqLiteral, pt: Type)(implicit ctx: Context) =
378-
super.typedSeqLiteral(tree, tree.typeOpt)
378+
super.typedSeqLiteral(tree, erasure(tree.typeOpt))
379379
// proto type of typed seq literal is original type; this makes elements be adapted to correct type.
380380

381381
override def typedValDef(vdef: untpd.ValDef, sym: Symbol)(implicit ctx: Context): ValDef =

0 commit comments

Comments
 (0)