KT-353 Generic type argument inference sometimes doesn't work
KT-459 Type argument inference fails when class names are fully qualified
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// KT-459 Type argument inference fails when class names are fully qualified
|
||||
|
||||
fun test() {
|
||||
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
@@ -0,0 +1,32 @@
|
||||
// KT-353 Generic type argument inference sometimes doesn't work
|
||||
|
||||
trait A {
|
||||
fun <T> gen() : T
|
||||
}
|
||||
|
||||
fun foo(a: A) {
|
||||
val g : fun() : Unit = {
|
||||
a.gen() //it works: Unit is derived
|
||||
}
|
||||
|
||||
val u: Unit = a.gen() //type mismatch, but Unit can be derived
|
||||
|
||||
if (true) {
|
||||
a.gen() //it works: Unit is derived
|
||||
}
|
||||
|
||||
val b : fun() : Unit = {
|
||||
if (true) {
|
||||
a.gen() //type mismatch, but Unit can be derived
|
||||
}
|
||||
else {
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
val f : fun() : Int = { () : Int =>
|
||||
a.gen() //type mismatch, but Int can be derived
|
||||
}
|
||||
|
||||
a.gen() //it works: Unit is derived
|
||||
}
|
||||
Reference in New Issue
Block a user