New J2K: separate nullability inference from common one & nullability bug fixes
It will be needed for structure mutability inference #KT-21467 fixed #KT-32609 fixed #KT-32572 fixed #KT-24677 fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/Array</*T1@*/Int> = arrayOf</*T0@*/Int>()/*Array<T0@Int>*/
|
||||
val y: /*T4@*/Array</*T3@*/Int> = x/*T2@Array<T1@Int>*/
|
||||
}
|
||||
|
||||
//T1 := T0 due to 'INITIALIZER'
|
||||
//T3 := T1 due to 'INITIALIZER'
|
||||
//T2 <: T4 due to 'INITIALIZER'
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
fun foo() {
|
||||
val x: /*T5@*/Array</*T4@*/Array</*T3@*/Int>> =
|
||||
Array</*T2@*/Array</*T1@*/Int>>(1/*LIT*/, {
|
||||
arrayOf</*T0@*/Int>(2/*LIT*/)/*Array<T0@Int>*/
|
||||
}/*Function0<Int, T6@Array<T7@Int>>*/
|
||||
)/*Array<T2@Array<T1@Int>>*/
|
||||
}
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'PARAMETER'
|
||||
//T7 := T0 due to 'RETURN'
|
||||
//T1 := T7 due to 'PARAMETER'
|
||||
//T6 <: T2 due to 'PARAMETER'
|
||||
//T3 := T1 due to 'INITIALIZER'
|
||||
//T4 := T2 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,12 @@
|
||||
class X<T> {
|
||||
fun x(): /*T1@*/List</*T0@*/T> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun y() {
|
||||
val a: /*T3@*/List</*T2@*/T> = x()/*T1@List<T0@T>*/
|
||||
}
|
||||
}
|
||||
|
||||
//T0 <: T2 due to 'INITIALIZER'
|
||||
//T1 <: T3 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,9 @@
|
||||
fun test() {
|
||||
foo</*T1@*/Int>(
|
||||
listOf</*T0@*/Int>()/*List<T0@Int>*/
|
||||
)
|
||||
}
|
||||
|
||||
fun <T> foo (x: /*T3@*/List</*T2@*/T>) {}
|
||||
|
||||
//T0 <: T1 due to 'PARAMETER'
|
||||
@@ -0,0 +1,15 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/X</*T1@*/Int> = X</*T0@*/Int>(10/*LIT*/)/*X<T0@Int>*/
|
||||
val x: /*T5@*/X</*T4@*/Int> = X</*T3@*/Int>(10/*LIT*/, 20/*LIT*/)/*X<T3@Int>*/
|
||||
}
|
||||
|
||||
class X<T>(x: /*T6@*/T) {
|
||||
constructor(x: /*T7@*/T, y: /*T8@*/Int): this(x/*T7@T*/)
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'PARAMETER'
|
||||
//T1 := T0 due to 'INITIALIZER'
|
||||
//LOWER <: T3 due to 'PARAMETER'
|
||||
//LOWER <: T8 due to 'PARAMETER'
|
||||
//T4 := T3 due to 'INITIALIZER'
|
||||
//T7 <: T6 due to 'PARAMETER'
|
||||
@@ -0,0 +1,5 @@
|
||||
class X<T>(x: /*T0@*/T) {
|
||||
constructor(x: /*T1@*/T, y: /*T2@*/Int): this(x/*T1@T*/)
|
||||
}
|
||||
|
||||
//T1 <: T0 due to 'PARAMETER'
|
||||
@@ -0,0 +1,14 @@
|
||||
fun test() {
|
||||
val x: /*T4@*/Array</*T3@*/Array</*T2@*/Int>> = arrayOf</*T1@*/Array</*T0@*/Int>>()/*Array<T1@Array<T0@Int>>*/
|
||||
val y: /*T6@*/Array</*T5@*/Int> = x/*T4@Array<T3@Array<T2@Int>>*/.get(0/*LIT*/)/*T3@Array<T2@Int>*/
|
||||
val z: /*T7@*/Int = y/*T6@Array<T5@Int>*/.get(0/*LIT*/)/*T5@Int*/
|
||||
}
|
||||
|
||||
//T2 := T0 due to 'INITIALIZER'
|
||||
//T3 := T1 due to 'INITIALIZER'
|
||||
//T2 := T2 due to 'RECEIVER_PARAMETER'
|
||||
//T3 := T3 due to 'RECEIVER_PARAMETER'
|
||||
//T5 := T2 due to 'INITIALIZER'
|
||||
//T3 <: T6 due to 'INITIALIZER'
|
||||
//T5 := T5 due to 'RECEIVER_PARAMETER'
|
||||
//T5 <: T7 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,14 @@
|
||||
fun test() {
|
||||
val x: /*T4@*/List</*T3@*/List</*T2@*/Int>> = listOf</*T1@*/List</*T0@*/Int>>()/*List<T1@List<T0@Int>>*/
|
||||
val y: /*T6@*/List</*T5@*/Int> = x/*T4@List<T3@List<T2@Int>>*/.get(0/*LIT*/)/*T3@List<T2@Int>*/
|
||||
val z: /*T7@*/Int = y/*T6@List<T5@Int>*/.get(0/*LIT*/)/*T5@Int*/
|
||||
}
|
||||
|
||||
//T0 <: T2 due to 'INITIALIZER'
|
||||
//T1 <: T3 due to 'INITIALIZER'
|
||||
//T2 <: T2 due to 'RECEIVER_PARAMETER'
|
||||
//T3 <: T3 due to 'RECEIVER_PARAMETER'
|
||||
//T2 <: T5 due to 'INITIALIZER'
|
||||
//T3 <: T6 due to 'INITIALIZER'
|
||||
//T5 <: T5 due to 'RECEIVER_PARAMETER'
|
||||
//T5 <: T7 due to 'INITIALIZER'
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/List</*T1@*/String> = listOf</*T0@*/String>()/*List<T0@String>*/
|
||||
for (y: /*T3@*/String in x/*T2@List<T1@String>*/) {
|
||||
val z: /*T4@*/String = x/*T2@List<T1@String>*/
|
||||
}
|
||||
}
|
||||
|
||||
//T0 <: T1 due to 'INITIALIZER'
|
||||
//T2 <: T4 due to 'INITIALIZER'
|
||||
//T3 <: T1 due to 'ASSIGNMENT'
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test() {
|
||||
val x: /*T1@*/List</*T0@*/Int> = nya()/*T3@List<T2@Int>*/
|
||||
}
|
||||
|
||||
fun nya(): /*T3@*/List</*T2@*/Int> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
//T2 <: T0 due to 'INITIALIZER'
|
||||
//T3 <: T1 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,7 @@
|
||||
fun f(): /*T1@*/Int {
|
||||
val x: /*T0@*/Int = 42/*LIT*/
|
||||
return x/*T0@Int*/
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'INITIALIZER'
|
||||
//T0 <: T1 due to 'RETURN'
|
||||
@@ -0,0 +1,11 @@
|
||||
fun test() {
|
||||
val x: /*T3@*/Map</*T1@*/String, /*T2@*/Int> = nya</*T0@*/String>()/*T6@Map<T0@String, T5@Int>*/
|
||||
}
|
||||
|
||||
fun <T> nya(): /*T6@*/Map</*T4@*/T, /*T5@*/Int> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
//T1 := T0 due to 'INITIALIZER'
|
||||
//T5 <: T2 due to 'INITIALIZER'
|
||||
//T6 <: T3 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,11 @@
|
||||
fun test() {
|
||||
nya</*T2@*/Boolean>({ a: /*T0@*/Int, b: /*T1@*/Boolean -> ""/*LIT*/ }/*Function2<T0@Int, T1@Boolean, T7@String>*/)
|
||||
}
|
||||
|
||||
fun <T> nya(x: /*T6@*/Function2</*T3@*/T, /*T4@*/Boolean, /*T5@*/String>) {
|
||||
}
|
||||
|
||||
//LOWER <: T7 due to 'RETURN'
|
||||
//T2 <: T0 due to 'PARAMETER'
|
||||
//T4 <: T1 due to 'PARAMETER'
|
||||
//T7 <: T5 due to 'PARAMETER'
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
val x: /*T5@*/Function2</*T2@*/Int, /*T3@*/String, /*T4@*/Boolean> = { a: /*T0@*/Int, b: /*T1@*/String -> true/*LIT*/ }/*Function2<T0@Int, T1@String, T6@Boolean>*/
|
||||
}
|
||||
|
||||
//LOWER <: T6 due to 'RETURN'
|
||||
//T2 <: T0 due to 'INITIALIZER'
|
||||
//T3 <: T1 due to 'INITIALIZER'
|
||||
//T6 <: T4 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test() {
|
||||
val x: /*T6@*/Function2</*T3@*/Int, /*T4@*/String, /*T5@*/Boolean> = { a: /*T0@*/Int, b: /*T1@*/String ->
|
||||
val a: /*T2@*/Boolean = true/*LIT*/
|
||||
a/*T2@Boolean*/
|
||||
}/*Function2<T0@Int, T1@String, T7@Boolean>*/
|
||||
}
|
||||
|
||||
//LOWER <: T2 due to 'INITIALIZER'
|
||||
//T2 <: T7 due to 'RETURN'
|
||||
//T3 <: T0 due to 'INITIALIZER'
|
||||
//T4 <: T1 due to 'INITIALIZER'
|
||||
//T7 <: T5 due to 'INITIALIZER'
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
class Test {
|
||||
fun foo1(r: /*T2@*/Function1</*T0@*/Int, /*T1@*/String>) {}
|
||||
fun foo() {
|
||||
foo1 { i: /*T3@*/Int ->
|
||||
val str: /*T4@*/String = ""/*LIT*/
|
||||
val str2: /*T5@*/String = ""/*LIT*/
|
||||
|
||||
if (i > 1) {
|
||||
return@foo1 str/*T4@String*/
|
||||
}
|
||||
str2/*T5@String*/
|
||||
}/*Function1<T3@Int, T6@String>*/
|
||||
}
|
||||
}
|
||||
|
||||
//LOWER <: T4 due to 'INITIALIZER'
|
||||
//LOWER <: T5 due to 'INITIALIZER'
|
||||
//T4 <: T6 due to 'RETURN'
|
||||
//T5 <: T6 due to 'RETURN'
|
||||
//T0 <: T3 due to 'PARAMETER'
|
||||
//T6 <: T1 due to 'PARAMETER'
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/List</*T1@*/Int> = listOf</*T0@*/Int>()/*List<T0@Int>*/
|
||||
val y: /*T4@*/List</*T3@*/Int> = x/*T2@List<T1@Int>*/
|
||||
}
|
||||
|
||||
//T0 <: T1 due to 'INITIALIZER'
|
||||
//T1 <: T3 due to 'INITIALIZER'
|
||||
//T2 <: T4 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,7 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/List</*T1@*/Int> = List</*T0@*/Int>(10/*LIT*/, { 10/*LIT*/ }/*Function0<Int, T3@Int>*/)/*List<T0@Int>*/
|
||||
}
|
||||
|
||||
//LOWER <: T3 due to 'RETURN'
|
||||
//T3 <: T0 due to 'PARAMETER'
|
||||
//T0 <: T1 due to 'INITIALIZER'
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fun foo() {
|
||||
val a: /*T5@*/List</*T4@*/List</*T3@*/Int>> = listOf</*T2@*/List</*T1@*/Int>>(
|
||||
listOf</*T0@*/Int>(
|
||||
1/*LIT*/
|
||||
)/*List<T0@Int>*/
|
||||
)/*List<T2@List<T1@Int>>*/
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'PARAMETER'
|
||||
//T0 <: T1 due to 'PARAMETER'
|
||||
//T1 <: T3 due to 'INITIALIZER'
|
||||
//T2 <: T4 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test() {
|
||||
val x: /*T5@*/List</*T4@*/List</*T3@*/Int>> = List</*T2@*/List</*T1@*/Int>>(13/*LIT*/, {
|
||||
List</*T0@*/Int>(7/*LIT*/, {
|
||||
666/*LIT*/
|
||||
}/*Function0<Int, T6@Int>*/)/*List<T0@Int>*/
|
||||
}/*Function0<Int, T7@List<T8@Int>>*/
|
||||
)/*List<T2@List<T1@Int>>*/
|
||||
}
|
||||
|
||||
//LOWER <: T6 due to 'RETURN'
|
||||
//T6 <: T0 due to 'PARAMETER'
|
||||
//T0 <: T8 due to 'RETURN'
|
||||
//T8 <: T1 due to 'PARAMETER'
|
||||
//T7 <: T2 due to 'PARAMETER'
|
||||
//T1 <: T3 due to 'INITIALIZER'
|
||||
//T2 <: T4 due to 'INITIALIZER'
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fun test() {
|
||||
val x: /*T2@*/X</*T1@*/Int> = X</*T0@*/Int>()/*X<T0@Int>*/
|
||||
val y: /*T5@*/Map</*T3@*/Int, /*T4@*/String> = x/*T2@X<T1@Int>*/.foo()/*T8@Map<T1@Int, T7@String>*/
|
||||
}
|
||||
|
||||
class X<T> {
|
||||
fun foo(): /*T8@*/Map</*T6@*/T, /*T7@*/String> {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
//T1 := T0 due to 'INITIALIZER'
|
||||
//T1 := T1 due to 'RECEIVER_PARAMETER'
|
||||
//T3 := T1 due to 'INITIALIZER'
|
||||
//T7 <: T4 due to 'INITIALIZER'
|
||||
//T8 <: T5 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test() {
|
||||
val x: /*T6@*/Function2</*T3@*/Int, /*T4@*/String, /*T5@*/Boolean> = l@{ a: /*T0@*/Int, b: /*T1@*/String ->
|
||||
val y: /*T2@*/Boolean = true/*LIT*/
|
||||
if (a == 3) {
|
||||
return@l y/*T2@Boolean*/
|
||||
}
|
||||
true/*LIT*/
|
||||
}/*Function2<T0@Int, T1@String, T7@Boolean>*//*Function2<T0@Int, T1@String, T7@Boolean>*/
|
||||
}
|
||||
|
||||
//LOWER <: T2 due to 'INITIALIZER'
|
||||
//T2 <: T7 due to 'RETURN'
|
||||
//LOWER <: T7 due to 'RETURN'
|
||||
//T3 <: T0 due to 'INITIALIZER'
|
||||
//T4 <: T1 due to 'INITIALIZER'
|
||||
//T7 <: T5 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,9 @@
|
||||
fun a(lst: /*T1@*/List</*T0@*/String>) {
|
||||
val newList: /*T5@*/List</*T4@*/String> = lst/*T1@List<T0@String>*/
|
||||
.asSequence</*T2@*/String>()/*Sequence<T2@String>*/
|
||||
.toList</*T3@*/String>()/*List<T3@String>*/
|
||||
}
|
||||
|
||||
//T0 <: T2 due to 'RECEIVER_PARAMETER'
|
||||
//T2 <: T3 due to 'RECEIVER_PARAMETER'
|
||||
//T3 <: T4 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,14 @@
|
||||
fun a(lst: /*T1@*/List</*T0@*/String>) {
|
||||
val newList: /*T8@*/List</*T7@*/Int> = lst/*T1@List<T0@String>*/
|
||||
.asSequence</*T2@*/String>()/*Sequence<T2@String>*/
|
||||
.map</*T4@*/String, /*T5@*/Int>({ x: /*T3@*/String -> 1/*LIT*/ }/*Function1<T3@String, T9@Int>*/)/*Sequence<T5@Int>*/
|
||||
.toList</*T6@*/Int>()/*List<T6@Int>*/
|
||||
}
|
||||
|
||||
//T0 <: T2 due to 'RECEIVER_PARAMETER'
|
||||
//LOWER <: T9 due to 'RETURN'
|
||||
//T2 <: T4 due to 'RECEIVER_PARAMETER'
|
||||
//T4 <: T3 due to 'PARAMETER'
|
||||
//T9 <: T5 due to 'PARAMETER'
|
||||
//T5 <: T6 due to 'RECEIVER_PARAMETER'
|
||||
//T6 <: T7 due to 'INITIALIZER'
|
||||
@@ -0,0 +1,9 @@
|
||||
fun test() {
|
||||
val x: /*T0@*/Int = 10/*LIT*/
|
||||
val y: /*T1@*/Int = x/*T0@Int*/
|
||||
val z: /*T2@*/Int = y/*T1@Int*/
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'INITIALIZER'
|
||||
//T0 <: T1 due to 'INITIALIZER'
|
||||
//T1 <: T2 due to 'INITIALIZER'
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
open class A<T> {
|
||||
open fun foo(x: /*T0@*/T, y: /*T2@*/List</*T1@*/T>) {
|
||||
}
|
||||
}
|
||||
|
||||
class B : A</*T6@*/Int>() {
|
||||
override fun foo(x: /*T3@*/Int, y: /*T5@*/List</*T4@*/Int>) {
|
||||
super/*LIT*/.foo(x/*T3@Int*/, y/*T5@List<T4@Int>*/)
|
||||
}
|
||||
}
|
||||
|
||||
//T3 := T6 due to 'SUPER_DECLARATION'
|
||||
//T4 := T6 due to 'SUPER_DECLARATION'
|
||||
//T2 := T5 due to 'SUPER_DECLARATION'
|
||||
@@ -0,0 +1,7 @@
|
||||
open class X<T>(x: /*T0@*/T) {
|
||||
}
|
||||
|
||||
class Y<T>(x: /*T1@*/T) : X</*T2@*/T>(x/*T1@T*/) {
|
||||
}
|
||||
|
||||
//T1 <: T0 due to 'PARAMETER'
|
||||
@@ -0,0 +1,15 @@
|
||||
interface A<T, S> {
|
||||
fun foo(): /*T3@*/List</*T2@*/Map</*T0@*/T, /*T1@*/S>>
|
||||
}
|
||||
|
||||
|
||||
open class B<X> : A</*T8@*/X, /*T9@*/Int> {
|
||||
override fun foo(): /*T7@*/List</*T6@*/Map</*T4@*/X, /*T5@*/Int>> {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
//T4 := T8 due to 'SUPER_DECLARATION'
|
||||
//T5 := T9 due to 'SUPER_DECLARATION'
|
||||
//T2 := T6 due to 'SUPER_DECLARATION'
|
||||
//T3 := T7 due to 'SUPER_DECLARATION'
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
open class A<T> {
|
||||
open fun foo(): /*T0@*/T {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
class B<T> : A</*T2@*/Int>() {
|
||||
override fun foo(): /*T1@*/Int {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
//T1 := T2 due to 'SUPER_DECLARATION'
|
||||
@@ -0,0 +1,13 @@
|
||||
open class A {
|
||||
open fun foo(): /*T0@*/String {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo(): /*T1@*/String {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
//T0 := T1 due to 'SUPER_DECLARATION'
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
fun <X : /*T0@*/Any> x() {
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fun test() {
|
||||
val x: /*T0@*/String = ""/*LIT*/
|
||||
val y: /*T1@*/String = ""/*LIT*/
|
||||
val z: /*T2@*/String = ""/*LIT*/
|
||||
val e: /*T5@*/List</*T4@*/String> = listOf</*T3@*/String>(x/*T0@String*/, y/*T1@String*/, z/*T2@String*/)/*List<T3@String>*/
|
||||
}
|
||||
|
||||
//LOWER <: T0 due to 'INITIALIZER'
|
||||
//LOWER <: T1 due to 'INITIALIZER'
|
||||
//LOWER <: T2 due to 'INITIALIZER'
|
||||
//T0 <: T3 due to 'PARAMETER'
|
||||
//T1 <: T3 due to 'PARAMETER'
|
||||
//T2 <: T3 due to 'PARAMETER'
|
||||
//T3 <: T4 due to 'INITIALIZER'
|
||||
Reference in New Issue
Block a user