4932fa1ddd
This commit support the following case.
Suppose we have such declaration:
fun <T> foo(): T { ... }
Then in code we want to use it like this: `foo() as String`.
But in LV <= 1.1 we have type inference error: "Not enough
information for type parameter `T`". This error happened because we
do not use type from cast as expected type for call.
In this commit we fix this problem and use this type as expected type
in following cases:
- our function has only one type parameter (this can be relaxed later)
- function parameter types and extension receiver type not contains `T`
Also this fix problem with `findViewById`.
Already signature was: `fun findViewById(...): View`
and was used like: `findViewById() as MyView`.
New signature is `fun <T : View> findViewById(...): T`
and old usage was broken because of problem described above
54 lines
2.4 KiB
Plaintext
Vendored
54 lines
2.4 KiB
Plaintext
Vendored
package
|
|
|
|
package a {
|
|
public val xCast: a.X
|
|
public val xCastExplicitType: a.X
|
|
public val xExplicit: a.X
|
|
public val xSafeCastExplicitType: a.X?
|
|
public val yCast: a.Y<kotlin.String>
|
|
public val yExplicit: a.Y<kotlin.String>
|
|
public fun test(/*0*/ t: a.Test): kotlin.Unit
|
|
public fun test2(/*0*/ t: a.Test?): kotlin.Unit
|
|
|
|
public open class Test {
|
|
public constructor Test()
|
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
public open fun </*0*/ T : a.View!> findViewById(/*0*/ id: kotlin.Int): T!
|
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
}
|
|
|
|
public final class TestChild : a.Test {
|
|
public constructor TestChild()
|
|
public final val xCast: a.X
|
|
public final val xExplicit: a.X
|
|
public final val yCast: a.Y<kotlin.String>
|
|
public final val yExplicit: a.Y<kotlin.String>
|
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
public open override /*1*/ /*fake_override*/ fun </*0*/ T : a.View!> findViewById(/*0*/ id: kotlin.Int): T!
|
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
}
|
|
|
|
public open class View {
|
|
public constructor View()
|
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
}
|
|
|
|
public final class X : a.View {
|
|
public constructor X()
|
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
}
|
|
|
|
public final class Y</*0*/ T> : a.View {
|
|
public constructor Y</*0*/ T>()
|
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
}
|
|
}
|