Skip to content

Overloaded isDefined or get breaks option-less pattern matching #1540

@OlivierBlanvillain

Description

@OlivierBlanvillain

Overloading isDefined or get as in the following example crashes dotc on this assertion:

class Casey1(val a: Int) {
  def isDefined: Boolean = true
  def isDefined(x: Int): Boolean = ???
  def get: Int = a
  def get(x: Int): String = ???
}
object Casey1 { def unapply(a: Casey1) = a }

object Test {
  def main(args: Array[String]): Unit = {
    val c @ Casey1(x) = new Casey1(0)
    assert(x == c.get)
  }
}

Metadata

Metadata

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