FIR2IR: insert implicit not-null casts in delegated calls

This commit is contained in:
Mikhail Glukhikh
2021-12-02 19:42:28 +03:00
parent 7cfec0d846
commit fa8441fb23
10 changed files with 100 additions and 80 deletions
@@ -44,9 +44,10 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
$this: VALUE_PARAMETER name:<this> type:<root>.Test
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.Test'
CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNotNull' type=<root>.Test origin=null
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNotNull' type=<root>.Test origin=null
FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:<root>.Test) returnType:kotlin.String?
annotations:
Nullable(value = <null>)
@@ -19,7 +19,7 @@ class Test : J {
@NotNull
override fun returnNotNull(): @EnhancedNullability String {
return <this>.#<$$delegate_0>.returnNotNull()
return <this>.#<$$delegate_0>.returnNotNull() /*!! String */
}
@Nullable
@@ -137,9 +137,10 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
$this: VALUE_PARAMETER name:<this> type:<root>.TestJFoo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestJFoo'
CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in <root>.JFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.JFoo visibility:local [final]' type=<root>.JFoo origin=null
receiver: GET_VAR '<this>: <root>.TestJFoo declared in <root>.TestJFoo.foo' type=<root>.TestJFoo origin=null
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in <root>.JFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.JFoo visibility:local [final]' type=<root>.JFoo origin=null
receiver: GET_VAR '<this>: <root>.TestJFoo declared in <root>.TestJFoo.foo' type=<root>.TestJFoo origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.JFoo visibility:local [final]
EXPRESSION_BODY
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.JFoo' type=<root>.JFoo origin=null
@@ -168,9 +169,10 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
$this: VALUE_PARAMETER name:<this> type:<root>.TestK1
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK1'
CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String [fake_override] declared in <root>.K1' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.K1 visibility:local [final]' type=<root>.K1 origin=null
receiver: GET_VAR '<this>: <root>.TestK1 declared in <root>.TestK1.foo' type=<root>.TestK1 origin=null
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String [fake_override] declared in <root>.K1' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.K1 visibility:local [final]' type=<root>.K1 origin=null
receiver: GET_VAR '<this>: <root>.TestK1 declared in <root>.TestK1.foo' type=<root>.TestK1 origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.K1 visibility:local [final]
EXPRESSION_BODY
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K1' type=<root>.K1 origin=null
@@ -261,9 +263,10 @@ FILE fqName:<root> fileName:/implicitNotNullOnDelegatedImplementation.kt
$this: VALUE_PARAMETER name:<this> type:<root>.TestK4
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.TestK4'
CALL 'public final fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.K4' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.K4 visibility:local [final]' type=<root>.K4 origin=null
receiver: GET_VAR '<this>: <root>.TestK4 declared in <root>.TestK4.foo' type=<root>.TestK4 origin=null
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public final fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.K4' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.K4 visibility:local [final]' type=<root>.K4 origin=null
receiver: GET_VAR '<this>: <root>.TestK4 declared in <root>.TestK4.foo' type=<root>.TestK4 origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.K4 visibility:local [final]
EXPRESSION_BODY
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K4' type=<root>.K4 origin=null
@@ -55,7 +55,7 @@ class TestJFoo : IFoo {
}
override fun foo(): String {
return <this>.#<$$delegate_0>.foo()
return <this>.#<$$delegate_0>.foo() /*!! String */
}
local /* final field */ val <$$delegate_0>: JFoo = JFoo()
@@ -70,7 +70,7 @@ class TestK1 : IFoo {
}
override fun foo(): String {
return <this>.#<$$delegate_0>.foo()
return <this>.#<$$delegate_0>.foo() /*!! String */
}
local /* final field */ val <$$delegate_0>: K1 = K1()
@@ -115,7 +115,7 @@ class TestK4 : IFoo {
}
override fun foo(): String {
return <this>.#<$$delegate_0>.foo()
return <this>.#<$$delegate_0>.foo() /*!! String */
}
local /* final field */ val <$$delegate_0>: K4 = K4()