[NI] Discriminate Nothing? result type from nullability constraints
Nullability constraints should not be chosen when proper argument constraints for variables in contravariant position present. ^KT-32106 Fixed ^KT-33166 Fixed
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class Cls
|
||||
|
||||
abstract class In<in I>
|
||||
class SubIn : In<Cls?>()
|
||||
|
||||
inline fun <reified T : Cls> materialize(): T? = TODO()
|
||||
|
||||
fun <D> transform(transformer: In<D>, data: D): Unit = TODO()
|
||||
|
||||
fun test(subIn: SubIn) {
|
||||
transform(subIn, materialize()) // D should be inferred to Cls?, not Nothing?
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class Cls
|
||||
|
||||
abstract class In<in I>
|
||||
class SubIn : In<Cls?>()
|
||||
|
||||
inline fun <reified T : Cls> materialize(): T? = TODO()
|
||||
|
||||
fun <D> transform(transformer: In<D>, data: D): Unit = TODO()
|
||||
|
||||
fun test(subIn: SubIn) {
|
||||
transform(subIn, materialize()) // D should be inferred to Cls?, not Nothing?
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ reified T : Cls> materialize(): T?
|
||||
public fun test(/*0*/ subIn: SubIn): kotlin.Unit
|
||||
public fun </*0*/ D> transform(/*0*/ transformer: In<D>, /*1*/ data: D): kotlin.Unit
|
||||
|
||||
public open class Cls {
|
||||
public constructor Cls()
|
||||
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 abstract class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in 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 SubIn : In<Cls?> {
|
||||
public constructor SubIn()
|
||||
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
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun <K> id(arg: K): K = arg
|
||||
|
||||
val v = id(null)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun <K> id(arg: K): K = arg
|
||||
|
||||
val v = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>id(null)<!>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public val v: kotlin.Nothing?
|
||||
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||
Reference in New Issue
Block a user