FIR2IR: set CATCH_PARAMETER origin for catch parameters

This commit is contained in:
Mikhail Glukhikh
2023-01-24 17:28:51 +01:00
committed by Space Team
parent f0a1d3e3b1
commit b867fd8c2f
9 changed files with 11 additions and 29 deletions
@@ -1222,7 +1222,9 @@ class Fir2IrVisitor(
override fun visitCatch(catch: FirCatch, data: Any?): IrElement {
return catch.convertWithOffsets { startOffset, endOffset ->
val catchParameter = declarationStorage.createIrVariable(catch.parameter, conversionScope.parentFromStack())
val catchParameter = declarationStorage.createIrVariable(
catch.parameter, conversionScope.parentFromStack(), IrDeclarationOrigin.CATCH_PARAMETER
)
IrCatchImpl(startOffset, endOffset, catchParameter, catch.block.convertToIrBlock())
}
}
@@ -1,14 +0,0 @@
FILE fqName:<root> fileName:/catchParameterInTopLevelProperty.kt
PROPERTY name:test visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Unit visibility:private [final,static]
EXPRESSION_BODY
TRY type=kotlin.Unit
try: BLOCK type=kotlin.Unit origin=null
CATCH parameter=val e: kotlin.Throwable [val] declared in <root>.test
VAR name:e type:kotlin.Throwable [val]
BLOCK type=kotlin.Unit origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> () returnType:kotlin.Unit
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test> (): kotlin.Unit declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Unit visibility:private [final,static]' type=kotlin.Unit origin=null
@@ -1,7 +0,0 @@
val test: Unit
field = try { // BLOCK
}
catch (e: Throwable){ // BLOCK
}
get
@@ -1 +1,2 @@
// FIR_IDENTICAL
val test = try { } catch (e : Throwable) { }
@@ -8,7 +8,7 @@ FILE fqName:<root> fileName:/catchParameterAccess.kt
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Unit origin=INVOKE
$this: GET_VAR 'f: kotlin.Function0<kotlin.Unit> declared in <root>.test' type=kotlin.Function0<kotlin.Unit> origin=VARIABLE_AS_FUNCTION
CATCH parameter=val e: java.lang.Exception [val] declared in <root>.test
VAR name:e type:java.lang.Exception [val]
VAR CATCH_PARAMETER name:e type:java.lang.Exception [val]
BLOCK type=kotlin.Nothing origin=null
THROW type=kotlin.Nothing
GET_VAR 'val e: java.lang.Exception [val] declared in <root>.test' type=java.lang.Exception origin=null
+2 -2
View File
@@ -13,7 +13,7 @@ FILE fqName:<root> fileName:/kt48806.kt
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.RuntimeException' type=java.lang.RuntimeException origin=null
CATCH parameter=val e: java.lang.Exception [val] declared in <root>.A.test_1
VAR name:e type:java.lang.Exception [val]
VAR CATCH_PARAMETER name:e type:java.lang.Exception [val]
BLOCK type=kotlin.Int origin=null
CONST Int type=kotlin.Int value=1
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test_1> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
@@ -30,7 +30,7 @@ FILE fqName:<root> fileName:/kt48806.kt
try: BLOCK type=kotlin.Int origin=null
CONST Int type=kotlin.Int value=1
CATCH parameter=val e: java.lang.Exception [val] declared in <root>.A.test_2
VAR name:e type:java.lang.Exception [val]
VAR CATCH_PARAMETER name:e type:java.lang.Exception [val]
BLOCK type=kotlin.Nothing origin=null
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.RuntimeException' type=java.lang.RuntimeException origin=null
@@ -5,7 +5,7 @@ FILE fqName:<root> fileName:/tryCatch.kt
try: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null
CATCH parameter=val e: kotlin.Throwable [val] declared in <root>.test1
VAR name:e type:kotlin.Throwable [val]
VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val]
BLOCK type=kotlin.Unit origin=null
CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null
finally: BLOCK type=kotlin.Unit origin=null
@@ -18,7 +18,7 @@ FILE fqName:<root> fileName:/tryCatch.kt
CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null
CONST Int type=kotlin.Int value=42
CATCH parameter=val e: kotlin.Throwable [val] declared in <root>.test2
VAR name:e type:kotlin.Throwable [val]
VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val]
BLOCK type=kotlin.Int origin=null
CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null
CONST Int type=kotlin.Int value=24
@@ -14,6 +14,6 @@ FILE fqName:<root> fileName:/tryCatchWithImplicitCast.kt
TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
GET_VAR 'a: kotlin.Any declared in <root>.testImplicitCast' type=kotlin.Any origin=null
CATCH parameter=val e: kotlin.Throwable [val] declared in <root>.testImplicitCast
VAR name:e type:kotlin.Throwable [val]
VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val]
BLOCK type=kotlin.String origin=null
CONST String type=kotlin.String value=""
@@ -14,7 +14,7 @@ FILE fqName:<root> fileName:/FlushFromAnonymous.kt
TRY type=kotlin.Unit
try: BLOCK type=kotlin.Unit origin=null
CATCH parameter=val e: kotlin.Throwable [val] declared in <root>.Serializer.serialize
VAR name:e type:kotlin.Throwable [val]
VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val]
BLOCK type=kotlin.Unit origin=null
CALL 'public open fun flush (): kotlin.Unit [fake_override] declared in <root>.Serializer.createMessageCollector.<no name provided>' type=kotlin.Unit origin=null
$this: GET_VAR 'val messageCollector: <root>.Serializer.createMessageCollector.<no name provided> [val] declared in <root>.Serializer.serialize' type=<root>.Serializer.createMessageCollector.<no name provided> origin=null