Skip to content

Probably a false positive warning for type tests  #16259

Closed as not planned
Closed as not planned
@WojciechMazur

Description

@WojciechMazur

Type test for locally defined classes (eg. within method) ends up with a warning. Not sure if it's a false negative positive introduced via regression or an improvement.

Compiler version

3.2.1

Minimized code

@main def Test = {
  class A(private val x: Int) {
    override def equals(that: Any): Boolean = that match {
      case that: A => this.x == that.x
      case _       => false
    }
  }
}

Output

Compiling project (Scala 3.2.1, JVM)
[warn] ./sandbox/src/main/scala/Test.scala:5:12: the type test for A cannot be checked at runtime
[warn]       case that: A => this.x == that.x

Expectation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions