Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix expected type of TupleXXL unapply #16248

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2824,7 +2824,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
val tupleXXLobj = untpd.ref(defn.TupleXXLModule.termRef)
val app = untpd.cpy.Apply(tree)(tupleXXLobj, elems.map(untpd.TypedSplice(_)))
.withSpan(tree.span)
val app1 = typed(app, defn.TupleXXLClass.typeRef)
val app1 = typed(app, if ctx.mode.is(Mode.Pattern) then pt else defn.TupleXXLClass.typeRef)
if (ctx.mode.is(Mode.Pattern)) app1
else {
val elemTpes = elems.lazyZip(pts).map((elem, pt) =>
Expand Down
11 changes: 11 additions & 0 deletions tests/run/i16213.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Test:
def main(args: Array[String]): Unit =
test(1) // was: ClassCastException: java.lang.Integer cannot be cast to scala.runtime.TupleXXL

def test(any: Any) = any match
case (
_, _, _, _, _, _, _, _, _, _,
_, _, _, _, _, _, _, _, _, _,
_, _, _
) => 23
case _ => -1