Skip to content

Commit 2bc3d23

Browse files
authored
Fix expected type of TupleXXL unapply (#16248)
2 parents 292e56f + 9207470 commit 2bc3d23

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2818,7 +2818,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
28182818
val tupleXXLobj = untpd.ref(defn.TupleXXLModule.termRef)
28192819
val app = untpd.cpy.Apply(tree)(tupleXXLobj, elems.map(untpd.TypedSplice(_)))
28202820
.withSpan(tree.span)
2821-
val app1 = typed(app, defn.TupleXXLClass.typeRef)
2821+
val app1 = typed(app, if ctx.mode.is(Mode.Pattern) then pt else defn.TupleXXLClass.typeRef)
28222822
if (ctx.mode.is(Mode.Pattern)) app1
28232823
else {
28242824
val elemTpes = elems.lazyZip(pts).map((elem, pt) =>

tests/run/i16213.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
test(1) // was: ClassCastException: java.lang.Integer cannot be cast to scala.runtime.TupleXXL
4+
5+
def test(any: Any) = any match
6+
case (
7+
_, _, _, _, _, _, _, _, _, _,
8+
_, _, _, _, _, _, _, _, _, _,
9+
_, _, _
10+
) => 23
11+
case _ => -1

0 commit comments

Comments
 (0)