提交 3d236b71 编写于 作者: V Vladimir Dolzhenko 提交者: Space

Simplify reportOnElement

Relates to #KT-38959
上级 b385650b
......@@ -1330,8 +1330,7 @@ public class DescriptorResolver {
}
if (isStaticNestedClass(classDescriptor)) {
PsiElement onReport = (reportErrorsOn instanceof KtConstructorDelegationCall)
? CallResolverUtilKt.reportOnElement((KtConstructorDelegationCall) reportErrorsOn) : reportErrorsOn;
PsiElement onReport = CallResolverUtilKt.reportOnElement(reportErrorsOn);
trace.report(INACCESSIBLE_OUTER_CLASS_EXPRESSION.on(onReport, classDescriptor));
return false;
}
......
......@@ -522,8 +522,7 @@ public class CallResolver {
@Nullable
private PsiElement calcReportOn(@NotNull KtConstructorDelegationReferenceExpression calleeExpression) {
PsiElement delegationCall = calleeExpression.getParent();
return delegationCall instanceof KtConstructorDelegationCall
? CallResolverUtilKt.reportOnElement((KtConstructorDelegationCall) delegationCall) : delegationCall;
return CallResolverUtilKt.reportOnElement(delegationCall);
}
@NotNull
......
......@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.resolve.calls.callResolverUtil
import com.google.common.collect.Lists
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
......@@ -322,6 +323,8 @@ fun createResolutionCandidatesForConstructors(
}
}
internal fun KtConstructorDelegationCall.reportOnElement() = if (this.isImplicit) {
this.getStrictParentOfType<KtSecondaryConstructor>()!!
} else this
internal fun PsiElement.reportOnElement() =
(this as? KtConstructorDelegationCall)
?.takeIf { isImplicit }
?.let { getStrictParentOfType<KtSecondaryConstructor>()!! }
?: this
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册