Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: unhandled visibility: private/*private to this*/ #1515

Closed
bcorso opened this issue Aug 30, 2023 · 3 comments · Fixed by #1620
Closed

java.lang.IllegalStateException: unhandled visibility: private/*private to this*/ #1515

bcorso opened this issue Aug 30, 2023 · 3 comments · Fixed by #1620
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bcorso
Copy link

bcorso commented Aug 30, 2023

Dagger just released it's KSP processors and a user has hit this exception:

exception: error: [ksp] java.lang.IllegalStateException: unhandled visibility: private/*private to this*/
exception:     at com.google.devtools.ksp.DescriptorUtilsKt.toKSModifiers(DescriptorUtils.kt:96)

Which points to this line:

https://github.com/google/ksp/blob/main/common-util/src/main/kotlin/com/google/devtools/ksp/DescriptorUtils.kt#L96

The Dagger Github issue (google/dagger#4045) gives some snippets of the class that caused this but I'm still not sure what exactly in the class could be responsible.

@kakai248
Copy link

Just to add some more information, it seems to be related with having in in generic P and then using it in paramState.

This compiles:

interface SubjectInteractor<in P : Any?, R : Any?> {
    val flow: Flow<R>
    suspend operator fun invoke(params: P)

-    abstract class Default<in P : Any?, R : Any?> : SubjectInteractor<P, R> {
+    abstract class Default<P : Any?, R : Any?> : SubjectInteractor<P, R> {
        private val paramState = MutableSharedFlow<P>(
            replay = 1,
            extraBufferCapacity = 0,
            onBufferOverflow = BufferOverflow.DROP_OLDEST
        )

        @OptIn(ExperimentalCoroutinesApi::class)
        override val flow: Flow<R> = paramState
            .distinctUntilChanged()
            .flatMapLatest(::createFlow)
            .distinctUntilChanged()

        override suspend operator fun invoke(params: P) {
            paramState.emit(params)
        }

        protected abstract fun createFlow(params: P): Flow<R>
    }
}

@ting-yuan ting-yuan modified the milestones: 1.0.14, Dagger Sep 28, 2023
@nesk
Copy link

nesk commented Oct 7, 2023

Just happened to me when trying to resolve the visibility of kotlin.collections.AbstractMap::_values:

class CustomProcessor : SymbolProcessor {
    override fun process(resolver: Resolver): List<KSAnnotated> {
        resolver.getClassDeclarationByName("kotlin.collections.AbstractMap")
            ?.getAllProperties()
            ?.single { it.simpleName.asString() == "_values" }
            ?.getVisibility()
        //    ^ java.lang.IllegalStateException: unhandled visibility: private/*private to this*/
    }
}

@technoir42
Copy link
Contributor

I get this error in incremental builds, but a follow-up build with --rerun-tasks always passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants