From b68a26865a1982d8073eb0240b4928b5e1428b03 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 16 Feb 2023 19:35:29 +0100 Subject: [PATCH] FIR2IR: add test for KT-55465 --- .../ir/FirLightTreeIrTextTestGenerated.java | 6 ++ .../runners/ir/FirPsiIrTextTestGenerated.java | 6 ++ .../ErrorInDefaultValue.fir.ir.txt | 92 +++++++++++++++++++ .../ErrorInDefaultValue.fir.kt.txt | 34 +++++++ .../firProblems/ErrorInDefaultValue.ir.txt | 90 ++++++++++++++++++ .../irText/firProblems/ErrorInDefaultValue.kt | 9 ++ .../firProblems/ErrorInDefaultValue.kt.txt | 34 +++++++ .../test/runners/ir/IrTextTestGenerated.java | 6 ++ .../klib/KlibTextTestCaseGenerated.java | 5 + 9 files changed, 282 insertions(+) create mode 100644 compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt create mode 100644 compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeIrTextTestGenerated.java index 3a660bed70d..a9b5082b2e8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeIrTextTestGenerated.java @@ -2606,6 +2606,12 @@ public class FirLightTreeIrTextTestGenerated extends AbstractFirLightTreeIrTextT runTest("compiler/testData/ir/irText/firProblems/emptyWhen.kt"); } + @Test + @TestMetadata("ErrorInDefaultValue.kt") + public void testErrorInDefaultValue() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt"); + } + @Test @TestMetadata("Fir2IrClassifierStorage.kt") public void testFir2IrClassifierStorage() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiIrTextTestGenerated.java index 406a51cf1b4..a4a59107bff 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiIrTextTestGenerated.java @@ -2606,6 +2606,12 @@ public class FirPsiIrTextTestGenerated extends AbstractFirPsiIrTextTest { runTest("compiler/testData/ir/irText/firProblems/emptyWhen.kt"); } + @Test + @TestMetadata("ErrorInDefaultValue.kt") + public void testErrorInDefaultValue() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt"); + } + @Test @TestMetadata("Fir2IrClassifierStorage.kt") public void testFir2IrClassifierStorage() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt new file mode 100644 index 00000000000..4592e4885bb --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt @@ -0,0 +1,92 @@ +FILE fqName: fileName:/ErrorInDefaultValue.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:f visibility:public modality:ABSTRACT <> ($this:.A, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:x index:0 type:kotlin.String + EXPRESSION_BODY + CONST String type=kotlin.String value="OK" + 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 [operator] 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:B modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:public <> () returnType:.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[.A]' + FUN name:f visibility:public modality:OPEN <> ($this:.B, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun f (x: kotlin.String): kotlin.String declared in .A + $this: VALUE_PARAMETER name: type:.B + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun f (x: kotlin.String): kotlin.String declared in .B' + GET_VAR 'x: kotlin.String declared in .B.f' type=kotlin.String origin=null + 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 [fake_override,operator] declared in .A + $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 [fake_override] declared in .A + $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 [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (x:.A) returnType:.C [primary] + VALUE_PARAMETER name:x index:0 type:.A + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A]' + FUN DELEGATED_MEMBER name:f visibility:public modality:OPEN <> ($this:.C, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun f (x: kotlin.String): kotlin.String declared in .A + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:x index:0 type:kotlin.String + EXPRESSION_BODY + ERROR_EXPR 'Stub expression for default value of x' type=kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun f (x: kotlin.String): kotlin.String declared in .C' + CALL 'public abstract fun f (x: kotlin.String): kotlin.String declared in .A' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final]' type=.A origin=null + receiver: GET_VAR ': .C declared in .C.f' type=.C origin=null + x: GET_VAR 'x: kotlin.String declared in .C.f' type=kotlin.String origin=null + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: .A declared in .C.' type=.A origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:.A + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .A declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final]' type=.A origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + 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 [fake_override,operator] declared in .A + $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 [fake_override] declared in .A + $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 [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt new file mode 100644 index 00000000000..208c1b5ddda --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt @@ -0,0 +1,34 @@ +interface A { + abstract fun f(x: String = "OK"): String + +} + +class B : A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun f(x: String): String { + return x + } + +} + +class C : A { + constructor(x: A) /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun f(x: String = error("") /* ErrorExpression */): String { + return .#x.f(x = x) + } + + val x: A + field = x + get + +} diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.ir.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.ir.txt new file mode 100644 index 00000000000..6180a5e7310 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.ir.txt @@ -0,0 +1,90 @@ +FILE fqName: fileName:/ErrorInDefaultValue.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:f visibility:public modality:ABSTRACT <> ($this:.A, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:x index:0 type:kotlin.String + EXPRESSION_BODY + CONST String type=kotlin.String value="OK" + 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 [operator] 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:B modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:public <> () returnType:.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[.A]' + FUN name:f visibility:public modality:OPEN <> ($this:.B, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun f (x: kotlin.String): kotlin.String declared in .A + $this: VALUE_PARAMETER name: type:.B + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun f (x: kotlin.String): kotlin.String declared in .B' + GET_VAR 'x: kotlin.String declared in .B.f' type=kotlin.String origin=null + 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 [fake_override,operator] declared in .A + $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 [fake_override] declared in .A + $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 [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (x:.A) returnType:.C [primary] + VALUE_PARAMETER name:x index:0 type:.A + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: .A declared in .C.' type=.A origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:.A + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .A declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final]' type=.A origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN DELEGATED_MEMBER name:f visibility:public modality:OPEN <> ($this:.C, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun f (x: kotlin.String): kotlin.String declared in .A + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun f (x: kotlin.String): kotlin.String declared in .C' + CALL 'public abstract fun f (x: kotlin.String): kotlin.String declared in .A' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.A visibility:private [final]' type=.A origin=null + receiver: GET_VAR ': .C declared in .C.f' type=.C origin=null + x: GET_VAR 'x: kotlin.String declared in .C.f' type=kotlin.String origin=null + 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 [fake_override,operator] declared in .A + $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 [fake_override] declared in .A + $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 [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt new file mode 100644 index 00000000000..1ff793d939b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt @@ -0,0 +1,9 @@ +interface A { + fun f(x: String = "OK"): String +} + +class B : A { + override fun f(x: String) = x +} + +class C(val x: A) : A by x diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt.txt new file mode 100644 index 00000000000..ad687810b26 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt.txt @@ -0,0 +1,34 @@ +interface A { + abstract fun f(x: String = "OK"): String + +} + +class B : A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun f(x: String): String { + return x + } + +} + +class C : A { + constructor(x: A) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: A + field = x + get + + override fun f(x: String): String { + return .#x.f(x = x) + } + +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index e2e4c0a07b8..9bea660d1db 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2606,6 +2606,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/emptyWhen.kt"); } + @Test + @TestMetadata("ErrorInDefaultValue.kt") + public void testErrorInDefaultValue() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt"); + } + @Test @TestMetadata("Fir2IrClassifierStorage.kt") public void testFir2IrClassifierStorage() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java index 6ca2fa511df..3ddd1cc3f42 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java @@ -1915,6 +1915,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase { runTest("compiler/testData/ir/irText/firProblems/emptyWhen.kt"); } + @TestMetadata("ErrorInDefaultValue.kt") + public void testErrorInDefaultValue() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.kt"); + } + @TestMetadata("Fir2IrClassifierStorage.kt") public void testFir2IrClassifierStorage() throws Exception { runTest("compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.kt");