[FIR generator] Deduplicate the logic of needPureAbstractElement
This commit is contained in:
committed by
Space Team
parent
45792c2e60
commit
9a4c28498c
+1
-1
@@ -98,7 +98,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
|
||||
print(" : ")
|
||||
if (!isInterface && !allParents.any { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }) {
|
||||
if (needPureAbstractElement) {
|
||||
print("${pureAbstractElementType.type}(), ")
|
||||
}
|
||||
print(allParents.joinToString { "${it.typeWithArguments}${it.kind.braces()}" })
|
||||
|
||||
-4
@@ -113,10 +113,6 @@ private fun List<String>.filterRedundantImports(
|
||||
}
|
||||
|
||||
|
||||
val ImplementationKindOwner.needPureAbstractElement: Boolean
|
||||
get() = (kind != ImplementationKind.Interface && kind != ImplementationKind.SealedInterface) && !allParents.any { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }
|
||||
|
||||
|
||||
val Field.isVal: Boolean
|
||||
get() = (this is FieldList && !isMutableOrEmpty) || (this is FieldWithDefault && origin is FieldList && !origin.isMutableOrEmpty) || !isMutable
|
||||
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ private fun markLeaves(elements: List<Element>) {
|
||||
|
||||
private fun addAbstractElement(elements: List<Element>) {
|
||||
for (el in elements) {
|
||||
if (el.kind!!.typeKind == TypeKind.Class && el.elementParents.none { it.element.kind!!.typeKind == TypeKind.Class }) {
|
||||
if (el.needPureAbstractElement) {
|
||||
el.otherParents += elementBaseType
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -8,4 +8,8 @@ package org.jetbrains.kotlin.generators.tree
|
||||
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 }
|
||||
Reference in New Issue
Block a user