|
Scala example source code file (t3833.scala)
The Scala t3833.scala source code
object Main {
def mkArray[T <: A](atype: Int) :T#AType = {
(atype match {
case 1 =>
new Array[Int](10)
// Decompiled code: return (Object[])new int[10];
case 2 =>
new Array[Float](10)
}).asInstanceOf[T#AType]
}
def main(args: Array[String]) {
println(mkArray[I](1))
//java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
}
}
trait A {
type AType <: AnyRef
}
trait I extends A {
type AType = Array[Int]
}
trait F extends A {
type AType = Array[Float]
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala t3833.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.