From cc76bbd09d37aaa0d2e9093b72f17655c13258d5 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 5 Jun 2023 10:17:40 +0000 Subject: [PATCH] [psi] don't decompile to detect invalid code in compiled code no error elements are possible Merge-request: KT-MR-10407 Merged-by: Anna Kozlova --- .../src/org/jetbrains/kotlin/psi/KtParameter.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameter.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameter.java index ef91e5460bb..784901ba7fe 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameter.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameter.java @@ -154,10 +154,18 @@ public class KtParameter extends KtNamedDeclarationStub imp private boolean checkParentOfParentType(Class klass) { // `parent` is supposed to be [KtParameterList] PsiElement parent = getParent(); - if (parent == null || parent.getNextSibling() instanceof PsiErrorElement) { + if (parent == null) { return false; } - return klass.isInstance(parent.getParent()); + if (klass.isInstance(parent.getParent())) { + //don't check ast if the tree structure is different; skip for compiled code + if (!getContainingKtFile().isCompiled() && + parent.getNextSibling() instanceof PsiErrorElement) { + return false; + } + return true; + } + return false; } public boolean isCatchParameter() {