Skip to content

Commit 9d075e4

Browse files
committed
Fix #7735: Handle case of seq literals if singleton primitive types
This failed -Ycheck before, but after erasure everything is fine. So this needs a couple of casts to work.
1 parent 9aa7991 commit 9d075e4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
453453
* kind for the given element type in `elemTpe`.
454454
*/
455455
def wrapArray(tree: Tree, elemtp: Type)(implicit ctx: Context): Tree =
456-
ref(defn.getWrapVarargsArrayModule)
456+
val wrapper = ref(defn.getWrapVarargsArrayModule)
457457
.select(wrapArrayMethodName(elemtp))
458458
.appliedToTypes(if (elemtp.isPrimitiveValueType) Nil else elemtp :: Nil)
459-
.appliedTo(tree)
459+
val actualElem = wrapper.tpe.widen.firstParamTypes.head
460+
wrapper.appliedTo(tree.ensureConforms(actualElem))
460461

461462
// ------ Creating typed equivalents of trees that exist only in untyped form -------
462463

compiler/src/dotty/tools/dotc/transform/SeqLiterals.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ class SeqLiterals extends MiniPhase {
3131
val arr = JavaSeqLiteral(tree.elems, tree.elemtpt)
3232
//println(i"trans seq $tree, arr = $arr: ${arr.tpe} ${arr.tpe.elemType}")
3333
val elemtp = tree.elemtpt.tpe
34-
wrapArray(arr, elemtp).withSpan(tree.span)
34+
wrapArray(arr, elemtp).withSpan(tree.span).ensureConforms(tree.tpe)
3535
}
3636
}

0 commit comments

Comments
 (0)