[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.fir.types.toSymbol
|
||||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
|
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
|
||||||
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
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
|
|
||||||
@Suppress("DuplicatedCode")
|
@Suppress("DuplicatedCode")
|
||||||
@@ -94,7 +93,14 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Compatible !in compatibilityToMembersMap -> {
|
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 -> {
|
else -> {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.types.AbstractTypeRefiner
|
|||||||
import org.jetbrains.kotlin.types.TypeCheckerState
|
import org.jetbrains.kotlin.types.TypeCheckerState
|
||||||
import org.jetbrains.kotlin.types.model.*
|
import org.jetbrains.kotlin.types.model.*
|
||||||
import org.jetbrains.kotlin.utils.DFS
|
import org.jetbrains.kotlin.utils.DFS
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
|
||||||
|
|
||||||
interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeContext {
|
interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeContext {
|
||||||
|
|
||||||
@@ -260,10 +259,11 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
): CapturedTypeMarker {
|
): CapturedTypeMarker {
|
||||||
require(lowerType is ConeKotlinType?)
|
require(lowerType is ConeKotlinType?)
|
||||||
require(constructorProjection is ConeTypeProjection)
|
require(constructorProjection is ConeTypeProjection)
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
return ConeCapturedType(
|
return ConeCapturedType(
|
||||||
captureStatus,
|
captureStatus,
|
||||||
lowerType,
|
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 {
|
override fun SimpleTypeMarker.replaceArguments(newArguments: List<TypeArgumentMarker>): SimpleTypeMarker {
|
||||||
require(this is ConeKotlinType)
|
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 {
|
override fun SimpleTypeMarker.replaceArguments(replacement: (TypeArgumentMarker) -> TypeArgumentMarker): SimpleTypeMarker {
|
||||||
@@ -506,7 +507,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker> {
|
override fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker> {
|
||||||
val builtInFunctionalType = getFunctionalTypeFromSupertypes().cast<ConeKotlinType>()
|
val builtInFunctionalType = getFunctionalTypeFromSupertypes() as ConeKotlinType
|
||||||
return buildList {
|
return buildList {
|
||||||
// excluding return type
|
// excluding return type
|
||||||
for (index in 0 until builtInFunctionalType.argumentsCount() - 1) {
|
for (index in 0 until builtInFunctionalType.argumentsCount() - 1) {
|
||||||
@@ -529,7 +530,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
var functionalSupertype: KotlinTypeMarker? = null
|
var functionalSupertype: KotlinTypeMarker? = null
|
||||||
simpleType.anySuperTypeConstructor { type ->
|
simpleType.anySuperTypeConstructor { type ->
|
||||||
simpleType.fastCorrespondingSupertypes(type.typeConstructor())?.any { superType ->
|
simpleType.fastCorrespondingSupertypes(type.typeConstructor())?.any { superType ->
|
||||||
val isFunctional = superType.cast<ConeKotlinType>().isBuiltinFunctionalType(session)
|
val isFunctional = (superType as ConeKotlinType).isBuiltinFunctionalType(session)
|
||||||
if (isFunctional)
|
if (isFunctional)
|
||||||
functionalSupertype = superType
|
functionalSupertype = superType
|
||||||
isFunctional
|
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.TypeConstructorMarker
|
||||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.filterIsInstanceWithChecker
|
import org.jetbrains.kotlin.utils.addToStdlib.filterIsInstanceWithChecker
|
||||||
|
|
||||||
class ConstraintSystemCompleter(components: BodyResolveComponents, private val context: BodyResolveContext) {
|
class ConstraintSystemCompleter(components: BodyResolveComponents, private val context: BodyResolveContext) {
|
||||||
@@ -220,8 +219,9 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
resolutionContext: ResolutionContext,
|
resolutionContext: ResolutionContext,
|
||||||
argument: PostponedAtomWithRevisableExpectedType,
|
argument: PostponedAtomWithRevisableExpectedType,
|
||||||
): Boolean = with(c) {
|
): Boolean = with(c) {
|
||||||
val revisedExpectedType: ConeKotlinType =
|
val revisedExpectedType = argument.revisedExpectedType
|
||||||
argument.revisedExpectedType?.takeIf { it.isFunctionOrKFunctionWithAnySuspendability() }?.cast() ?: return false
|
?.takeIf { it.isFunctionOrKFunctionWithAnySuspendability() } as ConeKotlinType?
|
||||||
|
?: return false
|
||||||
|
|
||||||
when (argument) {
|
when (argument) {
|
||||||
is ResolvedCallableReferenceAtom ->
|
is ResolvedCallableReferenceAtom ->
|
||||||
|
|||||||
Reference in New Issue
Block a user