Approximate definitely not-null types for type parameter's types if they are already not-null (has not-null upper bounds)

^KT-44440 Fixed
This commit is contained in:
Victor Petukhov
2021-01-21 14:57:28 +03:00
parent f2c1608c2b
commit f06a5321a6
12 changed files with 144 additions and 45 deletions
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_EXPRESSION
interface I
fun consume(x: WrapperFactory<Wrapper<I>>) {}
fun test(x: I) {
val y = foo(x)
<!DEBUG_INFO_EXPRESSION_TYPE("WrapperFactory<Wrapper<I>>")!>y<!>
consume(y)
}
fun <CX: I> foo(
x: CX,
fn1: (CX) -> Unit = {},
fn2: (CX?) -> Unit = {}
) = WrapperFactory { Wrapper(fn1, fn2) }
class WrapperFactory<W>(val creator: () -> W)
class Wrapper<in CX2>(val fn1: (CX2) -> Unit, val fn2: (CX2?) -> Unit)
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_EXPRESSION
interface I
fun consume(x: WrapperFactory<Wrapper<I>>) {}
fun test(x: I) {
val y = foo(x)
<!DEBUG_INFO_EXPRESSION_TYPE("WrapperFactory<Wrapper<I>>")!>y<!>
consume(y)
}
fun <CX: I> foo(
x: CX,
fn1: (CX) -> Unit = {},
fn2: (CX?) -> Unit = {}
) = WrapperFactory { Wrapper(fn1, fn2) }
class WrapperFactory<W>(val creator: () -> W)
class Wrapper<in CX2>(val fn1: (CX2) -> Unit, val fn2: (CX2?) -> Unit)
@@ -0,0 +1,28 @@
package
public fun consume(/*0*/ x: WrapperFactory<Wrapper<I>>): kotlin.Unit
public fun </*0*/ CX : I> foo(/*0*/ x: CX, /*1*/ fn1: (CX) -> kotlin.Unit = ..., /*2*/ fn2: (CX?) -> kotlin.Unit = ...): WrapperFactory<Wrapper<CX>>
public fun test(/*0*/ x: I): kotlin.Unit
public interface I {
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 Wrapper</*0*/ in CX2> {
public constructor Wrapper</*0*/ in CX2>(/*0*/ fn1: (CX2) -> kotlin.Unit, /*1*/ fn2: (CX2?) -> kotlin.Unit)
public final val fn1: (CX2) -> kotlin.Unit
public final val fn2: (CX2?) -> kotlin.Unit
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 WrapperFactory</*0*/ W> {
public constructor WrapperFactory</*0*/ W>(/*0*/ creator: () -> W)
public final val creator: () -> W
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
}