Skip to content

Commit 66981bc

Browse files
Backport "Type desugared transparent inline def unapply call in the correct mode" to LTS (#21049)
Backports #20108 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 827af90 + 11feb72 commit 66981bc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,8 @@ trait Applications extends Compatibility {
14131413
report.error(em"Structural unapply is not supported", unapplyFn.srcPos)
14141414
(unapplyFn, unapplyAppCall)
14151415
case Apply(fn, `dummyArg` :: Nil) =>
1416-
val inlinedUnapplyFn = Inlines.inlinedUnapplyFun(fn)
1416+
val inlinedUnapplyFn = withoutMode(Mode.Pattern):
1417+
Inlines.inlinedUnapplyFun(fn)
14171418
(inlinedUnapplyFn, inlinedUnapplyFn.appliedToArgs(`dummyArg` :: Nil))
14181419
case Apply(fn, args) =>
14191420
val (fn1, app) = rec(fn)

tests/pos/i20107.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object foo:
2+
transparent inline def unapply[F](e: F): Option[F] = Some(e.asInstanceOf[F])
3+
4+
class A:
5+
def test(x: Int) = x match
6+
case foo(e) => e

0 commit comments

Comments
 (0)