[FIR] Introduce unchecked not-null cast as internal operation for !!, ?:

This commit is contained in:
Simon Ogorodnik
2019-05-15 15:48:26 +03:00
committed by Mikhail Glukhikh
parent b469eb293b
commit aa96837758
16 changed files with 138 additions and 43 deletions
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
import org.jetbrains.kotlin.fir.expressions.FirWhenSubjectExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirUncheckedNotNullCastImpl
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
@@ -990,6 +991,11 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
}
}
private fun FlowContent.generate(makeNotNullCall: FirUncheckedNotNullCastImpl) {
generate(makeNotNullCall.expression)
keyword("!")
}
private fun FlowContent.generate(typeOperatorCall: FirTypeOperatorCall) {
val (expression) = typeOperatorCall.arguments
generate(expression)
@@ -1178,6 +1184,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
generate(expression.expression)
}
is FirTypeOperatorCall -> generate(expression)
is FirUncheckedNotNullCastImpl -> generate(expression)
is FirOperatorCall -> generate(expression)
else -> inlineUnsupported(expression)
}
@@ -629,6 +629,11 @@ internal class Fir2IrVisitor(
}
}
override fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: Any?): IrElement {
// TODO: Ensure correct
return uncheckedNotNullCast.expression.toIrExpression()
}
override fun visitWrappedArgumentExpression(wrappedArgumentExpression: FirWrappedArgumentExpression, data: Any?): IrElement {
// TODO: change this temporary hack to something correct
return wrappedArgumentExpression.expression.toIrExpression()
@@ -197,7 +197,10 @@ internal fun FirExpression.generateNotNullOrOther(
)
branches += FirWhenBranchImpl(
session, other.psi, FirElseIfTrueCondition(session, psi),
FirSingleExpressionBlock(session, generateResolvedAccessExpression(session, psi, subjectVariable))
FirSingleExpressionBlock(
session,
FirUncheckedNotNullCastImpl(session, psi, generateResolvedAccessExpression(session, psi, subjectVariable))
)
)
}
}
@@ -5,7 +5,7 @@ FILE: nullability.kt
Int(42)
}
else -> {
R|<local>/<elvis>|
R|<local>/<elvis>|!
}
}
@@ -16,7 +16,7 @@ FILE: nullability.kt
throw KotlinNullPointerException#()
}
else -> {
R|<local>/<bangbang>|
R|<local>/<bangbang>|!
}
}
@@ -131,6 +131,17 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
}
}
override fun transformUncheckedNotNullCast(
uncheckedNotNullCast: FirUncheckedNotNullCast,
data: Any?
): CompositeTransformResult<FirStatement> {
val notNullCast = super.transformUncheckedNotNullCast(uncheckedNotNullCast, data).single as FirUncheckedNotNullCast
val resultType = notNullCast.expression.resultType
notNullCast.resultType =
resultType.withReplacedConeType(session, resultType.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NOT_NULL))
return notNullCast.compose()
}
override fun transformTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: Any?): CompositeTransformResult<FirStatement> {
val symbolProvider = session.service<FirSymbolProvider>()
val resolved = super.transformTypeOperatorCall(typeOperatorCall, data).single
@@ -12,7 +12,7 @@ FILE: factoryFunctionOverloads.kt
throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()
}
else -> {
R|<local>/<bangbang>|
R|<local>/<bangbang>|!
}
}
, R|<local>/flag|)
@@ -919,4 +919,9 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
override fun visitErrorExpression(errorExpression: FirErrorExpression) {
print("ERROR_EXPR(${errorExpression.reason})")
}
override fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast) {
uncheckedNotNullCast.expression.accept(this)
print("!")
}
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions
import org.jetbrains.kotlin.fir.visitors.FirVisitor
interface FirUncheckedNotNullCast : FirCall {
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitUncheckedNotNullCast(this, data)
val expression: FirExpression get() = arguments[0]
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions.impl
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirUncheckedNotNullCast
import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.types.FirTypeRef
class FirUncheckedNotNullCastImpl(
session: FirSession,
psi: PsiElement?,
expression: FirExpression
) : FirAbstractCall(session, psi), FirUncheckedNotNullCast {
init {
arguments += expression
}
}
@@ -236,6 +236,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
return transformCall(stringConcatenationCall, data)
}
open fun transformUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: D): CompositeTransformResult<FirStatement> {
return transformCall(uncheckedNotNullCast, data)
}
open fun transformClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression, data: D): CompositeTransformResult<FirStatement> {
return transformExpression(classReferenceExpression, data)
}
@@ -732,6 +736,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
return transformTypedDeclaration(typedDeclaration, data)
}
final override fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: D): CompositeTransformResult<FirElement> {
return transformUncheckedNotNullCast(uncheckedNotNullCast, data)
}
final override fun visitUserTypeRef(userTypeRef: FirUserTypeRef, data: D): CompositeTransformResult<FirElement> {
return transformUserTypeRef(userTypeRef, data)
}
@@ -236,6 +236,10 @@ abstract class FirVisitor<out R, in D> {
return visitCall(stringConcatenationCall, data)
}
open fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: D): R {
return visitCall(uncheckedNotNullCast, data)
}
open fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression, data: D): R {
return visitExpression(classReferenceExpression, data)
}
@@ -236,6 +236,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitCall(stringConcatenationCall, null)
}
open fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast) {
visitCall(uncheckedNotNullCast, null)
}
open fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression) {
visitExpression(classReferenceExpression, null)
}
@@ -732,6 +736,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitTypedDeclaration(typedDeclaration)
}
final override fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: Nothing?) {
visitUncheckedNotNullCast(uncheckedNotNullCast)
}
final override fun visitUserTypeRef(userTypeRef: FirUserTypeRef, data: Nothing?) {
visitUserTypeRef(userTypeRef)
}
+4 -4
View File
@@ -1,12 +1,12 @@
FILE fqName:<root> fileName:/bangbang.kt
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Any?
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Any
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): kotlin.Any? declared in <root>'
BLOCK type=kotlin.Any? origin=EXCLEXCL
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): kotlin.Any declared in <root>'
BLOCK type=kotlin.Any origin=EXCLEXCL
VAR name:<bangbang> type:kotlin.Any? [val]
GET_VAR 'a: kotlin.Any? declared in <root>.test1' type=kotlin.Any? origin=null
WHEN type=kotlin.Any? origin=EXCLEXCL
WHEN type=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>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
@@ -45,11 +45,11 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
WHILE label=L origin=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value=true
body: BLOCK type=kotlin.Unit origin=null
VAR name:<range> type:kotlin.collections.List<kotlin.String>? [val]
BLOCK type=kotlin.collections.List<kotlin.String>? origin=ELVIS
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
BLOCK type=kotlin.collections.List<kotlin.String> origin=ELVIS
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
WHEN type=kotlin.collections.List<kotlin.String>? origin=ELVIS
WHEN type=kotlin.collections.List<kotlin.String> 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 <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
@@ -58,24 +58,27 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test3' type=kotlin.collections.List<kotlin.String>? origin=null
VAR name:<iterator> type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [kotlin/collections/List.iterator]>#' type=IrErrorType
VAR name:<iterator> type:kotlin.collections.Iterator<kotlin.String> [val]
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<kotlin.String> declared in kotlin.collections.List' type=kotlin.collections.Iterator<kotlin.String> origin=null
$this: GET_VAR 'val <range>: kotlin.collections.List<kotlin.String> [val] declared in <root>.test3' type=kotlin.collections.List<kotlin.String> origin=null
WHILE label=L2 origin=FOR_LOOP_INNER_WHILE
condition: ERROR_CALL 'Unresolved reference: <Unresolved name: hasNext>#' type=IrErrorType
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
$this: GET_VAR 'val <iterator>: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test3' type=kotlin.collections.Iterator<kotlin.String> origin=null
body: BLOCK type=kotlin.Unit origin=null
VAR name:s type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Unresolved name: next>#' type=IrErrorType
VAR name:s type:kotlin.String [val]
CALL 'public abstract fun next (): kotlin.String declared in kotlin.collections.Iterator' type=kotlin.String origin=null
$this: GET_VAR 'val <iterator>: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test3' type=kotlin.collections.Iterator<kotlin.String> origin=null
FUN name:test4 visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>?) returnType:kotlin.Unit
VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List<kotlin.String>?
BLOCK_BODY
WHILE label=L origin=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value=true
body: BLOCK type=kotlin.Unit origin=null
VAR name:<range> type:kotlin.collections.List<kotlin.String>? [val]
BLOCK type=kotlin.collections.List<kotlin.String>? origin=ELVIS
VAR name:<range> type:kotlin.collections.List<kotlin.String> [val]
BLOCK type=kotlin.collections.List<kotlin.String> origin=ELVIS
VAR name:<elvis> type:kotlin.collections.List<kotlin.String>? [val]
GET_VAR 'ss: kotlin.collections.List<kotlin.String>? declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
WHEN type=kotlin.collections.List<kotlin.String>? origin=ELVIS
WHEN type=kotlin.collections.List<kotlin.String> 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 <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
@@ -84,13 +87,16 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <elvis>: kotlin.collections.List<kotlin.String>? [val] declared in <root>.test4' type=kotlin.collections.List<kotlin.String>? origin=null
VAR name:<iterator> type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [kotlin/collections/List.iterator]>#' type=IrErrorType
VAR name:<iterator> type:kotlin.collections.Iterator<kotlin.String> [val]
CALL 'public abstract fun iterator (): kotlin.collections.Iterator<kotlin.String> declared in kotlin.collections.List' type=kotlin.collections.Iterator<kotlin.String> origin=null
$this: GET_VAR 'val <range>: kotlin.collections.List<kotlin.String> [val] declared in <root>.test4' type=kotlin.collections.List<kotlin.String> origin=null
WHILE label=L2 origin=FOR_LOOP_INNER_WHILE
condition: ERROR_CALL 'Unresolved reference: <Unresolved name: hasNext>#' type=IrErrorType
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null
$this: GET_VAR 'val <iterator>: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test4' type=kotlin.collections.Iterator<kotlin.String> origin=null
body: BLOCK type=kotlin.Unit origin=null
VAR name:s type:IrErrorType [val]
ERROR_CALL 'Unresolved reference: <Unresolved name: next>#' type=IrErrorType
VAR name:s type:kotlin.String [val]
CALL 'public abstract fun next (): kotlin.String declared in kotlin.collections.Iterator' type=kotlin.String origin=null
$this: GET_VAR 'val <iterator>: kotlin.collections.Iterator<kotlin.String> [val] declared in <root>.test4' type=kotlin.collections.Iterator<kotlin.String> origin=null
FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:i type:kotlin.Int [var]
+16 -16
View File
@@ -12,15 +12,15 @@ FILE fqName:<root> fileName:/elvis.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Any? declared in <root>'
CONST Null type=kotlin.Nothing? value=null
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?, b:kotlin.Any) returnType:kotlin.Any?
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?, b:kotlin.Any) returnType:kotlin.Any
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
VALUE_PARAMETER name:b index:1 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?, b: kotlin.Any): kotlin.Any? declared in <root>'
BLOCK type=kotlin.Any? origin=ELVIS
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?, b: kotlin.Any): kotlin.Any declared in <root>'
BLOCK type=kotlin.Any origin=ELVIS
VAR name:<elvis> type:kotlin.Any? [val]
GET_VAR 'a: kotlin.Any? declared in <root>.test1' type=kotlin.Any? origin=null
WHEN type=kotlin.Any? origin=ELVIS
WHEN type=kotlin.Any 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 <elvis>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
@@ -29,15 +29,15 @@ FILE fqName:<root> fileName:/elvis.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <elvis>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.String?, b:kotlin.Any) returnType:kotlin.Any?
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.String?, b:kotlin.Any) returnType:kotlin.Any
VALUE_PARAMETER name:a index:0 type:kotlin.String?
VALUE_PARAMETER name:b index:1 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.String?, b: kotlin.Any): kotlin.Any? declared in <root>'
BLOCK type=kotlin.Any? origin=ELVIS
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.String?, b: kotlin.Any): kotlin.Any declared in <root>'
BLOCK type=kotlin.Any origin=ELVIS
VAR name:<elvis> type:kotlin.String? [val]
GET_VAR 'a: kotlin.String? declared in <root>.test2' type=kotlin.String? origin=null
WHEN type=kotlin.Any? origin=ELVIS
WHEN type=kotlin.Any 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 <elvis>: kotlin.String? [val] declared in <root>.test2' type=kotlin.String? origin=null
@@ -75,14 +75,14 @@ FILE fqName:<root> fileName:/elvis.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <elvis>: kotlin.Any? [val] declared in <root>.test3' type=kotlin.Any? origin=null
FUN name:test4 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Any?
FUN name:test4 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Any
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test4 (x: kotlin.Any): kotlin.Any? declared in <root>'
BLOCK type=kotlin.Any? origin=ELVIS
RETURN type=kotlin.Nothing from='public final fun test4 (x: kotlin.Any): kotlin.Any declared in <root>'
BLOCK type=kotlin.Any origin=ELVIS
VAR name:<elvis> type:kotlin.Any? [val]
CALL 'public final fun <get-p> (): kotlin.Any? declared in <root>' type=kotlin.Any? origin=null
WHEN type=kotlin.Any? origin=ELVIS
WHEN type=kotlin.Any 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 <elvis>: kotlin.Any? [val] declared in <root>.test4' type=kotlin.Any? origin=null
@@ -91,14 +91,14 @@ FILE fqName:<root> fileName:/elvis.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val <elvis>: kotlin.Any? [val] declared in <root>.test4' type=kotlin.Any? origin=null
FUN name:test5 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Any?
FUN name:test5 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Any
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test5 (x: kotlin.Any): kotlin.Any? declared in <root>'
BLOCK type=kotlin.Any? origin=ELVIS
RETURN type=kotlin.Nothing from='public final fun test5 (x: kotlin.Any): kotlin.Any declared in <root>'
BLOCK type=kotlin.Any origin=ELVIS
VAR name:<elvis> type:kotlin.Any? [val]
CALL 'public final fun foo (): kotlin.Any? declared in <root>' type=kotlin.Any? origin=null
WHEN type=kotlin.Any? origin=ELVIS
WHEN type=kotlin.Any 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 <elvis>: kotlin.Any? [val] declared in <root>.test5' type=kotlin.Any? origin=null
@@ -5,14 +5,14 @@ FILE fqName:<root> fileName:/eqeqRhsConditionPossiblyAffectingLhs.kt
RETURN type=kotlin.Nothing from='public final fun test (x: kotlin.Any): kotlin.Boolean declared in <root>'
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 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
arg1: WHEN type=kotlin.Any? origin=IF
arg1: WHEN type=kotlin.Any origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=kotlin.Double
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Nothing? origin=EXCLEXCL
then: BLOCK type=kotlin.Nothing origin=EXCLEXCL
VAR name:<bangbang> type:kotlin.Nothing? [val]
CONST Null type=kotlin.Nothing? value=null
WHEN type=kotlin.Nothing? origin=EXCLEXCL
WHEN type=kotlin.Nothing 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>: kotlin.Nothing? [val] declared in <root>.test' type=kotlin.Nothing? origin=null