Skip to content

Commit e949676

Browse files
committed
Fix typeAssigner ignoring existence of JavaSeqLiteral
1 parent ec5ceac commit e949676

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
128128
if (tpe derivesFrom defn.SeqClass) SeqLiteral(elems) else JavaSeqLiteral(elems)
129129

130130
def JavaSeqLiteral(elems: List[Tree])(implicit ctx: Context): SeqLiteral =
131-
new untpd.JavaSeqLiteral(elems)
132-
.withType(defn.ArrayClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
131+
ta.assignType(new untpd.JavaSeqLiteral(elems), elems)
132+
133133

134134
def TypeTree(original: Tree)(implicit ctx: Context): TypeTree =
135135
TypeTree(original.tpe, original)

src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,14 @@ trait TypeAssigner {
304304
def assignType(tree: untpd.Throw)(implicit ctx: Context) =
305305
tree.withType(defn.NothingType)
306306

307-
def assignType(tree: untpd.SeqLiteral, elems: List[Tree])(implicit ctx: Context) = {
308-
val ownType =
309-
if (ctx.erasedTypes) defn.SeqType
310-
else defn.SeqType.appliedTo(ctx.typeComparer.lub(elems.tpes).widen)
311-
tree.withType(ownType)
307+
def assignType(tree: untpd.SeqLiteral, elems: List[Tree])(implicit ctx: Context) = tree match {
308+
case tree: JavaSeqLiteral =>
309+
tree.withType(defn.ArrayClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
310+
case _ =>
311+
val ownType =
312+
if (ctx.erasedTypes) defn.SeqType
313+
else defn.SeqType.appliedTo(ctx.typeComparer.lub(elems.tpes).widen)
314+
tree.withType(ownType)
312315
}
313316

314317
def assignType(tree: untpd.SingletonTypeTree, ref: Tree)(implicit ctx: Context) =

0 commit comments

Comments
 (0)