[NI] Dont' add trivial constraints with Nothing from incorporation
#KT-24490 Fixed #KT-26816 Fixed
This commit is contained in:
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Out<out T>(val o: T)
|
||||
|
||||
interface Base
|
||||
class Inv<K> : Base
|
||||
|
||||
fun <S> select(x: S, y: S): S = x
|
||||
|
||||
fun test(a1: Inv<Number>, a2: Inv<Nothing?>): Out<Base> {
|
||||
return select(Out(a1), Out(a2))
|
||||
}
|
||||
compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.txt
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S> select(/*0*/ x: S, /*1*/ y: S): S
|
||||
public fun test(/*0*/ a1: Inv<kotlin.Number>, /*1*/ a2: Inv<kotlin.Nothing?>): Out<Base>
|
||||
|
||||
public interface Base {
|
||||
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 Inv</*0*/ K> : Base {
|
||||
public constructor Inv</*0*/ K>()
|
||||
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 Out</*0*/ out T> {
|
||||
public constructor Out</*0*/ out T>(/*0*/ o: T)
|
||||
public final val o: 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
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Simple
|
||||
|
||||
fun test(s: Simple?): Simple? {
|
||||
myRun {
|
||||
s?.let { return it }
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
inline fun <R> myRun(block: () -> R): R = TODO()
|
||||
inline fun <K, V> K.let(block: (K) -> V): V = TODO()
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ R> myRun(/*0*/ block: () -> R): R
|
||||
public fun test(/*0*/ s: Simple?): Simple?
|
||||
public inline fun </*0*/ K, /*1*/ V> K.let(/*0*/ block: (K) -> V): V
|
||||
|
||||
public final class Simple {
|
||||
public constructor Simple()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun <T> bar(i: T): T = i
|
||||
fun foo(i: Int) = i
|
||||
|
||||
fun dontRun(body: () -> Unit) = Unit
|
||||
|
||||
class Case1 {
|
||||
fun test() {
|
||||
dontRun { val x = bar(bar { -> bar { -> 2} }) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar(/*0*/ i: T): T
|
||||
public fun dontRun(/*0*/ body: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ i: kotlin.Int): kotlin.Int
|
||||
|
||||
public final class Case1 {
|
||||
public constructor Case1()
|
||||
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 final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
fun <K> id1(k: K): K = k
|
||||
fun <V> id2(v: V): V = v
|
||||
|
||||
fun test() {
|
||||
id1 {
|
||||
id2 {
|
||||
3
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> id1(/*0*/ k: K): K
|
||||
public fun </*0*/ V> id2(/*0*/ v: V): V
|
||||
public fun test(): kotlin.Unit
|
||||
Reference in New Issue
Block a user