Skip to content

Commit 34f25b1

Browse files
committed
Fix typeAssigner ignoring existence of JavaSeqLiteral
1 parent 7fd8b1e commit 34f25b1

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
@@ -126,8 +126,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
126126
if (tpe derivesFrom defn.SeqClass) SeqLiteral(elems) else JavaSeqLiteral(elems)
127127

128128
def JavaSeqLiteral(elems: List[Tree])(implicit ctx: Context): SeqLiteral =
129-
new untpd.JavaSeqLiteral(elems)
130-
.withType(defn.ArrayClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
129+
ta.assignType(new untpd.JavaSeqLiteral(elems), elems)
130+
131131

132132
def TypeTree(original: Tree)(implicit ctx: Context): TypeTree =
133133
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
@@ -321,11 +321,14 @@ trait TypeAssigner {
321321
def assignType(tree: untpd.Throw)(implicit ctx: Context) =
322322
tree.withType(defn.NothingType)
323323

324-
def assignType(tree: untpd.SeqLiteral, elems: List[Tree])(implicit ctx: Context) = {
325-
val ownType =
326-
if (ctx.erasedTypes) defn.SeqType
327-
else defn.SeqType.appliedTo(ctx.typeComparer.lub(elems.tpes).widen)
328-
tree.withType(ownType)
324+
def assignType(tree: untpd.SeqLiteral, elems: List[Tree])(implicit ctx: Context) = tree match {
325+
case tree: JavaSeqLiteral =>
326+
tree.withType(defn.ArrayClass.typeRef.appliedTo(ctx.typeComparer.lub(elems.tpes)))
327+
case _ =>
328+
val ownType =
329+
if (ctx.erasedTypes) defn.SeqType
330+
else defn.SeqType.appliedTo(ctx.typeComparer.lub(elems.tpes).widen)
331+
tree.withType(ownType)
329332
}
330333

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

0 commit comments

Comments
 (0)