Skip to content
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

uncheckable warning for unapply with intersection including abstract type #6282

Closed
scabug opened this issue Aug 25, 2012 · 3 comments
Closed

Comments

@scabug
Copy link

scabug commented Aug 25, 2012

import scala.reflect.runtime.universe._

object Test {
  object Bippy {
    def unapply(x: Apply with Select) = Some(x.qualifier)
  }
  def main(args: Array[String]): Unit = {
    val x = Apply(EmptyTree, Nil)
    // Direct invocation correctly disallowed
    // Bippy.unapply(x)
    //
    // Pattern matcher allows, unsoundly
    x match { case Bippy(_) => () }
  }
}
// and...
//
// java.lang.ClassCastException: scala.reflect.internal.Trees$Apply cannot be cast to scala.reflect.api.Trees$SelectApi
//   at Test$Bippy$.unapply(a.scala:5)
//   at Test$.main(a.scala:13)
//   at Test.main(a.scala)
@scabug
Copy link
Author

scabug commented Aug 25, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6282?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Oct 20, 2012

@paulp said:
Putting 2+2 together, I keep running across this code and thinking "how can this be right?" but I forgot I'd opened this bug. I can't follow the logic at a glance, but this unlikely treatment of intersection types feels relevant.

// if at least one of the types in an intersection is checkable, use the checkable ones
// this avoids problems as in run/matchonseq.scala, where the expected type is `Coll with scala.collection.SeqLike`
// Coll is an abstract type, but SeqLike of course is not
case RefinedType(ps, _) if ps.length > 1 && (ps exists infer.isCheckable) =>
  None

@SethTisue
Copy link
Member

fixed as of 2.12.4

@SethTisue SethTisue removed this from the Backlog milestone Mar 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants