Skip to content

Incorrect "the type test for A cannot be checked at runtime because it's a local class" warning #20741

Open
@uosis

Description

@uosis

Compiler version

Tested 3.4.2, 3.4.1, 3.4.0, 3.3.3, all with the same issue.

2.13.14 works fine and does not emit warning.

Minimized example

def f: Unit = {
  class A {
    override def equals(x: Any): Boolean = x match {
      case a: A => true
      case _ => false
    }
  }
}

Output Error/Warning message

1 warning found
def f: Unit
-- [E092] Pattern Match Unchecked Warning: -------------------------------------
4 |      case a: A => true
  |           ^
  |the type test for A cannot be checked at runtime because it's a local class
  |
  | longer explanation available when compiling with `-explain`

Why this Error/Warning was not helpful

The code seems correct and runs correctly, i.e. the type test executes correctly at runtime, contradictory to the warning.

Suggested improvement

No warning should be emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions