Unsoundness due to `erased`
See original GitHub issueobject App {
def coerce[U, V](u: U): V = {
trait X { type R >: U }
trait Y { type R = V }
class T[A <: X](ghost val a: A)(val value: a.R)
object O { lazy val x : Y & X = ??? }
val a = new T[Y & X](O.x)(u)
a.value
}
def main(args: Array[String]): Unit = {
val x: Int = coerce[String, Int]("a")
println(x + 1)
}
}
//////////////////////////////////////////////////////////////
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:101)
at App$.main(HelloWorld.scala:15)
at App.main(HelloWorld.scala)
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
[TYPES] Java generics unsoundness?
To avoid the method clash we could use name mangling, i.e., including the types of the type-erased arguments in the name of the...
Read more >Unsoundness in owning_ref : r/rust - Reddit
158 votes, 42 comments. 212K subscribers in the rust community. A place for all things related to the Rust programming language—an ...
Read more >Erased Tapes on Instagram: “If you're down in Brighton for the ...
405 Likes, 5 Comments - Erased Tapes (@erasedtapesrecords) on Instagram: “If you're down in Brighton for the @GreatEscapeFest this weekend, ...
Read more >How LGBTQ Victims Were Erased From Holocaust History | Time
"For the queer survivors of Nazi oppression, 1945 did not bring about any kind of liberation," argues scholar Andrea Carlo.
Read more >Java and Scala's Type Systems are Unsound - Hacker News
It was unsound from the first version with respect to arrays. If B is a subtype of A, then Java allows you to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately, this makes erased vals practically useless. We should backout this fix and mark erased vals as unrealizable instead. erased is really the same as lazy in this respect. Either implies that the right-hand side will be constructed.
@alexknvl I renamed
unused
toghost
throughout the issue because of #4061.