[FIR/IR generator] Factor out adding pure abstract element as parent
This commit is contained in:
committed by
Space Team
parent
5798021e4b
commit
04c5ac0eb6
+1
-1
@@ -22,7 +22,7 @@ abstract class AbstractElement<Element, Field> : ElementOrRef<Element, Field>, F
|
||||
|
||||
abstract val elementParents: List<ElementRef<Element, Field>>
|
||||
|
||||
abstract val otherParents: List<ClassRef<*>>
|
||||
abstract val otherParents: MutableList<ClassRef<*>>
|
||||
|
||||
val parentRefs: List<ClassOrElementRef>
|
||||
get() = elementParents + otherParents
|
||||
|
||||
-4
@@ -9,7 +9,3 @@ interface ImplementationKindOwner : Importable {
|
||||
var kind: ImplementationKind?
|
||||
val allParents: List<ImplementationKindOwner>
|
||||
}
|
||||
|
||||
val ImplementationKindOwner.needPureAbstractElement: Boolean
|
||||
get() = !(kind?.isInterface ?: false) &&
|
||||
allParents.none { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.generators.tree
|
||||
|
||||
import org.jetbrains.kotlin.generators.tree.printer.braces
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.util.*
|
||||
import kotlin.reflect.KClass
|
||||
@@ -196,3 +197,17 @@ inline fun <reified T : Any> type(vararg args: TypeRef) = T::class.asRef<Positio
|
||||
|
||||
fun type(packageName: String, name: String, kind: TypeKind = TypeKind.Interface) =
|
||||
ClassRef<PositionTypeParameterRef>(kind, packageName, name)
|
||||
|
||||
val ClassOrElementRef.typeKind: TypeKind
|
||||
get() = when (this) {
|
||||
is ElementOrRef<*, *> -> element.kind!!.typeKind
|
||||
is ClassRef<*> -> kind
|
||||
}
|
||||
|
||||
fun ClassOrElementRef.inheritanceClauseParenthesis(): String = when (this) {
|
||||
is ElementOrRef<*, *> -> element.kind.braces()
|
||||
is ClassRef<*> -> when (kind) {
|
||||
TypeKind.Class -> "()"
|
||||
TypeKind.Interface -> ""
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.generators.tree
|
||||
|
||||
val ImplementationKindOwner.needPureAbstractElement: Boolean
|
||||
get() = !(kind?.isInterface ?: false) &&
|
||||
allParents.none { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }
|
||||
|
||||
fun addPureAbstractElement(elements: List<AbstractElement<*, *>>, pureAbstractElement: ClassRef<*>) {
|
||||
for (el in elements) {
|
||||
if (el.needPureAbstractElement) {
|
||||
el.otherParents.add(pureAbstractElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user