From f3b7d2fca9371c93c8e673919bf939c9db553d69 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 11 Sep 2019 12:51:55 +0300 Subject: [PATCH] Fix exception of getting parent for the root package (EA-210820) --- .../ReplaceGuardClauseWithFunctionCallInspection.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceGuardClauseWithFunctionCallInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceGuardClauseWithFunctionCallInspection.kt index f218e816a9d..c7754af935b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceGuardClauseWithFunctionCallInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceGuardClauseWithFunctionCallInspection.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.idea.util.CommentSaver import org.jetbrains.kotlin.idea.util.textRangeIn import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.parentOrNull import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression @@ -63,7 +64,7 @@ class ReplaceGuardClauseWithFunctionCallInspection : AbstractApplicabilityBasedI val argumentType = valueArguments.firstOrNull()?.getArgumentExpression()?.getType(context) if (argumentType != null && !KotlinBuiltIns.isStringOrNullableString(argumentType)) return false if (element.isUsedAsExpression(context)) return false - val fqName = call.getResolvedCall(context)?.resultingDescriptor?.fqNameSafe?.parent() + val fqName = call.getResolvedCall(context)?.resultingDescriptor?.fqNameSafe?.parentOrNull() return fqName == FqName("kotlin.$calleeText") || fqName == FqName("java.lang.$calleeText") }