|
Scala example source code file (bug412.scala)
The Scala bug412.scala source code
object Magic {
abstract class A[T1,T2]() {
trait C { type T; }
trait C1 extends C { type T = T1; }
trait C2 extends C { type T <: T2; }
type CX >: Null;
val c: CX with C2 = null;
def castA(x: c.T): T2 = x;
}
class B[T1,T2] extends A[T1,T2]() {
type CX = C1;
def castB(x: T1): T2 = castA(x);
}
def cast[T1,T2](v: T1): T2 =
new B[T1,T2]().castB(v)
}
object Test {
def main(args: Array[String]): Unit = {
Magic.cast[String,Exception]("xyz").printStackTrace();
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala bug412.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.