Skip to content

Cannot recude inline match if pattern condition is private #22300

Closed
@t9dupuy

Description

@t9dupuy

Compiler version

3.5.2

Minimized code

class Foo:

  inline def inlineMatch[T]: String =
    inline compiletime.erasedValue[T] match
      case _: EmptyTuple               => ""
      case _: (h *: _) if checkType[h] => ""

  private inline def checkType[T]: Boolean =
    inline compiletime.erasedValue[T] match
      case _: Int => true
      case _      => false

val foo = Foo()

foo.inlineMatch[(Int, Boolean)] // Error

Output

[error]    |cannot reduce inline match with
[error]    | scrutinee:  compiletime.package$package.erasedValue[(Int, Boolean)] : (Int, Boolean)
[error]    | patterns :  case _:EmptyTuple
[error]    |             case _:*:[h @ _, _ @  >: Nothing <: Any] if Foo_this.asInstanceOf[Foo].checkType[h]

Expectation

If this is indeed not supposed to work, I would expect a clearer error message.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions