diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirScopeProvider.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirScopeProvider.kt index 049efa5a0d1..6236e4dd5ae 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirScopeProvider.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirScopeProvider.kt @@ -246,7 +246,6 @@ internal class KtFirScopeProvider( private fun getScopeKind(firScope: FirScope, indexInTower: Int): KtScopeKind = when (firScope) { is FirNameAwareOnlyCallablesScope -> getScopeKind(firScope.delegate, indexInTower) - is FirNameAwareOnlyClassifiersScope -> getScopeKind(firScope.delegate, indexInTower) is FirLocalScope -> KtScopeKind.LocalScope(indexInTower) is FirTypeScope -> KtScopeKind.TypeScope(indexInTower) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt index 1f85cf4109c..41538f744a0 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInfixFunctionDeclarationChecker.kt @@ -17,13 +17,10 @@ import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction object FirInfixFunctionDeclarationChecker : FirBasicDeclarationChecker() { override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { if ((declaration as? FirMemberDeclaration)?.status?.isInfix != true) return - if (declaration is FirSimpleFunction) { - if (declaration.valueParameters.size != 1 || !hasExtensionOrDispatchReceiver(declaration, context)) { - reporter.reportOn(declaration.source, FirErrors.INAPPLICABLE_INFIX_MODIFIER, context) - } - return + val simpleFunction = declaration as FirSimpleFunction + if (simpleFunction.valueParameters.size != 1 || !hasExtensionOrDispatchReceiver(simpleFunction, context)) { + reporter.reportOn(declaration.source, FirErrors.INAPPLICABLE_INFIX_MODIFIER, context) } - reporter.reportOn(declaration.source, FirErrors.INAPPLICABLE_INFIX_MODIFIER, context) } private fun hasExtensionOrDispatchReceiver( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOuterClassArgumentsRequiredChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOuterClassArgumentsRequiredChecker.kt index 068a299916c..05890af4649 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOuterClassArgumentsRequiredChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOuterClassArgumentsRequiredChecker.kt @@ -11,9 +11,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.extractArgumentsTypeRefAndSource import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.ResolveStateAccess -import org.jetbrains.kotlin.fir.declarations.utils.classId -import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.isValidTypeParameterFromOuterDeclaration import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.toTypeProjections @@ -21,28 +18,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.* object FirOuterClassArgumentsRequiredChecker : FirRegularClassChecker() { - @OptIn(ResolveStateAccess::class) override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { // Checking the rest super types that weren't resolved on the first OUTER_CLASS_ARGUMENTS_REQUIRED check in FirTypeResolver - val oldResolveState = declaration.resolveState - val oldList = declaration.superTypeRefs.toList() - - try { - for (superTypeRef in declaration.superTypeRefs) { - checkOuterClassArgumentsRequired(superTypeRef, declaration, context, reporter) - } - } catch (e: ConcurrentModificationException) { - val newResolveState = declaration.resolveState - val newList = declaration.superTypeRefs.toList() - - throw IllegalStateException( - """ - CME while traversing superTypeRefs of declaration=${declaration.render()}: - classId: ${declaration.classId}, - oldState: $oldResolveState, oldList: ${oldList.joinToString { it.render() }}, - newState: $newResolveState, newList: ${newList.joinToString { it.render() }} - """.trimIndent(), e - ) + for (superTypeRef in declaration.superTypeRefs) { + checkOuterClassArgumentsRequired(superTypeRef, declaration, context, reporter) } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index d5390b2c860..6ebd581697a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirTypeAlias import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirStubStatement import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.render @@ -111,7 +110,6 @@ class Fir2IrImplicitCastInserter( override fun visitStatement(statement: FirStatement, data: IrElement): IrElement { return when (statement) { is FirTypeAlias -> data - FirStubStatement -> data is FirUnitExpression -> coerceToUnitIfNeeded(data as IrExpression, irBuiltIns) is FirBlock -> (data as IrContainerExpression).insertImplicitCasts() else -> statement.accept(this, data) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 58bf8b9b5b5..8e1954f1af5 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -26,7 +26,6 @@ import org.jetbrains.kotlin.fir.deserialization.toQualifiedPropertyAccessExpress import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirContractCallBlock import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition -import org.jetbrains.kotlin.fir.expressions.impl.FirStubStatement import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.resolve.isIteratorNext @@ -758,7 +757,6 @@ class Fir2IrVisitor( private fun FirStatement.toIrStatement(): IrStatement? { if (this is FirTypeAlias) return null - if (this == FirStubStatement) return null if (this is FirUnitExpression) return convertToIrExpression(this) if (this is FirContractCallBlock) return null if (this is FirBlock) return convertToIrExpression(this) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt index 12c6846b401..0f49105932c 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt @@ -164,11 +164,10 @@ fun lookupSuperTypes( symbol: FirClassifierSymbol<*>, lookupInterfaces: Boolean, deep: Boolean, - useSiteSession: FirSession, - supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default + useSiteSession: FirSession ): List { return SmartList().also { - symbol.collectSuperTypes(it, SmartSet.create(), deep, lookupInterfaces, false, useSiteSession, supertypeSupplier) + symbol.collectSuperTypes(it, SmartSet.create(), deep, lookupInterfaces, false, useSiteSession, SupertypeSupplier.Default) } } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirOnlyClassifiersScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirOnlyClassifiersScope.kt index 819f6d30eff..e21a959ec63 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirOnlyClassifiersScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirOnlyClassifiersScope.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor -import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.name.Name @@ -16,13 +15,3 @@ class FirOnlyClassifiersScope(val delegate: FirScope) : FirScope() { return delegate.processClassifiersByNameWithSubstitution(name, processor) } } - -class FirNameAwareOnlyClassifiersScope(val delegate: FirContainingNamesAwareScope) : FirContainingNamesAwareScope() { - override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) { - return delegate.processClassifiersByNameWithSubstitution(name, processor) - } - - override fun getCallableNames(): Set = emptySet() - - override fun getClassifierNames(): Set = delegate.getClassifierNames() -} diff --git a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt index 18b5c3dd66a..8ebcc672c8f 100644 --- a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt +++ b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusIm import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirContractCallBlock import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression -import org.jetbrains.kotlin.fir.expressions.impl.FirStubStatement import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.renderer.FirRenderer @@ -189,7 +188,7 @@ private fun throwTwiceVisitingError(element: FirElement, parent: FirElement?) { element is FirTypeProjection || element is FirValueParameter || element is FirAnnotation || element is FirFunctionTypeParameter || element is FirEmptyContractDescription || element is FirStubReference || element.isExtensionFunctionAnnotation || element is FirEmptyArgumentList || - element is FirStubStatement || element === FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS || + element === FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS || ((parent is FirContractCallBlock || parent is FirContractDescription) && element is FirFunctionCall) ) { return diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt index 0331a5b7fa5..4a91d54148b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt @@ -40,13 +40,6 @@ enum class ProcessResult { } abstract class TowerScopeLevel { - - sealed class Token> { - object Properties : Token>() - object Functions : Token>() - object Objects : Token>() - } - abstract fun processFunctionsByName(info: CallInfo, processor: TowerScopeLevelProcessor>): ProcessResult abstract fun processPropertiesByName(info: CallInfo, processor: TowerScopeLevelProcessor>): ProcessResult diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt deleted file mode 100644 index ba8c5f9a495..00000000000 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2020 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.fir.expressions.impl - -import org.jetbrains.kotlin.KtSourceElement -import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.FirPureAbstractElement -import org.jetbrains.kotlin.fir.expressions.FirAnnotation -import org.jetbrains.kotlin.fir.expressions.FirStatement -import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.fir.visitors.FirVisitor - -object FirStubStatement : FirPureAbstractElement(), FirStatement { - override val source: KtSourceElement? - get() = null - - override val annotations: List - get() = emptyList() - - override fun replaceAnnotations(newAnnotations: List) { - throw AssertionError("Mutating annotations of FirStubStatement is not supported") - } - - override fun transformAnnotations(transformer: FirTransformer, data: D): FirStatement { - return this - } - - override fun acceptChildren(visitor: FirVisitor, data: D) {} - - override fun transformChildren(transformer: FirTransformer, data: D): FirElement { - return this - } -} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt index aff4d1e2cdc..fbce1b03f0e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt @@ -481,11 +481,7 @@ class FirRenderer( } override fun visitStatement(statement: FirStatement) { - if (statement is FirStubStatement) { - print("[StubStatement]") - } else { - visitElement(statement) - } + visitElement(statement) } override fun visitReturnExpression(returnExpression: FirReturnExpression) {