[FIR] Get rid of all usages of cast in FIR modules
This commit is contained in:
committed by
teamcity
parent
ee21c966e1
commit
1cd4f3ad2f
+8
-2
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.toSymbol
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
@@ -94,7 +93,14 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
|
||||
}
|
||||
|
||||
Compatible !in compatibilityToMembersMap -> {
|
||||
reporter.reportOn(source, FirErrors.ACTUAL_WITHOUT_EXPECT, symbol, compatibilityToMembersMap.cast(), context)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
reporter.reportOn(
|
||||
source,
|
||||
FirErrors.ACTUAL_WITHOUT_EXPECT,
|
||||
symbol,
|
||||
compatibilityToMembersMap as Map<Incompatible<FirBasedSymbol<*>>, Collection<FirBasedSymbol<*>>>,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.types.AbstractTypeRefiner
|
||||
import org.jetbrains.kotlin.types.TypeCheckerState
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
|
||||
interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeContext {
|
||||
|
||||
@@ -260,10 +259,11 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
): CapturedTypeMarker {
|
||||
require(lowerType is ConeKotlinType?)
|
||||
require(constructorProjection is ConeTypeProjection)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ConeCapturedType(
|
||||
captureStatus,
|
||||
lowerType,
|
||||
constructor = ConeCapturedTypeConstructor(constructorProjection, constructorSupertypes.cast())
|
||||
constructor = ConeCapturedTypeConstructor(constructorProjection, constructorSupertypes as List<ConeKotlinType>)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -284,7 +284,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
|
||||
override fun SimpleTypeMarker.replaceArguments(newArguments: List<TypeArgumentMarker>): SimpleTypeMarker {
|
||||
require(this is ConeKotlinType)
|
||||
return this.withArguments(newArguments.cast<List<ConeTypeProjection>>().toTypedArray())
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this.withArguments((newArguments as List<ConeTypeProjection>).toTypedArray())
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.replaceArguments(replacement: (TypeArgumentMarker) -> TypeArgumentMarker): SimpleTypeMarker {
|
||||
@@ -506,7 +507,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker> {
|
||||
val builtInFunctionalType = getFunctionalTypeFromSupertypes().cast<ConeKotlinType>()
|
||||
val builtInFunctionalType = getFunctionalTypeFromSupertypes() as ConeKotlinType
|
||||
return buildList {
|
||||
// excluding return type
|
||||
for (index in 0 until builtInFunctionalType.argumentsCount() - 1) {
|
||||
@@ -529,7 +530,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
var functionalSupertype: KotlinTypeMarker? = null
|
||||
simpleType.anySuperTypeConstructor { type ->
|
||||
simpleType.fastCorrespondingSupertypes(type.typeConstructor())?.any { superType ->
|
||||
val isFunctional = superType.cast<ConeKotlinType>().isBuiltinFunctionalType(session)
|
||||
val isFunctional = (superType as ConeKotlinType).isBuiltinFunctionalType(session)
|
||||
if (isFunctional)
|
||||
functionalSupertype = superType
|
||||
isFunctional
|
||||
|
||||
+3
-3
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.filterIsInstanceWithChecker
|
||||
|
||||
class ConstraintSystemCompleter(components: BodyResolveComponents, private val context: BodyResolveContext) {
|
||||
@@ -220,8 +219,9 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
||||
resolutionContext: ResolutionContext,
|
||||
argument: PostponedAtomWithRevisableExpectedType,
|
||||
): Boolean = with(c) {
|
||||
val revisedExpectedType: ConeKotlinType =
|
||||
argument.revisedExpectedType?.takeIf { it.isFunctionOrKFunctionWithAnySuspendability() }?.cast() ?: return false
|
||||
val revisedExpectedType = argument.revisedExpectedType
|
||||
?.takeIf { it.isFunctionOrKFunctionWithAnySuspendability() } as ConeKotlinType?
|
||||
?: return false
|
||||
|
||||
when (argument) {
|
||||
is ResolvedCallableReferenceAtom ->
|
||||
|
||||
Reference in New Issue
Block a user