Gabriel Brollo
11/20/2020, 11:50 PMradityagumay
11/20/2020, 11:52 PMGabriel Brollo
11/20/2020, 11:55 PMNikolay Puliaev
11/21/2020, 12:13 AMGabriel Brollo
11/21/2020, 12:13 AMNikolay Puliaev
11/21/2020, 12:14 AMStavFX
11/23/2020, 8:04 PMGabriel Brollo
11/23/2020, 8:09 PMStavFX
11/23/2020, 8:37 PMStavFX
11/23/2020, 8:48 PMfun main() {
val b: Boolean = num() // compiles, but shouldn't
f(num()) // also compiles, but shouldn't
}
fun <T : Number> num(): T = 4 as T
fun f(b: Boolean) = b
The Java equivalent works as expected
void main() {
final Integer n = num(); // Complies
final Boolean b = num(); // Does not compile
f(num()); // Does not compile
}
<T extends Number> T num() { return (T) new Integer(4); }
void f(Boolean b) { }
I guess it’s a Kotlin bugGabriel Brollo
11/23/2020, 10:24 PMGabriel Brollo
11/23/2020, 10:25 PMclass GenericClass<T : Number> {
fun num() = 4 as T
}
Gabriel Brollo
11/23/2020, 10:26 PMGabriel Brollo
11/23/2020, 10:27 PMval b: Boolean = GenericClass<Boolean>().num()
does not compileStavFX
11/23/2020, 10:52 PMGabriel Brollo
11/23/2020, 11:07 PMGabriel Brollo
11/23/2020, 11:09 PM