PSI2IR: For implicit function return, use expression's end offset as start offset of the IrReturn to generarate correct line number.

This commit is contained in:
Jiaxiang Chen
2019-11-18 13:30:07 -08:00
committed by Ilmir Usmanov
parent e49431a12c
commit 0441e484a6
6 changed files with 11 additions and 14 deletions
@@ -61,7 +61,7 @@ class BodyGenerator(
val irBody = statementGenerator.generateStatement(ktBody)
irBlockBody.statements.add(
if (ktBody.isUsedAsExpression(context.bindingContext) && irBody is IrExpression)
generateReturnExpression(irBody.startOffset, irBody.endOffset, irBody)
generateReturnExpression(irBody.endOffset, irBody.endOffset, irBody)
else
irBody
)
@@ -20,9 +20,6 @@ fun bar(x: Int) =
foo(x)
}
// IGNORE_BACKEND: JVM_IR
// IR backend has bar().12 replaced as bar().8 for returning bar() function result.
// LINENUMBERS
// TestKt.box():4
// FooKt.foo(int):4
@@ -24,7 +24,7 @@
@2:0..8:1 VALUE_PARAMETER name:<this> type:kotlin.Any
@10:0..18 FUN name:foo visibility:public modality:FINAL <> () returnType:test.Host
@10:12..18 BLOCK_BODY
@10:12..18 RETURN type=kotlin.Nothing from='public final fun foo (): test.Host declared in test'
@10:18..18 RETURN type=kotlin.Nothing from='public final fun foo (): test.Host declared in test'
@10:12..18 CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in test.Host' type=test.Host origin=null
@12:0..14:1 FUN name:test2 visibility:public modality:FINAL <> ($receiver:test.Host) returnType:kotlin.Unit
@12:4..8 VALUE_PARAMETER name:<this> type:test.Host
+1 -1
View File
@@ -31,7 +31,7 @@
@27:8..25 FUN name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Foo) returnType:kotlin.Int
@27:8..25 VALUE_PARAMETER name:<this> type:<root>.Foo
@27:16..25 BLOCK_BODY
@27:16..25 RETURN type=kotlin.Nothing from='public final fun <get-x> (): kotlin.Int declared in <root>.Foo'
@27:25..25 RETURN type=kotlin.Nothing from='public final fun <get-x> (): kotlin.Int declared in <root>.Foo'
@27:16..25 CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUS
@27:16..21 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
@27:16..21 GET_VAR '<this>: <root>.Foo declared in <root>.Foo.<get-x>' type=<root>.Foo origin=null
@@ -49,25 +49,25 @@
@23:14..24 FUN name:<get-test4> visibility:public modality:FINAL <> ($this:test.Test) returnType:kotlin.Int
@23:14..24 VALUE_PARAMETER name:<this> type:test.Test
@23:22..24 BLOCK_BODY
@23:22..24 RETURN type=kotlin.Nothing from='public final fun <get-test4> (): kotlin.Int declared in test.Test'
@23:24..24 RETURN type=kotlin.Nothing from='public final fun <get-test4> (): kotlin.Int declared in test.Test'
@23:22..24 CONST Int type=kotlin.Int value=42
@26:4..27:18 PROPERTY name:test5 visibility:public modality:FINAL [val]
@27:8..18 FUN name:<get-test5> visibility:public modality:FINAL <> ($this:test.Test) returnType:kotlin.Int
@27:8..18 VALUE_PARAMETER name:<this> type:test.Test
@27:16..18 BLOCK_BODY
@27:16..18 RETURN type=kotlin.Nothing from='public final fun <get-test5> (): kotlin.Int declared in test.Test'
@27:18..18 RETURN type=kotlin.Nothing from='public final fun <get-test5> (): kotlin.Int declared in test.Test'
@27:16..18 CONST Int type=kotlin.Int value=42
@30:4..34:18 PROPERTY name:test6 visibility:public modality:FINAL [val]
@34:8..18 FUN name:<get-test6> visibility:public modality:FINAL <> ($this:test.Test) returnType:kotlin.Int
@34:8..18 VALUE_PARAMETER name:<this> type:test.Test
@34:16..18 BLOCK_BODY
@34:16..18 RETURN type=kotlin.Nothing from='public final fun <get-test6> (): kotlin.Int declared in test.Test'
@34:18..18 RETURN type=kotlin.Nothing from='public final fun <get-test6> (): kotlin.Int declared in test.Test'
@34:16..18 CONST Int type=kotlin.Int value=42
@37:4..41:18 PROPERTY name:test7 visibility:public modality:FINAL [val]
@41:8..18 FUN name:<get-test7> visibility:public modality:FINAL <> ($this:test.Test) returnType:kotlin.Int
@38:8..41:18 VALUE_PARAMETER name:<this> type:test.Test
@41:16..18 BLOCK_BODY
@41:16..18 RETURN type=kotlin.Nothing from='public final fun <get-test7> (): kotlin.Int declared in test.Test'
@41:18..18 RETURN type=kotlin.Nothing from='public final fun <get-test7> (): kotlin.Int declared in test.Test'
@41:16..18 CONST Int type=kotlin.Int value=42
@44:4..18 PROPERTY name:test8 visibility:public modality:FINAL [var]
@44:4..18 FIELD PROPERTY_BACKING_FIELD name:test8 type:kotlin.Int visibility:private
@@ -34,22 +34,22 @@
@22:0..20 PROPERTY name:test4 visibility:public modality:FINAL [val]
@22:10..20 FUN name:<get-test4> visibility:public modality:FINAL <> () returnType:kotlin.Int
@22:18..20 BLOCK_BODY
@22:18..20 RETURN type=kotlin.Nothing from='public final fun <get-test4> (): kotlin.Int declared in test'
@22:20..20 RETURN type=kotlin.Nothing from='public final fun <get-test4> (): kotlin.Int declared in test'
@22:18..20 CONST Int type=kotlin.Int value=42
@25:0..26:14 PROPERTY name:test5 visibility:public modality:FINAL [val]
@26:4..14 FUN name:<get-test5> visibility:public modality:FINAL <> () returnType:kotlin.Int
@26:12..14 BLOCK_BODY
@26:12..14 RETURN type=kotlin.Nothing from='public final fun <get-test5> (): kotlin.Int declared in test'
@26:14..14 RETURN type=kotlin.Nothing from='public final fun <get-test5> (): kotlin.Int declared in test'
@26:12..14 CONST Int type=kotlin.Int value=42
@29:0..33:14 PROPERTY name:test6 visibility:public modality:FINAL [val]
@33:4..14 FUN name:<get-test6> visibility:public modality:FINAL <> () returnType:kotlin.Int
@33:12..14 BLOCK_BODY
@33:12..14 RETURN type=kotlin.Nothing from='public final fun <get-test6> (): kotlin.Int declared in test'
@33:14..14 RETURN type=kotlin.Nothing from='public final fun <get-test6> (): kotlin.Int declared in test'
@33:12..14 CONST Int type=kotlin.Int value=42
@36:0..40:14 PROPERTY name:test7 visibility:public modality:FINAL [val]
@40:4..14 FUN name:<get-test7> visibility:public modality:FINAL <> () returnType:kotlin.Int
@40:12..14 BLOCK_BODY
@40:12..14 RETURN type=kotlin.Nothing from='public final fun <get-test7> (): kotlin.Int declared in test'
@40:14..14 RETURN type=kotlin.Nothing from='public final fun <get-test7> (): kotlin.Int declared in test'
@40:12..14 CONST Int type=kotlin.Int value=42
@43:0..14 PROPERTY name:test8 visibility:public modality:FINAL [var]
@43:0..14 FIELD PROPERTY_BACKING_FIELD name:test8 type:kotlin.Int visibility:private [static]