Skip to content

pattern matching does not wlways check outer #2

Closed
@scabug

Description

@scabug

Aladdin: [http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1159 bug 1159]

== Code ==

class Outer {
  case class Foo(x: int, y: int) {
    override def equals(other: Any) = other match {
      case Outer.this.Foo(`x`, `y`) => true
      case _ => false
    }
  }
}

object Test extends Application {
  val o1 = new Outer
  val o2 = new Outer
  val x: Any = o1.Foo(1, 2)
  val y: Any = o2.Foo(1, 2)
  println(x equals y)
  x match {
    case o2.Foo(x, y) => println("error 1")
    case o1.Foo(x, y) => println("OK")
    case _ => println("error 2")
  }
}

== What happened ==

true
OK

== What expected ==

false
OK

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions