From ad2c77b298aac53c70eef165bebf631292642e27 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 30 Nov 2023 14:41:50 +0100 Subject: [PATCH] KT-59732 [FIR] Get rid of `FirErrorImport` node It's no longer relevant, since it's not created anywhere --- .../checkers/declaration/FirImportsChecker.kt | 1 - .../ErrorNodeDiagnosticCollectorComponent.kt | 5 --- .../kotlin/fir/declarations/FirErrorImport.kt | 38 ---------------- .../builder/FirErrorImportBuilder.kt | 43 ------------------ .../declarations/impl/FirErrorImportImpl.kt | 44 ------------------- .../kotlin/fir/visitors/FirTransformer.kt | 8 ---- .../kotlin/fir/visitors/FirVisitor.kt | 3 -- .../kotlin/fir/visitors/FirVisitorVoid.kt | 8 ---- .../fir/tree/generator/FirTreeBuilder.kt | 1 - .../generator/ImplementationConfigurator.kt | 4 -- .../fir/tree/generator/NodeConfigurator.kt | 4 -- 11 files changed, 159 deletions(-) delete mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorImport.kt delete mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorImportBuilder.kt delete mode 100644 compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorImportImpl.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirImportsChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirImportsChecker.kt index 6448fa24f3f..d4ed890f61a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirImportsChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirImportsChecker.kt @@ -44,7 +44,6 @@ object FirImportsChecker : FirFileChecker() { override fun check(declaration: FirFile, context: CheckerContext, reporter: DiagnosticReporter) { declaration.imports.forEach { import -> if (import.source?.kind?.shouldSkipErrorTypeReporting == true) return@forEach - if (import is FirErrorImport) return@forEach if (import.isAllUnder) { if (import is FirResolvedImport) { checkAllUnderFromObject(import, context, reporter) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index af4c3a6f07a..139cb41126c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -122,11 +122,6 @@ class ErrorNodeDiagnosticCollectorComponent( reportFirDiagnostic(errorResolvedQualifier.diagnostic, source, data) } - override fun visitErrorImport(errorImport: FirErrorImport, data: CheckerContext) { - val source = errorImport.source - reportFirDiagnostic(errorImport.diagnostic, source, data) - } - override fun visitErrorPrimaryConstructor(errorPrimaryConstructor: FirErrorPrimaryConstructor, data: CheckerContext) { reportFirDiagnostic(errorPrimaryConstructor.diagnostic, errorPrimaryConstructor.source, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorImport.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorImport.kt deleted file mode 100644 index 975c43f2480..00000000000 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorImport.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// This file was generated automatically. See compiler/fir/tree/tree-generator/Readme.md. -// DO NOT MODIFY IT MANUALLY. - -package org.jetbrains.kotlin.fir.declarations - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic -import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name - -/** - * Generated from: [org.jetbrains.kotlin.fir.tree.generator.FirTreeBuilder.errorImport] - */ -abstract class FirErrorImport : FirImport(), FirDiagnosticHolder { - abstract override val source: KtSourceElement? - abstract override val importedFqName: FqName? - abstract override val isAllUnder: Boolean - abstract override val aliasName: Name? - abstract override val aliasSource: KtSourceElement? - abstract override val diagnostic: ConeDiagnostic - abstract val delegate: FirImport - - override fun accept(visitor: FirVisitor, data: D): R = - visitor.visitErrorImport(this, data) - - @Suppress("UNCHECKED_CAST") - override fun transform(transformer: FirTransformer, data: D): E = - transformer.transformErrorImport(this, data) as E -} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorImportBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorImportBuilder.kt deleted file mode 100644 index c6d2e1e16b0..00000000000 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirErrorImportBuilder.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -// This file was generated automatically. See compiler/fir/tree/tree-generator/Readme.md. -// DO NOT MODIFY IT MANUALLY. - -@file:Suppress("DuplicatedCode", "unused") - -package org.jetbrains.kotlin.fir.declarations.builder - -import kotlin.contracts.* -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.builder.FirBuilderDsl -import org.jetbrains.kotlin.fir.declarations.FirErrorImport -import org.jetbrains.kotlin.fir.declarations.FirImport -import org.jetbrains.kotlin.fir.declarations.impl.FirErrorImportImpl -import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic - -@FirBuilderDsl -class FirErrorImportBuilder { - var aliasSource: KtSourceElement? = null - lateinit var diagnostic: ConeDiagnostic - lateinit var delegate: FirImport - - fun build(): FirErrorImport { - return FirErrorImportImpl( - aliasSource, - diagnostic, - delegate, - ) - } - -} - -@OptIn(ExperimentalContracts::class) -inline fun buildErrorImport(init: FirErrorImportBuilder.() -> Unit): FirErrorImport { - contract { - callsInPlace(init, InvocationKind.EXACTLY_ONCE) - } - return FirErrorImportBuilder().apply(init).build() -} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorImportImpl.kt deleted file mode 100644 index 0e92dfbf027..00000000000 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorImportImpl.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -// This file was generated automatically. See compiler/fir/tree/tree-generator/Readme.md. -// DO NOT MODIFY IT MANUALLY. - -@file:Suppress("DuplicatedCode", "unused") - -package org.jetbrains.kotlin.fir.declarations.impl - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.declarations.FirErrorImport -import org.jetbrains.kotlin.fir.declarations.FirImport -import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name - -internal class FirErrorImportImpl( - override val aliasSource: KtSourceElement?, - override val diagnostic: ConeDiagnostic, - override var delegate: FirImport, -) : FirErrorImport() { - override val source: KtSourceElement? - get() = delegate.source - override val importedFqName: FqName? - get() = delegate.importedFqName - override val isAllUnder: Boolean - get() = delegate.isAllUnder - override val aliasName: Name? - get() = delegate.aliasName - - override fun acceptChildren(visitor: FirVisitor, data: D) { - delegate.accept(visitor, data) - } - - override fun transformChildren(transformer: FirTransformer, data: D): FirErrorImportImpl { - delegate = delegate.transform(transformer, data) - return this - } -} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt index 4026796d8ab..7cec3b028d2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt @@ -451,14 +451,6 @@ abstract class FirTransformer : FirVisitor() { return transformResolvedImport(resolvedImport, data) } - open fun transformErrorImport(errorImport: FirErrorImport, data: D): FirImport { - return transformElement(errorImport, data) - } - - final override fun visitErrorImport(errorImport: FirErrorImport, data: D): FirImport { - return transformErrorImport(errorImport, data) - } - open fun transformLoop(loop: FirLoop, data: D): FirStatement { return transformElement(loop, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt index 713df38a09c..0c9b0451e40 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt @@ -182,9 +182,6 @@ abstract class FirVisitor { open fun visitResolvedImport(resolvedImport: FirResolvedImport, data: D): R = visitElement(resolvedImport, data) - open fun visitErrorImport(errorImport: FirErrorImport, data: D): R = - visitElement(errorImport, data) - open fun visitLoop(loop: FirLoop, data: D): R = visitElement(loop, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt index ccede2e9dc9..81584150cf8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt @@ -451,14 +451,6 @@ abstract class FirVisitorVoid : FirVisitor() { visitElement(resolvedImport) } - final override fun visitErrorImport(errorImport: FirErrorImport, data: Nothing?) { - visitErrorImport(errorImport) - } - - open fun visitErrorImport(errorImport: FirErrorImport) { - visitElement(errorImport) - } - final override fun visitLoop(loop: FirLoop, data: Nothing?) { visitLoop(loop) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt index ca9988e5db0..353f3230547 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt @@ -79,7 +79,6 @@ object FirTreeBuilder : AbstractFirTreeBuilder() { val import by element(Declaration) val resolvedImport by element(Declaration, import) - val errorImport by element(Declaration, import, diagnosticHolder) val loop by sealedElement(Expression, statement, targetElement) val errorLoop by element(Expression, loop, diagnosticHolder) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index ab6d94dcea5..12e34bcb2bf 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -72,10 +72,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } } - impl(errorImport) { - delegateFields(listOf("aliasName", "importedFqName", "isAllUnder", "source"), "delegate") - } - fun ImplementationContext.commonAnnotationConfig() { defaultEmptyList("annotations") default("coneTypeOrNull") { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index 483c9f8f01e..9d6f2bbc333 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -530,10 +530,6 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild ) } - errorImport.configure { - +field("delegate", import) - } - annotation.configure { +field("useSiteTarget", annotationUseSiteTargetType, nullable = true, withReplace = true) +field("annotationTypeRef", typeRef, withReplace = true).withTransform()