KT-2505 Type mismatch: inferred type is T but T was expected
#KT-2505
This commit is contained in:
@@ -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?
|
||||
}
|
||||
Reference in New Issue
Block a user