diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java index f9d1f43a050..65be1f9ea6e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.kdoc.psi.api.KDoc; import org.jetbrains.jet.lang.psi.findDocComment.FindDocCommentPackage; +import org.jetbrains.jet.lang.psi.stubs.KotlinClassOrObjectStub; abstract class JetDeclarationStub extends JetModifierListOwnerStub implements JetDeclaration { public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) { @@ -43,7 +44,8 @@ abstract class JetDeclarationStub extends JetModifierList @Override public PsiElement getParent() { T stub = getStub(); - if (stub != null) { + // we build stubs for local classes/objects too but they have wrong parent + if (stub != null && !(stub instanceof KotlinClassOrObjectStub && ((KotlinClassOrObjectStub) stub).isLocal())) { return stub.getParentStub().getPsi(); } return super.getParent();