[FIR] Fix creating DefinitelyNotNullTypes

Also fix substitutions to them
This commit is contained in:
Dmitriy Novozhilov
2020-01-27 16:59:08 +03:00
parent 4303cd2fc7
commit 57a1342aac
28 changed files with 117 additions and 94 deletions
@@ -7,10 +7,10 @@ fun <E : CharSequence> foo1(x: E) {}
fun <E : CharSequence> E.foo2() {}
fun <F : String?> bar(x: F) {
<!INAPPLICABLE_CANDIDATE!>A<!>(x)
A(x)
<!INAPPLICABLE_CANDIDATE!>A<!><F>(x)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(x)
foo1(x)
<!INAPPLICABLE_CANDIDATE!>foo1<!><F>(x)
x.<!INAPPLICABLE_CANDIDATE!>foo2<!>()
@@ -45,7 +45,7 @@ fun <T : CharSequence?> foo(x: T) {
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
<!INAPPLICABLE_CANDIDATE!>bar1<!>(y)
bar1(y)
bar2(y)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(y)
}
@@ -38,7 +38,7 @@ class A<F> {
x4.checkType { _<Z>() }
<!INAPPLICABLE_CANDIDATE!>foo1<!><W>(w)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(w)
foo1(w)
foo2<W>(w)
val x6 = foo2(w)
@@ -13,6 +13,6 @@ fun <T : String?> foo(x: T) {
bar1(x)
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
bar3(x)
bar4(x)
}
@@ -1,5 +1,5 @@
fun <S : Any> foo(x: Array<out S?>, y: Array<in S?>) {
val xo = <!INAPPLICABLE_CANDIDATE!>outA<!>(x)
val xo = outA(x)
val yo = inA(y)
var f: Array<S> = xo
@@ -16,5 +16,5 @@ fun <T : Any> test() {
value = JClass.getNotNullT()
}
value.<!INAPPLICABLE_CANDIDATE!>hashCode<!>() // unsafe call error
value.hashCode() // unsafe call error
}
@@ -36,6 +36,6 @@ fun test() {
B1().bar(null)
B2().bar(null)
C1().<!AMBIGUITY!>bar<!>(null)
C1().bar(null)
}
@@ -27,7 +27,7 @@ FILE fqName:<root> fileName:/implicitCastToNonNull.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public abstract fun <get-length> (): kotlin.Int declared in kotlin.CharSequence' type=kotlin.Int origin=null
$this: GET_VAR 'x: T of <root>.test2 declared in <root>.test2' type=kotlin.Any origin=null
$this: GET_VAR 'x: T of <root>.test2 declared in <root>.test2' type=T of <root>.test2 origin=null
FUN name:test3 visibility:public modality:FINAL <T> (x:kotlin.Any) returnType:kotlin.Int [inline]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence?]
VALUE_PARAMETER name:x index:0 type:kotlin.Any
@@ -70,4 +70,4 @@ FILE fqName:<root> fileName:/implicitCastToNonNull.kt
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public abstract fun invoke (p1: S of <root>.test5): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null
$this: GET_VAR 'fn: kotlin.Function1<S of <root>.test5, kotlin.Unit> declared in <root>.test5' type=kotlin.Function1<S of <root>.test5, kotlin.Unit> origin=null
p1: GET_VAR 'x: T of <root>.test5 declared in <root>.test5' type=kotlin.Any origin=null
p1: GET_VAR 'x: T of <root>.test5 declared in <root>.test5' type=T of <root>.test5 origin=null
+30 -30
View File
@@ -11,10 +11,10 @@ FILE fqName:<root> fileName:/kt30796.kt
VALUE_PARAMETER name:value2 index:1 type:T of <root>.test
BLOCK_BODY
VAR name:x1 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:T of <root>.test [val]
GET_VAR 'value: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
WHEN type=kotlin.Any origin=ELVIS
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_0: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
@@ -22,20 +22,20 @@ FILE fqName:<root> fileName:/kt30796.kt
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_0: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_0: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
VAR name:x2 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:T of <root>.test [val]
GET_VAR 'value: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
WHEN type=kotlin.Any origin=ELVIS
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_1: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: BLOCK type=kotlin.Any origin=ELVIS
then: BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:T of <root>.test [val]
GET_VAR 'value2: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
WHEN type=kotlin.Any origin=ELVIS
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_2: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
@@ -43,12 +43,12 @@ FILE fqName:<root> fileName:/kt30796.kt
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_2: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_2: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_1: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_1: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
VAR name:x3 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:T of <root>.test [val]
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:T of <root>.test [val]
@@ -61,8 +61,8 @@ FILE fqName:<root> fileName:/kt30796.kt
then: GET_VAR 'value2: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_4: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
WHEN type=kotlin.Any origin=ELVIS
then: GET_VAR 'val tmp_4: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_3: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
@@ -70,9 +70,9 @@ FILE fqName:<root> fileName:/kt30796.kt
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_3: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_3: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
VAR name:x4 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:T of <root>.test [val]
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:T of <root>.test [val]
@@ -85,8 +85,8 @@ FILE fqName:<root> fileName:/kt30796.kt
then: GET_VAR 'value2: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_6: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
WHEN type=kotlin.Any origin=ELVIS
then: GET_VAR 'val tmp_6: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_5: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
@@ -94,7 +94,7 @@ FILE fqName:<root> fileName:/kt30796.kt
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_5: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_5: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
VAR name:x5 type:kotlin.Any [val]
BLOCK type=kotlin.Int origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Nothing [val]
@@ -110,32 +110,32 @@ FILE fqName:<root> fileName:/kt30796.kt
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_7: kotlin.Nothing [val] declared in <root>.test' type=kotlin.Nothing origin=null
VAR name:x6 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:T of <root>.test [val]
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:T of <root>.test [val]
GET_VAR 'value: T of <root>.test declared in <root>.test' type=T of <root>.test origin=null
WHEN type=kotlin.Any origin=ELVIS
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_9: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CALL 'public final fun magic <T> (): T of <root>.magic declared in <root>' type=kotlin.Any origin=null
<T>: kotlin.Any
then: CALL 'public final fun magic <T> (): T of <root>.magic declared in <root>' type=T of <root>.test origin=null
<T>: T of <root>.test
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_9: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
WHEN type=kotlin.Any origin=ELVIS
then: GET_VAR 'val tmp_9: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_8: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
arg0: GET_VAR 'val tmp_8: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_8: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_8: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
VAR name:x7 type:kotlin.Any [val]
BLOCK type=kotlin.Any origin=ELVIS
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:T of <root>.test [val]
BLOCK type=T of <root>.test origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Nothing [val]
@@ -150,7 +150,7 @@ FILE fqName:<root> fileName:/kt30796.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_11: kotlin.Nothing [val] declared in <root>.test' type=kotlin.Nothing origin=null
WHEN type=kotlin.Any origin=ELVIS
WHEN type=T of <root>.test origin=ELVIS
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_10: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null
@@ -158,4 +158,4 @@ FILE fqName:<root> fileName:/kt30796.kt
then: CONST Int type=kotlin.Int value=42
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_10: T of <root>.test [val] declared in <root>.test' type=kotlin.Any origin=null
then: GET_VAR 'val tmp_10: T of <root>.test [val] declared in <root>.test' type=T of <root>.test origin=null