KT-2505 Type mismatch: inferred type is T but T was expected

#KT-2505
This commit is contained in:
Svetlana Isakova
2012-08-07 18:08:52 +04:00
parent 9102622e02
commit 70c5a5ba9e
7 changed files with 83 additions and 33 deletions
@@ -0,0 +1,15 @@
package d
fun <T> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? {
return null
}
fun <T> joinT(<!UNUSED_PARAMETER!>x<!>: Any, <!UNUSED_PARAMETER!>y<!>: T): T? {
return null
}
fun test() {
val x2 = joinT(<!NON_VARARG_SPREAD!>*<!>1, "2")
x2 : String?
}
@@ -0,0 +1,20 @@
//KT-2505 Type mismatch: inferred type is T but T was expected
package a
trait MyType {}
class MyClass<T> : MyType {}
public open class HttpResponse() {
public open fun parseAs<T>(dataClass : MyClass<T>) : T? {
return null
}
public open fun parseAs(dataType : MyType) : Any? {
return null
}
}
fun test<R> (httpResponse: HttpResponse, rtype: MyClass<R>) {
val res = httpResponse.parseAs( rtype )
res : R? //type mismatch: required R?, found T?
}