diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/LibraryKinds.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/LibraryKinds.kt index 543c3f44ca6..4fc47a97b92 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/LibraryKinds.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/LibraryKinds.kt @@ -52,7 +52,7 @@ val PersistentLibraryKind<*>?.platform: TargetPlatform } fun getLibraryPlatform(project: Project, library: Library): TargetPlatform { - library as? LibraryEx ?: return JvmPlatform + if (library !is LibraryEx) return JvmPlatform if (library.isDisposed) return JvmPlatform return library.effectiveKind(project).platform diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 9778385c8a4..3fdf576135d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -351,7 +351,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { private fun hasPlatformImplementations(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor?): Boolean { if (!declaration.hasExpectModifier()) return false - descriptor as? MemberDescriptor ?: return false + if (descriptor !is MemberDescriptor) return false val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor() return commonModuleDescriptor.implementingDescriptors.any { it.hasActualsFor(descriptor) } || diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt index 5ee85a5f4e7..49da30fa9b8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt @@ -60,7 +60,7 @@ class UseExpressionBodyInspection(private val convertEmptyToUnit: Boolean) : Abs override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = declarationVisitor(fun(declaration) { - declaration as? KtDeclarationWithBody ?: return + if (declaration !is KtDeclarationWithBody) return val (toHighlightElement, suffix, highlightType) = statusFor(declaration) ?: return // Change range to start with left brace val hasHighlighting = highlightType != INFORMATION diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/migration/ObsoleteExperimentalCoroutinesInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/migration/ObsoleteExperimentalCoroutinesInspection.kt index 7128acac76b..2b7377523ca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/migration/ObsoleteExperimentalCoroutinesInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/migration/ObsoleteExperimentalCoroutinesInspection.kt @@ -44,7 +44,7 @@ class ObsoleteExperimentalCoroutinesInspection : AbstractKotlinInspection(), Cle when (simpleNameExpression.text) { RESUME_MARKER, RESUME_WITH_EXCEPTION_MARKER -> { - simpleNameExpression.parent as? KtCallExpression ?: return + if (simpleNameExpression.parent !is KtCallExpression) return val descriptor = simpleNameExpression.resolveMainReferenceToDescriptors().firstOrNull() ?: return val callableDescriptor = descriptor as? CallableDescriptor ?: return @@ -174,7 +174,7 @@ class ObsoleteExperimentalCoroutinesInspection : AbstractKotlinInspection(), Cle override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val element = descriptor.psiElement - element as? KtSimpleNameExpression ?: return + if (element !is KtSimpleNameExpression) return val importFun = KotlinTopLevelFunctionFqnNameIndex.getInstance() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveMemberToTopLevelIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveMemberToTopLevelIntention.kt index 1b340a54803..da613f4cb8d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveMemberToTopLevelIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveMemberToTopLevelIntention.kt @@ -60,7 +60,7 @@ class MoveMemberToTopLevelIntention : MoveMemberOutOfObjectIntention("Move to to override fun applicabilityRange(element: KtNamedDeclaration): TextRange? { if (element !is KtNamedFunction && element !is KtProperty) return null - element.containingClassOrObject as? KtObjectDeclaration ?: return null + if (element.containingClassOrObject !is KtObjectDeclaration) return null return element.nameIdentifier?.textRange } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt index e96cb029865..6878b7b83b4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyParenthesesFromLambdaCallIntention.kt @@ -44,7 +44,7 @@ class RemoveEmptyParenthesesFromLambdaCallIntention : SelfTargetingRangeIntentio val parent = element.parent as? KtCallExpression ?: return null val singleLambdaArgument = parent.lambdaArguments.singleOrNull() ?: return null if (element.getLineNumber(start = false) != singleLambdaArgument.getLineNumber(start = true)) return null - element.getPrevSiblingIgnoringWhitespaceAndComments() as? KtCallExpression ?: return element.range + if (element.getPrevSiblingIgnoringWhitespaceAndComments() !is KtCallExpression) return element.range return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt index b31d79d610b..3b8d41b2536 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceCallFix.kt @@ -88,7 +88,7 @@ class ReplaceWithSafeCallFix( return ReplaceWithSafeCallFix(qualifiedExpression, qualifiedExpression.shouldHaveNotNullType()) } else { - psiElement as? KtNameReferenceExpression ?: return null + if (psiElement !is KtNameReferenceExpression) return null if (psiElement.getResolvedCall(psiElement.analyze())?.getImplicitReceiverValue() != null) { val expressionToReplace: KtExpression = psiElement.parent as? KtCallExpression ?: psiElement return ReplaceImplicitReceiverCallFix(expressionToReplace, expressionToReplace.shouldHaveNotNullType())