Skip to content

Regression in 3.4.1: spurious error when using transparent inline def unapply #20107

Closed
@smarter

Description

@smarter

Compiler version

3.4.1 (Worked in 3.3, 3.4.0, broke in #19380)

Minimized code

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

Output

```-- Error: foo.scala:6:9 --------------------------------------------
6 |    case foo(e) => e
  |         ^^^
  |         invalid pattern
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from foo.scala:2
2 |     transparent inline def unapply[F](e: F): Option[F] = Some(e.asInstanceOf[F])
  |                                                               ^^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------
-- [E107] Syntax Error: foo.scala:6:12 -----------------------------
6 |    case foo(e) => e
  |         ^^^^^^
  |         Wrong number of argument patterns for foo; expected: ()
  |
  | longer explanation available when compiling with `-explain`
-- [E006] Not Found Error: foo.scala:6:19 --------------------------
6 |    case foo(e) => e
  |                   ^
  |                   Not found: e
  |
  | longer explanation available when compiling with `-explain`

Expectation

This should work as it used to before #19380 (it still works without transparent).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions