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
bogus "eliminated by erasure" warning #6791
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6791?orig=1 |
Stephen Compall (s11001001) said (edited on Dec 10, 2013 4:36:13 AM UTC): package test.sixtysevenninetyone
object UCs {
abstract class Ooh[+A] extends Tuple1[Unit](()) {
val phantom: A
}
def ooh[A](a: => A): Ooh[A] = new Ooh[A]{lazy val phantom = a}
def uc1[A, B]: A =:= B = {
val aa = ooh(implicitly[A =:= A])
val no = ooh(???)
aa match {case ano: no.type => ano.phantom}
}
import collection.mutable.Buffer
def uc2[A, B]: A =:= B = {
val es = Buffer[A =:= B]()
val gs = Buffer[A =:= A]()
(gs: Buffer[_]) match {
case es: es.type => gs += implicitly; es.head
}
}
def oops = (uc1[String, ClassLoader]("twenty-one"),
uc2[String, ClassLoader]("forty-two"))
} Yielding session (excluding uninteresting warnings about subclassing tuple; the basic principle of getting [warn] 6791.scala:12: non-variable type argument Nothing in type pattern test.sixtysevenninetyone.UCs.Ooh[Nothing] is unchecked since it is eliminated by erasure
[warn] aa match {case ano: no.type => ano.phantom}
[warn] ^
[warn] 6791.scala:21: non-variable type argument =:=[A,B] in type pattern scala.collection.mutable.Buffer[=:=[A,B]] is unchecked since it is eliminated by erasure
[warn] case es: es.type => gs += implicitly; es.head
[warn] ^
[warn] four warnings found
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.0-M7 (OpenJDK 64-Bit Server VM, Java 1.7.0_45).
Type in expressions to have them evaluated.
Type :help for more information.
scala> test.sixtysevenninetyone.UCs.oops
res0: (ClassLoader, ClassLoader) = (twenty-one,forty-two) Also as in 2.10.3. |
@paulp said: There is definitely grave unsoundness related to trusting equals - #1503 is the main ticket - this is not that. See #4577, which I marked as a "blocker" at some point, ha ha. |
@adriaanm said: |
This program should not warn about the abstract type being eliminated by erasure because we are testing for a more specific type than the one which is eliminated by erasure - it is a test which we can perform.
The text was updated successfully, but these errors were encountered: