@@ -1126,20 +1126,31 @@ class Typer extends Namer
11261126 }
11271127
11281128 def typedSeqLiteral (tree : untpd.SeqLiteral , pt : Type )(implicit ctx : Context ): SeqLiteral = track(" typedSeqLiteral" ) {
1129- val proto1 = pt.elemType match {
1129+ val elemProto = pt.elemType match {
11301130 case NoType => WildcardType
11311131 case bounds : TypeBounds => WildcardType (bounds)
11321132 case elemtp => elemtp
11331133 }
1134- val elems1 = tree.elems mapconserve (typed(_, proto1))
1135- val proto2 = // the computed type of the `elemtpt` field
1136- if (! tree.elemtpt.isEmpty) WildcardType
1137- else if (isFullyDefined(proto1, ForceDegree .none)) proto1
1138- else if (tree.elems.isEmpty && tree.isInstanceOf [Trees .JavaSeqLiteral [_]])
1139- defn.ObjectType // generic empty Java varargs are of type Object[]
1140- else ctx.typeComparer.lub(elems1.tpes)
1141- val elemtpt1 = typed(tree.elemtpt, proto2)
1142- assignType(cpy.SeqLiteral (tree)(elems1, elemtpt1), elems1, elemtpt1)
1134+
1135+ def assign (elems1 : List [Tree ], elemtpt1 : Tree ) =
1136+ assignType(cpy.SeqLiteral (tree)(elems1, elemtpt1), elems1, elemtpt1)
1137+
1138+ if (! tree.elemtpt.isEmpty) {
1139+ val elemtpt1 = typed(tree.elemtpt, elemProto)
1140+ val elems1 = tree.elems.mapconserve(typed(_, elemtpt1.tpe))
1141+ assign(elems1, elemtpt1)
1142+ } else {
1143+ val elems1 = tree.elems.mapconserve(typed(_, elemProto))
1144+ val elemtptType =
1145+ if (isFullyDefined(elemProto, ForceDegree .none))
1146+ elemProto
1147+ else if (tree.elems.isEmpty && tree.isInstanceOf [Trees .JavaSeqLiteral [_]])
1148+ defn.ObjectType // generic empty Java varargs are of type Object[]
1149+ else
1150+ ctx.typeComparer.lub(elems1.tpes)
1151+ val elemtpt1 = typed(tree.elemtpt, elemtptType)
1152+ assign(elems1, elemtpt1)
1153+ }
11431154 }
11441155
11451156 def typedInlined (tree : untpd.Inlined , pt : Type )(implicit ctx : Context ): Inlined = {
0 commit comments