Skip to content

Commit 7818baf

Browse files
committed
[FIR2IR] Fix problem with double-generation of local class members
1 parent 64fcbbc commit 7818baf

File tree

13 files changed

+15
-15
lines changed

13 files changed

+15
-15
lines changed

compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package org.jetbrains.kotlin.fir.backend.generators
77

88
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
9+
import org.jetbrains.kotlin.descriptors.Visibilities
910
import org.jetbrains.kotlin.fir.backend.*
1011
import org.jetbrains.kotlin.fir.declarations.*
1112
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
@@ -73,9 +74,20 @@ internal class ClassMemberGenerator(
7374
processedCallableNames += DataClassMembersGenerator(components).generateDataClassMembers(klass, irClass)
7475
}
7576
with(fakeOverrideGenerator) { irClass.addFakeOverrides(klass, processedCallableNames) }
76-
klass.declarations.forEach {
77-
if (it !is FirTypeAlias && (it !is FirConstructor || !it.isPrimary)) {
78-
it.accept(visitor, null)
77+
klass.declarations.forEach { declaration ->
78+
when {
79+
declaration is FirTypeAlias -> {
80+
}
81+
declaration is FirConstructor && declaration.isPrimary -> {
82+
}
83+
declaration is FirRegularClass && declaration.visibility == Visibilities.LOCAL -> {
84+
val irNestedClass = classifierStorage.getCachedIrClass(declaration)!!
85+
irNestedClass.parent = irClass
86+
conversionScope.withParent(irNestedClass) {
87+
convertClassContent(irNestedClass, declaration)
88+
}
89+
}
90+
else -> declaration.accept(visitor, null)
7991
}
8092
}
8193
annotationGenerator.generate(irClass, klass)

compiler/testData/codegen/box/classes/kt2607.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
fun box() : String {
32
val o = object {
43

compiler/testData/codegen/box/closures/captureInSuperConstructorCall/constructorParameterAndLocalCapturedInLambdaInLocalClass.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
open class Base(val fn: () -> String)
32

43
fun box(): String {

compiler/testData/codegen/box/closures/captureInSuperConstructorCall/constructorParameterCapturedInLambdaInLocalClass.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
open class Base(val fn: () -> String)
32

43
fun box(): String {

compiler/testData/codegen/box/closures/captureInSuperConstructorCall/constructorParameterCapturedInLambdaInLocalClass2.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
open class Base(val fn: () -> String)
32

43
fun box(): String {

compiler/testData/codegen/box/closures/captureInSuperConstructorCall/localCapturedInLambdaInInnerClassInLocalClass.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
open class Base(val fn: () -> String)
32

43
fun box(): String {

compiler/testData/codegen/box/defaultArguments/constructor/kt2852.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
fun box(): String {
32
val o = object {
43
inner class A(val value: String = "OK")

compiler/testData/codegen/box/innerNested/superConstructorCall/objectExtendsInnerOfLocalWithCapture.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
fun box(): String {
32
class Local {
43
open inner class Inner(val s: String) {

compiler/testData/codegen/box/localClasses/closureOfInnerLocalClass.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
// Enable for JVM backend when KT-8120 gets fixed
32
// IGNORE_BACKEND: JVM
43

compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_FIR: JVM_IR
21
// Enable for JVM backend when KT-8120 gets fixed
32
// IGNORE_BACKEND: JVM
43

0 commit comments

Comments
 (0)