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