diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt index b7fc95e6ae1..ab8e0c9a8a6 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt @@ -336,7 +336,10 @@ internal class ClassMemberGenerator( it.dispatchReceiver = visitor.convertToIrExpression(firDispatchReceiver) } with(callGenerator) { - it.applyCallArguments(this@toIrDelegatingConstructorCall, annotationMode = false) + declarationStorage.enterScope(irConstructorSymbol.owner) + val result = it.applyCallArguments(this@toIrDelegatingConstructorCall, annotationMode = false) + declarationStorage.leaveScope(irConstructorSymbol.owner) + result } } } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index f1da3a1fe33..5ba65444c02 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2542,6 +2542,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/kt43342.kt"); } + @Test + @TestMetadata("lambdaInEnumEntryConstructorCall.kt") + public void testLambdaInEnumEntryConstructorCall() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt"); + } + @Test @TestMetadata("localClassUsedBeforeDeclaration.kt") public void testLocalClassUsedBeforeDeclaration() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.ir.txt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.ir.txt new file mode 100644 index 00000000000..a7d42f2db4f --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.ir.txt @@ -0,0 +1,111 @@ +FILE fqName: fileName:/lambdaInEnumEntryConstructorCall.kt + CLASS CLASS name:Wrapper modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Wrapper + CONSTRUCTOR visibility:public <> (baseUrl:kotlin.String) returnType:.Wrapper [primary] + VALUE_PARAMETER name:baseUrl index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Wrapper modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:baseUrl visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private + EXPRESSION_BODY + GET_VAR 'baseUrl: kotlin.String declared in .Wrapper.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Wrapper) returnType:kotlin.String + correspondingProperty: PROPERTY name:baseUrl visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Wrapper + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Wrapper' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .Wrapper declared in .Wrapper.' type=.Wrapper origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Wrapper, :kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:baseUrl visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Wrapper + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Wrapper declared in .Wrapper.' type=.Wrapper origin=null + value: GET_VAR ': kotlin.String declared in .Wrapper.' 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 [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 ENUM_CLASS name:ConfigurationParameter modality:OPEN visibility:public superTypes:[kotlin.Enum<.ConfigurationParameter>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ConfigurationParameter + ENUM_ENTRY name:BASE_URL + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor (apply: kotlin.Function2.Wrapper, kotlin.Unit>) declared in .ConfigurationParameter' + apply: FUN_EXPR type=kotlin.Function2.Wrapper, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (value:kotlin.String, nc:.Wrapper) returnType:kotlin.Unit + VALUE_PARAMETER name:value index:0 type:kotlin.String + VALUE_PARAMETER name:nc index:1 type:.Wrapper + BLOCK_BODY + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null + message: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="Base url updated from config parameters " + other: CALL 'public final fun (): kotlin.String declared in .Wrapper' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR 'nc: .Wrapper declared in .ConfigurationParameter.' type=.Wrapper origin=null + other: CONST String type=kotlin.String value=" -> " + other: GET_VAR 'value: kotlin.String declared in .ConfigurationParameter.' type=kotlin.String origin=null + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in .Wrapper' type=kotlin.Unit origin=EQ + $this: GET_VAR 'nc: .Wrapper declared in .ConfigurationParameter.' type=.Wrapper origin=null + : GET_VAR 'value: kotlin.String declared in .ConfigurationParameter.' type=kotlin.String origin=null + CONSTRUCTOR visibility:private <> (apply:kotlin.Function2.Wrapper, kotlin.Unit>) returnType:.ConfigurationParameter + VALUE_PARAMETER name:apply index:0 type:kotlin.Function2.Wrapper, kotlin.Unit> + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' + : .ConfigurationParameter + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:ConfigurationParameter modality:OPEN visibility:public superTypes:[kotlin.Enum<.ConfigurationParameter>]' + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.ConfigurationParameter> + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.ConfigurationParameter + VALUE_PARAMETER name:value index:0 type:kotlin.String + SYNTHETIC_BODY kind=ENUM_VALUEOF + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.ConfigurationParameter) returnType:kotlin.Int [fake_override,operator] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + VALUE_PARAMETER name:other index:0 type:.ConfigurationParameter + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] + overridden: + public final fun hashCode (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final name: kotlin.String [val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final ordinal: kotlin.Int [val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.kt.txt new file mode 100644 index 00000000000..a1d1c7aa375 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.fir.kt.txt @@ -0,0 +1,32 @@ +class Wrapper { + constructor(baseUrl: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + var baseUrl: String + field = baseUrl + get + set + +} + +open enum class ConfigurationParameter : Enum { + BASE_URL = ConfigurationParameter(apply = local fun (value: String, nc: Wrapper) { + println(message = "Base url updated from config parameters ".plus(other = nc.()).plus(other = " -> ").plus(other = value)) + nc.( = value) + } +) + + private constructor(apply: Function2) { + super/*Enum*/() + /* () */ + + } + + fun values(): Array /* Synthetic body for ENUM_VALUES */ + + fun valueOf(value: String): ConfigurationParameter /* Synthetic body for ENUM_VALUEOF */ + +} diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.ir.txt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.ir.txt new file mode 100644 index 00000000000..d98cd523216 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.ir.txt @@ -0,0 +1,119 @@ +FILE fqName: fileName:/lambdaInEnumEntryConstructorCall.kt + CLASS CLASS name:Wrapper modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Wrapper + CONSTRUCTOR visibility:public <> (baseUrl:kotlin.String) returnType:.Wrapper [primary] + VALUE_PARAMETER name:baseUrl index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Wrapper modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:baseUrl visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private + EXPRESSION_BODY + GET_VAR 'baseUrl: kotlin.String declared in .Wrapper.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Wrapper) returnType:kotlin.String + correspondingProperty: PROPERTY name:baseUrl visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Wrapper + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Wrapper' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .Wrapper declared in .Wrapper.' type=.Wrapper origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Wrapper, :kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:baseUrl visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Wrapper + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:baseUrl type:kotlin.String visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Wrapper declared in .Wrapper.' type=.Wrapper origin=null + value: GET_VAR ': kotlin.String declared in .Wrapper.' 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 [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 ENUM_CLASS name:ConfigurationParameter modality:FINAL visibility:public superTypes:[kotlin.Enum<.ConfigurationParameter>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ConfigurationParameter + ENUM_ENTRY name:BASE_URL + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor (apply: kotlin.Function2.Wrapper, kotlin.Unit>) declared in .ConfigurationParameter' + apply: FUN_EXPR type=kotlin.Function2.Wrapper, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (value:kotlin.String, nc:.Wrapper) returnType:kotlin.Unit + VALUE_PARAMETER name:value index:0 type:kotlin.String + VALUE_PARAMETER name:nc index:1 type:.Wrapper + BLOCK_BODY + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null + message: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="Base url updated from config parameters " + other: CALL 'public final fun (): kotlin.String declared in .Wrapper' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR 'nc: .Wrapper declared in .ConfigurationParameter.' type=.Wrapper origin=null + other: CONST String type=kotlin.String value=" -> " + other: GET_VAR 'value: kotlin.String declared in .ConfigurationParameter.' type=kotlin.String origin=null + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in .Wrapper' type=kotlin.Unit origin=EQ + $this: GET_VAR 'nc: .Wrapper declared in .ConfigurationParameter.' type=.Wrapper origin=null + : GET_VAR 'value: kotlin.String declared in .ConfigurationParameter.' type=kotlin.String origin=null + CONSTRUCTOR visibility:private <> (apply:kotlin.Function2.Wrapper, kotlin.Unit>) returnType:.ConfigurationParameter + VALUE_PARAMETER name:apply index:0 type:kotlin.Function2.Wrapper, kotlin.Unit> + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' + : .ConfigurationParameter + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:ConfigurationParameter modality:FINAL visibility:public superTypes:[kotlin.Enum<.ConfigurationParameter>]' + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final name: kotlin.String [val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final ordinal: kotlin.Int [val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>, other:.ConfigurationParameter) returnType:kotlin.Int [fake_override,operator] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + VALUE_PARAMETER name:other index:0 type:.ConfigurationParameter + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.Unit [fake_override] + overridden: + protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:@[FlexibleNullability] java.lang.Class<@[FlexibleNullability] .ConfigurationParameter?>? [fake_override] + overridden: + public final fun getDeclaringClass (): @[FlexibleNullability] java.lang.Class<@[FlexibleNullability] E of kotlin.Enum?>? declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.Int [fake_override] + overridden: + public final fun hashCode (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<.ConfigurationParameter>) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.ConfigurationParameter> + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.ConfigurationParameter> + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.ConfigurationParameter + VALUE_PARAMETER name:value index:0 type:kotlin.String + SYNTHETIC_BODY kind=ENUM_VALUEOF diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt new file mode 100644 index 00000000000..be7ebf3e5bd --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt @@ -0,0 +1,14 @@ +// WITH_STDLIB +// KT-50774 +class Wrapper(var baseUrl: String) + +enum class ConfigurationParameter { + BASE_URL( + { value, nc -> + println("Base url updated from config parameters " + nc.baseUrl + " -> " + value) + nc.baseUrl = value + } + ); + + constructor(apply: (String, Wrapper) -> Unit) {} +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt new file mode 100644 index 00000000000..3a8e58ed3e0 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt @@ -0,0 +1,33 @@ +class Wrapper { + constructor(baseUrl: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + var baseUrl: String + field = baseUrl + get + set + +} + +enum class ConfigurationParameter : Enum { + BASE_URL = ConfigurationParameter(apply = local fun (value: String, nc: Wrapper) { + println(message = "Base url updated from config parameters ".plus(other = nc.()).plus(other = " -> ").plus(other = value)) + nc.( = value) + } +) + + private constructor(apply: Function2) { + super/*Enum*/() + /* () */ + + } + + fun values(): Array /* Synthetic body for ENUM_VALUES */ + + fun valueOf(value: String): ConfigurationParameter /* Synthetic body for ENUM_VALUEOF */ + +} + 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 063eaff8bbd..e2a8fb81333 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 @@ -2542,6 +2542,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/kt43342.kt"); } + @Test + @TestMetadata("lambdaInEnumEntryConstructorCall.kt") + public void testLambdaInEnumEntryConstructorCall() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt"); + } + @Test @TestMetadata("localClassUsedBeforeDeclaration.kt") public void testLocalClassUsedBeforeDeclaration() 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 0d6a235143c..95e21790c8a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java @@ -1882,6 +1882,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase { runTest("compiler/testData/ir/irText/firProblems/kt43342.kt"); } + @TestMetadata("lambdaInEnumEntryConstructorCall.kt") + public void testLambdaInEnumEntryConstructorCall() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt"); + } + @TestMetadata("localClassUsedBeforeDeclaration.kt") public void testLocalClassUsedBeforeDeclaration() throws Exception { runTest("compiler/testData/ir/irText/firProblems/localClassUsedBeforeDeclaration.kt");