Kotlin 2.0.20-Beta2: Exception when parsing a property accessor #495
Closed
Description
Exception is thrown when parsing the following code:
class FilteringExecutor(
private val delegate: ExecutorService = Executors.newSingleThreadExecutor()
) : Executor {
var filterFunction: (Runnable) -> Boolean = { true }
// failing expression
set(value) {
field = value
reEnqueueDeferred()
}
// failing expression
private fun reEnqueueDeferred() {}
}
It appears that accessor.stub
can be null
with 2.0.20.
Full exception:
org.jetbrains.kotlin.com.intellij.psi.PsiInvalidElementAccessException: Element: class org.jetbrains.kotlin.psi.KtParameterList; stub hierarchy is invalid: org.jetbrains.kotlin.com.intellij.psi.impl.source.SubstrateRef$StubRef@23756ebe (class org.jetbrains.kotlin.com.intellij.psi.impl.source.SubstrateRef$StubRef) has null containing file stub
at org.jetbrains.kotlin.com.intellij.psi.impl.source.SubstrateRef$StubRef.getContainingFile(SubstrateRef.java:110)
at org.jetbrains.kotlin.com.intellij.extapi.psi.StubBasedPsiElementBase.getContainingFile(StubBasedPsiElementBase.java:235)
at org.jetbrains.kotlin.com.intellij.extapi.psi.StubBasedPsiElementBase.getNode(StubBasedPsiElementBase.java:119)
at org.jetbrains.kotlin.com.intellij.psi.PsiInvalidElementAccessException.getPsiInvalidationTrace(PsiInvalidElementAccessException.java:98)
at org.jetbrains.kotlin.com.intellij.psi.PsiInvalidElementAccessException.<init>(PsiInvalidElementAccessException.java:61)
at org.jetbrains.kotlin.com.intellij.psi.stubs.StubBase.<init>(StubBase.java:31)
at org.jetbrains.kotlin.psi.stubs.impl.KotlinStubBaseImpl.<init>(KotlinStubBaseImpl.kt:34)
at org.jetbrains.kotlin.psi.stubs.impl.KotlinPlaceHolderStubImpl.<init>(KotlinPlaceHolderStubImpl.java:28)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.getParameterListWithBugFixes(KotlinInputAstVisitor.kt:1428)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.access$getParameterListWithBugFixes(KotlinInputAstVisitor.kt:133)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$declareOne$2$1.invoke(KotlinInputAstVisitor.kt:1401)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$declareOne$2$1.invoke(KotlinInputAstVisitor.kt:1393)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$declareOne$2.invoke(KotlinInputAstVisitor.kt:1393)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$declareOne$2.invoke(KotlinInputAstVisitor.kt:1387)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.declareOne(KotlinInputAstVisitor.kt:1387)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.access$declareOne(KotlinInputAstVisitor.kt:133)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitProperty$1.invoke(KotlinInputAstVisitor.kt:443)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitProperty$1.invoke(KotlinInputAstVisitor.kt:442)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visitProperty(KotlinInputAstVisitor.kt:442)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitProperty(KtVisitorVoid.java:497)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitProperty(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtProperty.accept(KtProperty.java:57)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:49)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visit(KotlinInputAstVisitor.kt:2596)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.access$visit(KotlinInputAstVisitor.kt:133)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassBody$1$2.invoke(KotlinInputAstVisitor.kt:1965)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassBody$1$2.invoke(KotlinInputAstVisitor.kt:1965)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassBody$1.invoke(KotlinInputAstVisitor.kt:1965)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassBody$1.invoke(KotlinInputAstVisitor.kt:1924)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$emitBracedBlock$1.invoke(KotlinInputAstVisitor.kt:414)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$emitBracedBlock$1.invoke(KotlinInputAstVisitor.kt:411)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.emitBracedBlock(KotlinInputAstVisitor.kt:411)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visitClassBody(KotlinInputAstVisitor.kt:1924)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassBody(KtVisitorVoid.java:545)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassBody(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtClassBody.accept(KtClassBody.kt:43)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:49)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visit(KotlinInputAstVisitor.kt:2596)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.access$visit(KotlinInputAstVisitor.kt:133)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassOrObject$1.invoke(KotlinInputAstVisitor.kt:1550)
at com.facebook.ktfmt.format.KotlinInputAstVisitor$visitClassOrObject$1.invoke(KotlinInputAstVisitor.kt:1514)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block(KotlinInputAstVisitor.kt:2568)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.block$default(KotlinInputAstVisitor.kt:2564)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visitClassOrObject(KotlinInputAstVisitor.kt:1514)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassOrObject(KtVisitorVoid.java:473)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassOrObject(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtVisitor.visitClass(KtVisitor.java:33)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:33)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:467)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtClass.accept(KtClass.kt:22)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:49)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visit(KotlinInputAstVisitor.kt:2596)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visitScript(KotlinInputAstVisitor.kt:2517)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:527)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtScript.accept(KtScript.java:69)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:49)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visit(KotlinInputAstVisitor.kt:2596)
at com.facebook.ktfmt.format.KotlinInputAstVisitor.visitKtFile(KotlinInputAstVisitor.kt:2492)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:521)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:41)
at org.jetbrains.kotlin.psi.KtCommonFile.accept(KtCommonFile.kt:244)
at com.facebook.ktfmt.format.Formatter.prettyPrint(Formatter.kt:109)
at com.facebook.ktfmt.format.Formatter.format(Formatter.kt:96)
at androidx.build.BaseKtfmtTask.processFile(Ktfmt.kt:150)
at androidx.build.BaseKtfmtTask.access$processFile(Ktfmt.kt:84)
at androidx.build.BaseKtfmtTask$processInputFiles$2$1$1.invokeSuspend(Ktfmt.kt:144)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)