Fix inference when captured type is used as a lambda parameter type
Use lower approximation bound to obtain acceptable types for lambda parameters those types depend on captured type #KT-12238 Fixed #KT-10627 Fixed
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class B<E>
|
||||
|
||||
fun <T> B<T>.foo(f: (T) -> Unit) {}
|
||||
fun <T> B<T>.bar(f: (T, T) -> Unit, g: (T, T) -> Unit) {}
|
||||
|
||||
fun number(x: Number) {}
|
||||
fun Number.foobar() {}
|
||||
|
||||
fun test(b: B<out Number>) {
|
||||
b.foo {
|
||||
it checkType { _<Number>() }
|
||||
it.toInt()
|
||||
}
|
||||
|
||||
b.foo { x ->
|
||||
x checkType { _<Number>() }
|
||||
x.toInt()
|
||||
}
|
||||
|
||||
b.bar({ x, y ->
|
||||
x checkType { _<Number>() }
|
||||
y checkType { _<Number>() }
|
||||
x.toInt()
|
||||
y.toInt()
|
||||
}) { u, w ->
|
||||
u checkType { _<Number>() }
|
||||
w checkType { _<Number>() }
|
||||
|
||||
u.toInt()
|
||||
w.toInt()
|
||||
}
|
||||
|
||||
b.foo(::number)
|
||||
b.foo(Number::foobar)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun number(/*0*/ x: kotlin.Number): kotlin.Unit
|
||||
public fun test(/*0*/ b: B<out kotlin.Number>): kotlin.Unit
|
||||
public fun </*0*/ T> B<T>.bar(/*0*/ f: (T, T) -> kotlin.Unit, /*1*/ g: (T, T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T> B<T>.foo(/*0*/ f: (T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun kotlin.Number.foobar(): kotlin.Unit
|
||||
|
||||
public final class B</*0*/ E> {
|
||||
public constructor B</*0*/ E>()
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user