Fix for KT-10313: ClassCastException with Generics
#KT-10313 Fixed
This commit is contained in:
committed by
Michael Bogdanov
parent
edf6a2142b
commit
0073257841
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun box() : String {
|
||||
val b = Box<Long>(2 * 3)
|
||||
val expected: Long? = 6L
|
||||
return if (b.value == expected) "OK" else "fail"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun box() : String {
|
||||
val b = Box<Long>(x@ (1 + 2))
|
||||
val expected: Long? = 3L
|
||||
return if (b.value == expected) "OK" else "fail"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun box() : String {
|
||||
val b = Box<Long>((-1))
|
||||
val expected: Long? = -1L
|
||||
return if (b.value == expected) "OK" else "fail"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
open class Base<T>(val value: T)
|
||||
class Box(): Base<Long>(-1)
|
||||
|
||||
fun box(): String {
|
||||
val expected: Long? = -1L
|
||||
return if (Box().value == expected) "OK" else "fail"
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun box() : String {
|
||||
val b = Box<Long>(-1)
|
||||
val expected: Long? = -1L
|
||||
return if (b.value == expected) "OK" else "fail"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Box<T>(val value: T)
|
||||
|
||||
fun <T> run(vararg z: T): Box<T> {
|
||||
return Box<T>(z[0])
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = run<Long>(-1, -1, -1)
|
||||
val expected: Long? = -1L
|
||||
return if (b.value == expected) "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user