-
Notifications
You must be signed in to change notification settings - Fork 21
spurious unchecked warning when an abstract type is accompanied by a same-named extractor #5503
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5503?orig=1 |
@retronym said: This gives the same warning (although I'm not certain it's a faithful minimization of the one above). trait A {
type MethodType
val MethodType: MethodTypeExtractor = null
abstract class MethodTypeExtractor {
def unapply(tpe: MethodType): Option[(Any, Any)]
}
}
object Test {
val a: A = null
def foo(tpe: A#MethodType) = tpe match {
case a.MethodType(_, _) =>
}
} Switching to |
@retronym said (edited on Feb 19, 2012 4:32:10 PM UTC): trait A {
type Type
type MethodType <: Type
val MethodType: MethodTypeExtractor = null
abstract class MethodTypeExtractor {
def unapply(tpe: MethodType): Option[(Any, Any)]
}
}
object Test {
val a: A = null
def foo(tpe: a.Type) = tpe match {
case a.MethodType(_, _) =>
}
} Who is at fault: compiler or library? |
@adriaanm said: |
@retronym said: ./build/quick/bin/scala -Yvirtpatmat -unchecked
Welcome to Scala version 2.10.0-M1-0374-g526c92848a-2012-02-19 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import reflect.mirror._import reflect.mirror._
scala> object A { def foo(t: Tree) = t.tpe match { case MethodType(_, _) => 0 }}
<console>:10: warning: abstract type reflect.mirror.MethodType in type pattern reflect.mirror.MethodType is unchecked since it is eliminated by erasure
object A { def foo(t: Tree) = t.tpe match { case MethodType(_, _) => 0 }}
^
defined module A
scala> :paste
// Entering paste mode (ctrl-D to finish)
trait A {
type Type
type MethodType <: Type
val MethodType: MethodTypeExtractor = null
abstract class MethodTypeExtractor {
def unapply(tpe: MethodType): Option[(Any, Any)]
}
}
object Test {
val a: A = null
def foo(tpe: a.Type) = tpe match {
case a.MethodType(_, _) =>
}
}
// Exiting paste mode, now interpreting.
<console>:25: warning: abstract type Test.a.MethodType in type pattern Test.a.MethodType is unchecked since it is eliminated by erasure
case a.MethodType(_, _) =>
^ |
@SethTisue said: |
@adriaanm said: |
@retronym said: |
This pattern is used in
scala.reflect._
. I haven't managed to produce a standalone reproduction.Inspection of the generated code shows that the extractor is being used.
The text was updated successfully, but these errors were encountered: