From 8e577e101ebcab0efbcd9193eb4ed4791733dba2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 28 Sep 2023 11:27:58 +0200 Subject: [PATCH] K2: reproduce KT-61974 --- .../FirLightTreeJvmIrTextTestGenerated.java | 6 ++ .../ir/FirPsiJvmIrTextTestGenerated.java | 6 ++ .../elvisOnBackingFieldInGetter.fir.ir.txt | 98 +++++++++++++++++++ .../elvisOnBackingFieldInGetter.fir.kt.txt | 45 +++++++++ .../elvisOnBackingFieldInGetter.ir.txt | 98 +++++++++++++++++++ .../elvisOnBackingFieldInGetter.kt | 20 ++++ .../elvisOnBackingFieldInGetter.kt.txt | 45 +++++++++ .../elvisOnBackingFieldInGetter.sig.kt.txt | 45 +++++++++ .../ir/ClassicJvmIrTextTestGenerated.java | 6 ++ 9 files changed, 369 insertions(+) create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.sig.kt.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index ef64bc0e2f5..d92edc499ee 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -2682,6 +2682,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + @Test + @TestMetadata("elvisOnBackingFieldInGetter.kt") + public void testElvisOnBackingFieldInGetter() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt"); + } + @Test @TestMetadata("emptyWhen.kt") public void testEmptyWhen() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index d5c348c2343..19b6b205181 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -2682,6 +2682,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + @Test + @TestMetadata("elvisOnBackingFieldInGetter.kt") + public void testElvisOnBackingFieldInGetter() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt"); + } + @Test @TestMetadata("emptyWhen.kt") public void testEmptyWhen() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.ir.txt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.ir.txt new file mode 100644 index 00000000000..14274ae000a --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.ir.txt @@ -0,0 +1,98 @@ +FILE fqName: fileName:/elvisOnBackingFieldInGetter.kt + CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test + CONSTRUCTOR visibility:public <> () returnType:.Test [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:resourceTable visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private + EXPRESSION_BODY + CONST Null type=kotlin.Nothing? value=null + FUN name: visibility:public modality:FINAL <> ($this:.Test) returnType:.ResourceTable? + correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=GET_PROPERTY + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun (): .ResourceTable? declared in .Test' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=GET_PROPERTY + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + VAR name:fileData type:kotlin.String? [val] + CALL 'public final fun getFileData (): kotlin.String? declared in .Test' type=kotlin.String? origin=null + $this: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val fileData: kotlin.String? declared in .Test.' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Unit origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + value: CONSTRUCTOR_CALL 'public constructor () declared in .ResourceTable' type=.ResourceTable origin=null + RETURN type=kotlin.Nothing from='public final fun (): .ResourceTable? declared in .Test' + BLOCK type=.ResourceTable origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Nothing? [val] + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=GET_PROPERTY + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + WHEN type=.ResourceTable origin=null + 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 tmp_0: kotlin.Nothing? declared in .Test.' type=kotlin.Nothing? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONSTRUCTOR_CALL 'public constructor () declared in .ResourceTable' type=.ResourceTable origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val tmp_0: kotlin.Nothing? declared in .Test.' type=kotlin.Nothing? origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test, :.ResourceTable?) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name: index:0 type:.ResourceTable? + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + value: GET_VAR ': .ResourceTable? declared in .Test.' type=.ResourceTable? origin=null + FUN name:getFileData visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.String? + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun getFileData (): kotlin.String? declared in .Test' + CONST String type=kotlin.String value="" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:ResourceTable modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResourceTable + CONSTRUCTOR visibility:public <> () returnType:.ResourceTable [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResourceTable modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.kt.txt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.kt.txt new file mode 100644 index 00000000000..f93e6cf08a4 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.fir.kt.txt @@ -0,0 +1,45 @@ +class Test { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + var resourceTable: ResourceTable? + field = null + get(): ResourceTable? { + when { + EQEQ(arg0 = .#resourceTable, arg1 = null).not() -> { // BLOCK + return .#resourceTable + } + } + val fileData: String? = .getFileData() + when { + EQEQ(arg0 = fileData, arg1 = null).not() -> { // BLOCK + .#resourceTable = ResourceTable() + } + } + return { // BLOCK + val : Nothing? = .#resourceTable + when { + EQEQ(arg0 = , arg1 = null) -> ResourceTable() + else -> + } + } + } + set + + fun getFileData(): String? { + return "" + } + +} + +class ResourceTable { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.ir.txt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.ir.txt new file mode 100644 index 00000000000..4f22b3efd22 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.ir.txt @@ -0,0 +1,98 @@ +FILE fqName: fileName:/elvisOnBackingFieldInGetter.kt + CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test + CONSTRUCTOR visibility:public <> () returnType:.Test [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:resourceTable visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private + EXPRESSION_BODY + CONST Null type=kotlin.Nothing? value=null + FUN name: visibility:public modality:FINAL <> ($this:.Test) returnType:.ResourceTable? + correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun (): .ResourceTable? declared in .Test' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + VAR name:fileData type:kotlin.String? [val] + CALL 'public final fun getFileData (): kotlin.String? declared in .Test' type=kotlin.String? origin=null + $this: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val fileData: kotlin.String? declared in .Test.' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Unit origin=null + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + value: CONSTRUCTOR_CALL 'public constructor () declared in .ResourceTable' type=.ResourceTable origin=null + RETURN type=kotlin.Nothing from='public final fun (): .ResourceTable? declared in .Test' + BLOCK type=.ResourceTable? origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.ResourceTable? [val] + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=.ResourceTable? origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + WHEN type=.ResourceTable? origin=null + 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 tmp_0: .ResourceTable? declared in .Test.' type=.ResourceTable? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONSTRUCTOR_CALL 'public constructor () declared in .ResourceTable' type=.ResourceTable origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val tmp_0: .ResourceTable? declared in .Test.' type=.ResourceTable? origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test, :.ResourceTable?) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name: index:0 type:.ResourceTable? + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:.ResourceTable? visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + value: GET_VAR ': .ResourceTable? declared in .Test.' type=.ResourceTable? origin=null + FUN name:getFileData visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.String? + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun getFileData (): kotlin.String? declared in .Test' + CONST String type=kotlin.String value="" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:ResourceTable modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResourceTable + CONSTRUCTOR visibility:public <> () returnType:.ResourceTable [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResourceTable modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt new file mode 100644 index 00000000000..c61d92d67c0 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt @@ -0,0 +1,20 @@ +// ISSUE: KT-61974 +// TARGET_BACKEND: JVM + +class Test { + var resourceTable: ResourceTable? = null + get() { + if (field != null) { + return field + } + val fileData = getFileData() + if (fileData != null) { + field = ResourceTable() + } + return field ?: ResourceTable() + } + + fun getFileData(): String? = "" +} + +class ResourceTable diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt.txt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt.txt new file mode 100644 index 00000000000..83449a62937 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt.txt @@ -0,0 +1,45 @@ +class Test { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + var resourceTable: ResourceTable? + field = null + get(): ResourceTable? { + when { + EQEQ(arg0 = .#resourceTable, arg1 = null).not() -> { // BLOCK + return .#resourceTable + } + } + val fileData: String? = .getFileData() + when { + EQEQ(arg0 = fileData, arg1 = null).not() -> { // BLOCK + .#resourceTable = ResourceTable() + } + } + return { // BLOCK + val tmp0_elvis_lhs: ResourceTable? = .#resourceTable + when { + EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> ResourceTable() + else -> tmp0_elvis_lhs + } + } + } + set + + fun getFileData(): String? { + return "" + } + +} + +class ResourceTable { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} diff --git a/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.sig.kt.txt b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.sig.kt.txt new file mode 100644 index 00000000000..27d1488f83b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.sig.kt.txt @@ -0,0 +1,45 @@ +// CHECK: +// Mangled name: ResourceTable +// Public signature: /ResourceTable|null[0] +class ResourceTable { + // CHECK: + // Mangled name: ResourceTable#(){} + // Public signature: /ResourceTable.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + +} + +// CHECK: +// Mangled name: Test +// Public signature: /Test|null[0] +class Test { + // CHECK: + // Mangled name: Test{}resourceTable + // Public signature: /Test.resourceTable|5106462391401126974[0] + // Public signature debug description: {}resourceTable + var resourceTable: ResourceTable? + // CHECK JVM_IR: + // Mangled name: Test#(){}ResourceTable? + // Public signature: /Test.resourceTable.|-8031293433039158174[0] + // Public signature debug description: (){}ResourceTable? + get(): ResourceTable? + // CHECK: + // Mangled name: Test#(ResourceTable?){} + // Public signature: /Test.resourceTable.|-5872518901213324823[0] + // Public signature debug description: (ResourceTable?){} + set + + // CHECK: + // Mangled name: Test#(){} + // Public signature: /Test.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + + // CHECK JVM_IR: + // Mangled name: Test#getFileData(){}kotlin.String? + // Public signature: /Test.getFileData|5079278953481470574[0] + // Public signature debug description: getFileData(){}kotlin.String? + fun getFileData(): String? + +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 535be3d4d76..a106bab1673 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -2682,6 +2682,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + @Test + @TestMetadata("elvisOnBackingFieldInGetter.kt") + public void testElvisOnBackingFieldInGetter() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/elvisOnBackingFieldInGetter.kt"); + } + @Test @TestMetadata("emptyWhen.kt") public void testEmptyWhen() throws Exception {