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
Inappropriate type is inferred for an extracted value #8045
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8045?orig=1 |
@retronym said: |
@retronym said: |
@retronym said: object Test extends App {
class Number(i: Int)
object UnliftNumber {
def unapply(t: Any): Option[Number] = t match {
case i: Int => Some(new Number(i))
case _ => None
}
}
def eval(expr: Any): Option[Number] = expr match {
case UnliftNumber(n) => Some(n)
case _ => None
}
println(eval(1))
} This code seems culpable: /** If this is a case class, the case field accessors (which may be an empty list.)
* Otherwise, if there are any product selectors, that list.
* Otherwise, a list containing only the type itself.
*/
def typesOfSelectorsOrSelf(tp: Type): List[Type] = (
if (tp.typeSymbol.isCase)
typesOfCaseAccessors(tp)
else typesOfSelectors(tp) match {
case Nil => tp :: Nil
case tps => tps
}
) |
@paulp said: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we the return type of eval is ommited the code compiles and runs just fine:
The text was updated successfully, but these errors were encountered: