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

uncheckable warning for unapply with intersection including abstract type #6282

scabug opened this issue Aug 25, 2012 · 3 comments

Comments

@scabug
Copy link

@scabug 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 25, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug 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

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Mar 3, 2018

fixed as of 2.12.4

@SethTisue SethTisue closed this Mar 3, 2018
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.