diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClassOrObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClassOrObject.kt index f5954f3f822..a37893fcc83 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClassOrObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClassOrObject.kt @@ -83,7 +83,7 @@ abstract class KtClassOrObject : return getOrCreateBody().addBefore(declaration, anchorAfter) as T } - fun isTopLevel(): Boolean = stub?.isTopLevel() ?: (parent is KtFile) + fun isTopLevel(): Boolean = stub?.isTopLevel() ?: (parent == null || parent is KtFile) fun isLocal(): Boolean = stub?.isLocal() ?: KtPsiUtil.isLocal(this)