Removed useless as casts from compiler code

It allows compiling code with K2 and enabled `-Werror`
This commit is contained in:
Ivan Kochurkin
2023-10-20 13:44:09 +02:00
committed by Space Team
parent d50c6f1b6d
commit 1827df82c4
40 changed files with 77 additions and 117 deletions
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.resolve.inference.model.ConeReceiverConstraintPo
import org.jetbrains.kotlin.fir.resolve.inference.preprocessCallableReference
import org.jetbrains.kotlin.fir.resolve.inference.preprocessLambdaArgument
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolvedTypeDeclaration
import org.jetbrains.kotlin.fir.returnExpressions
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
@@ -362,9 +361,7 @@ private fun checkApplicabilityForArgumentType(
return ConeTypeIntersector.intersectTypes(context.session.typeContext, constraintTypes)
}
val originalTypeParameter =
(lookupTag as? ConeTypeVariableTypeConstructor)?.originalTypeParameter as? ConeTypeParameterLookupTag
val originalTypeParameter = lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag
if (originalTypeParameter != null)
return ConeTypeParameterTypeImpl(originalTypeParameter, type.isNullable, type.attributes)
} else if (type is ConeIntegerLiteralType) {
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.isClass
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.FirVariable
import org.jetbrains.kotlin.fir.declarations.utils.modality
import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
@@ -27,7 +26,6 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addIfNotNull
fun BodyResolveComponents.findTypesForSuperCandidates(
superTypeRefs: List<FirTypeRef>,
@@ -144,7 +142,7 @@ private fun BodyResolveComponents.getPropertyMembers(type: ConeKotlinType, name:
scopeSession = scopeSession,
callableCopyTypeCalculator = CallableCopyTypeCalculator.DoNothing,
requiredMembersPhase = FirResolvePhase.STATUS,
)?.processPropertiesByName(name) { addIfNotNull(it.fir as? FirVariable) }
)?.processPropertiesByName(name) { add(it.fir) }
}
@@ -421,7 +421,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
processBlocks = true
) { candidate ->
candidate.postponedAtoms.forEach { atom ->
notAnalyzedArguments.addIfNotNull((atom as? PostponedResolvedAtom)?.takeUnless { it.analyzed })
notAnalyzedArguments.addIfNotNull(atom.takeUnless { it.analyzed })
}
}
}
@@ -1027,7 +1027,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
),
)
(result as? FirVariableAssignment)?.let { dataFlowAnalyzer.exitVariableAssignment(it) }
dataFlowAnalyzer.exitVariableAssignment(result)
return result
}