google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.84k stars 266 forks source link

Intermittent test failues with kotlin-compile-testing #11

Closed evant closed 4 years ago

evant commented 4 years ago

Sometimes getting

ERROR: Access to psi files should not be performed after project disposal: org.jetbrains.kotlin.com.intellij.mock.MockProject@5c15f56a
java.lang.Throwable: Access to psi files should not be performed after project disposal: org.jetbrains.kotlin.com.intellij.mock.MockProject@5c15f56a
    at org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger.error(Logger.java:145)
    at org.jetbrains.kotlin.com.intellij.psi.impl.file.impl.FileManagerImpl.findDirectory(FileManagerImpl.java:375)
    at org.jetbrains.kotlin.com.intellij.psi.impl.PsiManagerImpl.findDirectory(PsiManagerImpl.java:166)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.PsiFileImpl.getContainingDirectory(PsiFileImpl.java:412)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.PsiFileImpl.getParent(PsiFileImpl.java:399)
    at org.jetbrains.kotlin.com.intellij.psi.impl.source.PsiFileImpl.getParent(PsiFileImpl.java:49)
    at org.jetbrains.kotlin.com.intellij.psi.util.PsiTreeUtil.getStubOrPsiParent(PsiTreeUtil.java:581)
    at org.jetbrains.kotlin.psi.KtPsiUtil.getEnclosingElementForLocalDeclaration(KtPsiUtil.java:821)
    at org.jetbrains.kotlin.psi.KtPsiUtil.getEnclosingElementForLocalDeclaration(KtPsiUtil.java:768)
    at org.jetbrains.kotlin.psi.KtPsiUtil.isLocal(KtPsiUtil.java:868)
    at org.jetbrains.kotlin.ksp.processing.impl.ResolverImpl.resolveDeclaration(ResolverImpl.kt:195)
    at org.jetbrains.kotlin.ksp.processing.impl.ResolverImpl.resolveUserType(ResolverImpl.kt:245)
    at org.jetbrains.kotlin.ksp.symbol.impl.kotlin.KSTypeReferenceImpl.resolve(KSTypeReferenceImpl.kt:51)
    at me.tatarka.inject.compiler.ksp.UtilKt.hasAnnotation(Util.kt:23)

when executing a ksp processor using kotlin-compile-testing. It always happens when running multiple tests (running the test in isolation passes). It appears that it's due to something in the processor holding a reference to a disposed project instance.

neetopia commented 4 years ago

Can you provide a reproduce on this issue? If it can only be reproduced with kotlin-compile-testing, might make sense to file an issue in kotlin-compile-testing as well.

evant commented 4 years ago

Linked branch can reproduce it. I'll try to better isolate when I get time. I strongly suspect it has something to do with the statically-held ResolveImpl instance.

evant commented 4 years ago

No longer able to reproduce this on 20200828 :shrug:

evant commented 4 years ago

Moved branch with issue to https://github.com/evant/kotlin-inject/tree/compile-testing-old if you still care about it.

neetopia commented 4 years ago

Closed for now.