Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OlivierBlanvillain opened this issue Sep 26, 2016 · 2 comments
Closed
Assignees

Comments

@OlivierBlanvillain
Copy link
Contributor

OlivierBlanvillain commented Sep 26, 2016

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)
  }
}
@odersky
Copy link
Contributor

odersky commented Oct 14, 2016

It actually fails before, if one does a -Ycheck:pat. @liufengyun or @DarkDimius can one of you have a look?

*** error while checking i1540.scala after phase patternMatcher ***

exception occurred while compiling i1540.scala
Exception in thread "main" java.lang.UnsupportedOperationException: multi-denotation with alternatives List(method isDefined, method isDefined) does not implement operation info
at dotty.tools.dotc.core.Denotations$MultiDenotation.multiHasNot(Denotations.scala:604)
at dotty.tools.dotc.core.Denotations$MultiDenotation.infoOrCompleter(Denotations.scala:565)
at dotty.tools.dotc.core.Denotations$MultiDenotation.info(Denotations.scala:566)
at dotty.tools.dotc.core.Denotations$MultiDenotation.info(Denotations.scala:564)

@liufengyun
Copy link
Contributor

OK, I'll have look at it.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Oct 14, 2016
liufengyun added a commit to dotty-staging/dotty that referenced this issue Oct 14, 2016
liufengyun added a commit to dotty-staging/dotty that referenced this issue Oct 14, 2016
liufengyun added a commit to dotty-staging/dotty that referenced this issue Oct 14, 2016
odersky added a commit that referenced this issue Oct 14, 2016
Fix #1540: overloaded get and isDefined in option-less patmat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants