[FIR] Allow nullable receiver type in case of safe-calls

This commit is contained in:
Simon Ogorodnik
2019-05-15 15:53:07 +03:00
committed by Mikhail Glukhikh
parent b28207deca
commit 27a1ec3817
12 changed files with 92 additions and 37 deletions
+9 -9
View File
@@ -16,21 +16,21 @@ FILE fqName:<root> fileName:/bangbang.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <bangbang>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:IrErrorType
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Int
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): IrErrorType declared in <root>'
BLOCK type=IrErrorType origin=EXCLEXCL
VAR name:<bangbang> type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [kotlin/Any.hashCode]>#' type=IrErrorType
WHEN type=IrErrorType origin=EXCLEXCL
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=EXCLEXCL
VAR name:<bangbang> type:kotlin.Int [val]
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
$this: GET_VAR 'a: kotlin.Any? declared in <root>.test2' type=kotlin.Any? origin=null
WHEN type=kotlin.Int origin=EXCLEXCL
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 <bangbang>: IrErrorType [val] declared in <root>.test2' type=IrErrorType origin=null
arg0: GET_VAR 'val <bangbang>: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: THROW type=kotlin.Nothing
ERROR_CALL 'Unresolved reference: <Unresolved name: KotlinNullPointerException>#' type=IrErrorType
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <bangbang>: IrErrorType [val] declared in <root>.test2' type=IrErrorType origin=null
then: GET_VAR 'val <bangbang>: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
@@ -28,9 +28,12 @@ FILE fqName:<root> fileName:/chainOfSafeCalls.kt
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (nc:<root>.C?) returnType:IrErrorType
FUN name:test visibility:public modality:FINAL <> (nc:<root>.C?) returnType:<root>.C
VALUE_PARAMETER name:nc index:0 type:<root>.C?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test (nc: <root>.C?): IrErrorType declared in <root>'
ERROR_CALL 'Unresolved reference: <Unresolved name: foo>#' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun test (nc: <root>.C?): <root>.C declared in <root>'
CALL 'public final fun foo (): <root>.C declared in <root>.C' type=<root>.C origin=null
$this: CALL 'public final fun foo (): <root>.C declared in <root>.C' type=<root>.C origin=null
$this: CALL 'public final fun bar (): <root>.C? declared in <root>.C' type=<root>.C? origin=null
$this: CALL 'public final fun foo (): <root>.C declared in <root>.C' type=<root>.C origin=null
$this: GET_VAR 'nc: <root>.C? declared in <root>.test' type=<root>.C? origin=null
+8 -7
View File
@@ -55,20 +55,21 @@ FILE fqName:<root> fileName:/kt30020.kt
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
ERROR_CALL 'Unresolved reference: R|<local>/<complex-set>|' type=IrErrorType
VAR name:<complex-set> type:IrErrorType [val]
BLOCK type=IrErrorType origin=EXCLEXCL
VAR name:<bangbang> type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [/X.f]>#' type=IrErrorType
WHEN type=IrErrorType origin=EXCLEXCL
VAR name:<complex-set> type:kotlin.collections.MutableList<kotlin.Any> [val]
BLOCK type=kotlin.collections.MutableList<kotlin.Any> origin=EXCLEXCL
VAR name:<bangbang> type:kotlin.collections.MutableList<kotlin.Any> [val]
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
$this: GET_VAR 'nx: <root>.X? declared in <root>.test' type=<root>.X? origin=null
WHEN type=kotlin.collections.MutableList<kotlin.Any> origin=EXCLEXCL
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 <bangbang>: IrErrorType [val] declared in <root>.test' type=IrErrorType origin=null
arg0: GET_VAR 'val <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.KotlinNullPointerException' type=kotlin.KotlinNullPointerException origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <bangbang>: IrErrorType [val] declared in <root>.test' type=IrErrorType origin=null
then: GET_VAR 'val <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
ERROR_CALL 'Unresolved reference: R|<local>/<complex-set>|' type=IrErrorType
FUN name:testExtensionReceiver visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
@@ -31,7 +31,8 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt
FUN name:inc visibility:public modality:FINAL <> () returnType:kotlin.Int?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun inc (): kotlin.Int? declared in test'
CALL 'public final fun inc (): kotlin.Int? declared in test' type=kotlin.Int? origin=null
CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: ERROR_CALL 'Unresolved reference: this#' type=kotlin.Int?
FUN name:get visibility:public modality:FINAL <> (index:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:index index:0 type:kotlin.Int
BLOCK_BODY
+6 -5
View File
@@ -67,24 +67,25 @@ FILE fqName:<root> fileName:/safeCalls.kt
VALUE_PARAMETER name:x index:0 type:kotlin.String?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (x: kotlin.String?): IrErrorType declared in <root>'
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [kotlin/Any.hashCode, kotlin/Any.hashCode]>#' type=IrErrorType
ERROR_CALL 'Unresolved reference: <Ambiguity: hashCode, [kotlin/Any.hashCode, kotlin/Any.hashCode]>#' type=IrErrorType
FUN name:test3 visibility:public modality:FINAL <> (x:kotlin.String?, y:kotlin.Any?) returnType:IrErrorType
VALUE_PARAMETER name:x index:0 type:kotlin.String?
VALUE_PARAMETER name:y index:1 type:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3 (x: kotlin.String?, y: kotlin.Any?): IrErrorType declared in <root>'
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [kotlin/Any.equals, kotlin/Any.equals]>#' type=IrErrorType
ERROR_CALL 'Unresolved reference: <Ambiguity: equals, [kotlin/Any.equals, kotlin/Any.equals]>#' type=IrErrorType
GET_VAR 'y: kotlin.Any? declared in <root>.test3' type=kotlin.Any? origin=null
FUN name:test4 visibility:public modality:FINAL <> (x:<root>.Ref?) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:<root>.Ref?
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:public ' type=kotlin.Int origin=null
value: CONST Int type=kotlin.Int value=0
FUN name:test5 visibility:public modality:FINAL <> (s:kotlin.String?) returnType:IrErrorType
FUN name:test5 visibility:public modality:FINAL <> (s:kotlin.String?) returnType:kotlin.Int
VALUE_PARAMETER name:s index:0 type:kotlin.String?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test5 (s: kotlin.String?): IrErrorType declared in <root>'
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [/IHost.extLength]>#' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun test5 (s: kotlin.String?): kotlin.Int declared in <root>'
CALL 'public open fun extLength (): kotlin.Int declared in <root>.IHost' type=kotlin.Int origin=null
$this: GET_VAR 's: kotlin.String? declared in <root>.test5' type=kotlin.String? origin=null
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Int declared in <root>'
@@ -31,7 +31,8 @@ FILE fqName:<root> fileName:/temporaryInEnumEntryInitializer.kt
CONSTRUCTOR visibility:public <> () returnType:<root>.En.ENTRY [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> (x: kotlin.String?) [primary] declared in <root>.En'
x: CALL 'public final fun toString (): kotlin.String declared in kotlin' type=kotlin.String origin=null
x: CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
$this: CALL 'public final fun <get-n> (): kotlin.Any? declared in <root>' type=kotlin.Any? origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ENTRY modality:FINAL visibility:public superTypes:[<root>.En]'
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any
overridden:
@@ -18,7 +18,8 @@ FILE fqName:<root> fileName:/temporaryInInitBlock.kt
ANONYMOUS_INITIALIZER isStatic=false
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String? visibility:public [final] ' type=kotlin.String? origin=null
value: CALL 'public final fun toString (): kotlin.String declared in kotlin' type=kotlin.String origin=null
value: CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
$this: GET_VAR 'x: kotlin.Any? declared in <root>.C.<init>' type=kotlin.Any? origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any