diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrSourceRangesTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrSourceRangesTestGenerated.java index 9b74db73e53..17e927a31c8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrSourceRangesTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrSourceRangesTestGenerated.java @@ -85,6 +85,12 @@ public class FirLightTreeJvmIrSourceRangesTestGenerated extends AbstractFirLight runTest("compiler/testData/ir/sourceRanges/postfixIncrementDecrement.kt"); } + @Test + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("compiler/testData/ir/sourceRanges/this.kt"); + } + @Nested @TestMetadata("compiler/testData/ir/sourceRanges/declarations") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrSourceRangesTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrSourceRangesTestGenerated.java index bb051c10832..f00c50a56de 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrSourceRangesTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrSourceRangesTestGenerated.java @@ -85,6 +85,12 @@ public class FirPsiJvmIrSourceRangesTestGenerated extends AbstractFirPsiJvmIrSou runTest("compiler/testData/ir/sourceRanges/postfixIncrementDecrement.kt"); } + @Test + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("compiler/testData/ir/sourceRanges/this.kt"); + } + @Nested @TestMetadata("compiler/testData/ir/sourceRanges/declarations") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/ir/sourceRanges/this.fir.txt b/compiler/testData/ir/sourceRanges/this.fir.txt new file mode 100644 index 00000000000..3d0d06fed35 --- /dev/null +++ b/compiler/testData/ir/sourceRanges/this.fir.txt @@ -0,0 +1,32 @@ +@0:0..5:0 FILE fqName: fileName:/this.kt + @2:0..4:1 CLASS CLASS name:Klass modality:FINAL visibility:public superTypes:[kotlin.Any] + @2:0..4:1 CONSTRUCTOR visibility:public <> () returnType:.Klass [primary] + @2:0..4:1 BLOCK_BODY + @2:0..4:1 DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + @2:0..4:1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Klass modality:FINAL visibility:public superTypes:[kotlin.Any]' + @3:4..46 PROPERTY name:maybeThis visibility:public modality:FINAL [val] + @3:4..46 FIELD PROPERTY_BACKING_FIELD name:maybeThis type:.Klass? visibility:private [final] + @3:20..46 EXPRESSION_BODY + @3:20..46 WHEN type=.Klass? origin=IF + @3:32..36 BRANCH + @3:24..30 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + @3:24..25 CONST Int type=kotlin.Int value=1 + @3:29..30 CONST Int type=kotlin.Int value=1 + @3:32..36 GET_VAR ': .Klass declared in .Klass' type=.Klass origin=null + @3:42..46 BRANCH + @3:42..46 CONST Boolean type=kotlin.Boolean value=true + @3:42..46 CONST Null type=kotlin.Nothing? value=null + @3:4..46 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Klass) returnType:.Klass? + @3:4..46 VALUE_PARAMETER name: type:.Klass + @3:4..46 BLOCK_BODY + @3:4..46 RETURN type=kotlin.Nothing from='public final fun (): .Klass? declared in .Klass' + @3:4..46 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:maybeThis type:.Klass? visibility:private [final]' type=.Klass? origin=null + @3:4..46 GET_VAR ': .Klass declared in .Klass.' type=.Klass origin=null + @2:0..4:1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 VALUE_PARAMETER name:other index:0 type:kotlin.Any? + @2:0..4:1 FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Klass diff --git a/compiler/testData/ir/sourceRanges/this.kt b/compiler/testData/ir/sourceRanges/this.kt new file mode 100644 index 00000000000..a0eb3a63ccc --- /dev/null +++ b/compiler/testData/ir/sourceRanges/this.kt @@ -0,0 +1,5 @@ +// ISSUE: KT-59584 + +class Klass { + val maybeThis = if (1 == 1) this else null +} diff --git a/compiler/testData/ir/sourceRanges/this.txt b/compiler/testData/ir/sourceRanges/this.txt new file mode 100644 index 00000000000..7d1274bf8c1 --- /dev/null +++ b/compiler/testData/ir/sourceRanges/this.txt @@ -0,0 +1,32 @@ +@0:0..5:0 FILE fqName: fileName:/this.kt + @2:0..4:1 CLASS CLASS name:Klass modality:FINAL visibility:public superTypes:[kotlin.Any] + @2:0..4:1 CONSTRUCTOR visibility:public <> () returnType:.Klass [primary] + @2:0..4:1 BLOCK_BODY + @2:0..4:1 DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + @2:0..4:1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Klass modality:FINAL visibility:public superTypes:[kotlin.Any]' + @3:4..46 PROPERTY name:maybeThis visibility:public modality:FINAL [val] + @3:4..46 FIELD PROPERTY_BACKING_FIELD name:maybeThis type:.Klass? visibility:private [final] + @3:20..46 EXPRESSION_BODY + @3:20..46 WHEN type=.Klass? origin=IF + @3:20..46 BRANCH + @3:24..30 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + @3:24..25 CONST Int type=kotlin.Int value=1 + @3:29..30 CONST Int type=kotlin.Int value=1 + @3:32..36 GET_VAR ': .Klass declared in .Klass' type=.Klass origin=null + @3:20..46 BRANCH + @3:20..46 CONST Boolean type=kotlin.Boolean value=true + @3:42..46 CONST Null type=kotlin.Nothing? value=null + @3:4..46 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Klass) returnType:.Klass? + @3:4..46 VALUE_PARAMETER name: type:.Klass + @3:4..46 BLOCK_BODY + @3:4..46 RETURN type=kotlin.Nothing from='public final fun (): .Klass? declared in .Klass' + @3:4..46 GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:maybeThis type:.Klass? visibility:private [final]' type=.Klass? origin=null + @3:4..46 GET_VAR ': .Klass declared in .Klass.' type=.Klass origin=null + @2:0..4:1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 VALUE_PARAMETER name:other index:0 type:kotlin.Any? + @2:0..4:1 FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + @2:0..4:1 VALUE_PARAMETER name: type:kotlin.Any + @2:0..4:1 VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Klass diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrSourceRangesTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrSourceRangesTestGenerated.java index ab21855765c..2f0a52d8427 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrSourceRangesTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrSourceRangesTestGenerated.java @@ -85,6 +85,12 @@ public class ClassicJvmIrSourceRangesTestGenerated extends AbstractClassicJvmIrS runTest("compiler/testData/ir/sourceRanges/postfixIncrementDecrement.kt"); } + @Test + @TestMetadata("this.kt") + public void testThis() throws Exception { + runTest("compiler/testData/ir/sourceRanges/this.kt"); + } + @Nested @TestMetadata("compiler/testData/ir/sourceRanges/declarations") @TestDataPath("$PROJECT_ROOT")