[FE 1.0] Remove usages of safeAs and cast from most of FE 1.0 modules:

- :core:descriptors
- :core:descriptors.jvm
- :core:deserialization
- :compiler:cli
- :compiler:frontend
- :compiler:frontend:cfg
- :compiler:frontend.java
- :compiler:frontend.common.jvm
- :compiler:psi
- :compiler:resolution
- :compiler:resolution.common
- :compiler:resolution.common.jvm
- :kotlin-reflect-api
This commit is contained in:
Dmitriy Novozhilov
2022-10-11 15:26:45 +03:00
committed by Space Team
parent 6afceb1e84
commit d423782fac
65 changed files with 156 additions and 241 deletions
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.runtime.components.ReflectKotlinClass
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import kotlin.jvm.internal.TypeParameterReference
import kotlin.reflect.KType
import kotlin.reflect.KTypeParameter
@@ -74,9 +73,11 @@ internal class KTypeParameterImpl(
toJavaClass()?.kotlin as KClassImpl<*>?
?: throw KotlinReflectionInternalError("Type parameter container is not resolved: $containingDeclaration")
private fun DeserializedMemberDescriptor.getContainerClass(): Class<*> =
containerSource.safeAs<JvmPackagePartSource>()?.knownJvmBinaryClass.safeAs<ReflectKotlinClass>()?.klass
private fun DeserializedMemberDescriptor.getContainerClass(): Class<*> {
val jvmPackagePartSource = containerSource as? JvmPackagePartSource
return (jvmPackagePartSource?.knownJvmBinaryClass as? ReflectKotlinClass)?.klass
?: throw KotlinReflectionInternalError("Container of deserialized member is not resolved: $this")
}
override fun equals(other: Any?) =
other is KTypeParameterImpl && container == other.container && name == other.name