diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt index a6a9fd3fbfd..62830ce0160 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt @@ -5,13 +5,10 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import com.intellij.lang.LighterASTNode -import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.getChildren import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirClass @@ -23,23 +20,11 @@ object FirDelegationInInterfaceChecker : FirMemberDeclarationChecker() { return } - declaration.source?.findSuperTypeDelegation()?.let { - reporter.report(declaration.superTypeRefs.getOrNull(it)?.source) - } - } - - private fun FirSourceElement.findSuperTypeDelegation(): Int = - lighterASTNode.findSuperTypeDelegation(treeStructure) - - private fun LighterASTNode.findSuperTypeDelegation(tree: FlyweightCapableTreeStructure): Int { - val children = getChildren(tree) - return if (children.isNotEmpty()) { - children.find { it?.tokenType == KtNodeTypes.SUPER_TYPE_LIST } - ?.getChildren(tree) - ?.indexOfFirst { it?.tokenType == KtNodeTypes.DELEGATED_SUPER_TYPE_ENTRY } - ?: -1 - } else { - -1 + for (superTypeRef in declaration.superTypeRefs) { + val source = superTypeRef.source ?: continue + if (source.treeStructure.getParent(source.lighterASTNode)?.tokenType == KtNodeTypes.DELEGATED_SUPER_TYPE_ENTRY) { + reporter.report(source) + } } }