Skip to content

Commit 4ea930b

Browse files
Type desugared transparent inline def unapply call in the correct mode (#20108)
This regressed in 5648f12. Fixes #20107.
2 parents 1e8a653 + 5672caa commit 4ea930b

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
@@ -1430,7 +1430,8 @@ trait Applications extends Compatibility {
14301430
report.error(em"Structural unapply is not supported", unapplyFn.srcPos)
14311431
(unapplyFn, unapplyAppCall)
14321432
case Apply(fn, `dummyArg` :: Nil) =>
1433-
val inlinedUnapplyFn = Inlines.inlinedUnapplyFun(fn)
1433+
val inlinedUnapplyFn = withoutMode(Mode.Pattern):
1434+
Inlines.inlinedUnapplyFun(fn)
14341435
(inlinedUnapplyFn, inlinedUnapplyFn.appliedToArgs(`dummyArg` :: Nil))
14351436
case Apply(fn, args) =>
14361437
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)