Skip to content

Commit

Permalink
Backport "Type desugared transparent inline def unapply call in the…
Browse files Browse the repository at this point in the history
… correct mode" to LTS (#21049)

Backports #20108 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 5, 2024
2 parents 827af90 + 11feb72 commit 66981bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/pos/i20107.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 66981bc

Please sign in to comment.