From 11feb72416e4f6a41410fbf712036080ae6669c1 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 5 Apr 2024 00:38:35 +0200 Subject: [PATCH] Type desugared `transparent inline def unapply` call in the correct mode This regressed in 5648f12fb136886da4e1f00695627cbfde90ee9e. Fixes #20107. [Cherry-picked 5672caa1391d0efdc4ebc9e4f2cac087a46ea8fe] --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 3 ++- tests/pos/i20107.scala | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i20107.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 73d27d3ee1e7..73186b6e36fc 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1413,7 +1413,8 @@ trait Applications extends Compatibility { report.error(em"Structural unapply is not supported", unapplyFn.srcPos) (unapplyFn, unapplyAppCall) case Apply(fn, `dummyArg` :: Nil) => - val inlinedUnapplyFn = Inlines.inlinedUnapplyFun(fn) + val inlinedUnapplyFn = withoutMode(Mode.Pattern): + Inlines.inlinedUnapplyFun(fn) (inlinedUnapplyFn, inlinedUnapplyFn.appliedToArgs(`dummyArg` :: Nil)) case Apply(fn, args) => val (fn1, app) = rec(fn) diff --git a/tests/pos/i20107.scala b/tests/pos/i20107.scala new file mode 100644 index 000000000000..80ce350cf29d --- /dev/null +++ b/tests/pos/i20107.scala @@ -0,0 +1,6 @@ +object foo: + transparent inline def unapply[F](e: F): Option[F] = Some(e.asInstanceOf[F]) + +class A: + def test(x: Int) = x match + case foo(e) => e