[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
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.util.*
// NOTE: in this file we collect only Kotlin-specific methods working with PSI and not modifying it
@@ -674,7 +673,7 @@ fun isTopLevelInFileOrScript(element: PsiElement): Boolean {
fun KtFile.getFileOrScriptDeclarations() = if (isScript()) script!!.declarations else declarations
fun KtExpression.getBinaryWithTypeParent(): KtBinaryExpressionWithTypeRHS? {
val callExpression = parent.safeAs<KtCallExpression>() ?: return null
val callExpression = parent as? KtCallExpression ?: return null
val possibleQualifiedExpression = callExpression.parent
val targetExpression = if (possibleQualifiedExpression is KtQualifiedExpression) {