[FIR] Remove useless code discovered by code coverage
This commit is contained in:
committed by
Space Team
parent
9486d966dc
commit
ca93165044
-1
@@ -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)
|
||||
|
||||
+3
-6
@@ -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(
|
||||
|
||||
+2
-23
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -164,11 +164,10 @@ fun lookupSuperTypes(
|
||||
symbol: FirClassifierSymbol<*>,
|
||||
lookupInterfaces: Boolean,
|
||||
deep: Boolean,
|
||||
useSiteSession: FirSession,
|
||||
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default
|
||||
useSiteSession: FirSession
|
||||
): List<ConeClassLikeType> {
|
||||
return SmartList<ConeClassLikeType>().also {
|
||||
symbol.collectSuperTypes(it, SmartSet.create(), deep, lookupInterfaces, false, useSiteSession, supertypeSupplier)
|
||||
symbol.collectSuperTypes(it, SmartSet.create(), deep, lookupInterfaces, false, useSiteSession, SupertypeSupplier.Default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -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<Name> = emptySet()
|
||||
|
||||
override fun getClassifierNames(): Set<Name> = delegate.getClassifierNames()
|
||||
}
|
||||
|
||||
+1
-2
@@ -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
|
||||
|
||||
@@ -40,13 +40,6 @@ enum class ProcessResult {
|
||||
}
|
||||
|
||||
abstract class TowerScopeLevel {
|
||||
|
||||
sealed class Token<out T : FirBasedSymbol<*>> {
|
||||
object Properties : Token<FirVariableSymbol<*>>()
|
||||
object Functions : Token<FirFunctionSymbol<*>>()
|
||||
object Objects : Token<FirBasedSymbol<*>>()
|
||||
}
|
||||
|
||||
abstract fun processFunctionsByName(info: CallInfo, processor: TowerScopeLevelProcessor<FirFunctionSymbol<*>>): ProcessResult
|
||||
|
||||
abstract fun processPropertiesByName(info: CallInfo, processor: TowerScopeLevelProcessor<FirVariableSymbol<*>>): ProcessResult
|
||||
|
||||
@@ -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<FirAnnotation>
|
||||
get() = emptyList()
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
|
||||
throw AssertionError("Mutating annotations of FirStubStatement is not supported")
|
||||
}
|
||||
|
||||
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirStatement {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user