"This method shouldn't be invoked for INVISIBLE_FAKE visibility" Internal Error


#1

I’m getting an unusual error in my project, with the following stacktrace:

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: This method shouldn't be invoked for INVISIBLE_FAKE visibility
at org.jetbrains.kotlin.descriptors.Visibilities$8.mustCheckInImports(Visibilities.java:266)
at org.jetbrains.kotlin.resolve.QualifiedExpressionResolverKt.isVisible(QualifiedExpressionResolver.kt:651)
at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.choseOnlyVisibleOrAll(LazyExplicitImportScope.kt:149)
at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.collectCallableMemberDescriptors(LazyExplicitImportScope.kt:138)
at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.getContributedVariables(LazyExplicitImportScope.kt:57)
at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.getContributedDescriptors(LazyExplicitImportScope.kt:69)
at org.jetbrains.kotlin.resolve.scopes.BaseImportingScope.getContributedDescriptors(Scopes.kt:146)
at org.jetbrains.kotlin.resolve.scopes.ResolutionScope$DefaultImpls.getContributedDescriptors$default(ResolutionScope.kt:37)
at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.storeReferencesToDescriptors$kotlin_compiler(LazyExplicitImportScope.kt:109)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver$forceResolveImportDirective$1.invoke(LazyImportScope.kt:98)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver$forceResolveImportDirective$1.invoke(LazyImportScope.kt:75)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:408)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:483)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver.forceResolveImport(LazyImportScope.kt:154)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver$forceResolveAllImportsTask$1.invoke(LazyImportScope.kt:110)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver$forceResolveAllImportsTask$1.invoke(LazyImportScope.kt:75)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:323)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:370)
at org.jetbrains.kotlin.resolve.lazy.LazyImportResolver.forceResolveAllImports(LazyImportScope.kt:138)
at org.jetbrains.kotlin.resolve.lazy.FileScopeFactory$FilesScopesBuilder$importResolver$1.forceResolveAllImports(FileScopeFactory.kt:96)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.resolveImportsInAllFiles(LazyTopDownAnalyzer.kt:231)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:216)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:56)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:111)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:83)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:377)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:68)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:368)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:133)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:58)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:103)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:380)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:889)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:916)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:888)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:378)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Before I post any code, I’d like to know what the context of such an error is? I’m using IntelliJ IDEA with Kotlin version 1.1.51. My project was building just fine before I began refactoring it. And now I’m not sure as to if the error is due to that or if it’s a Kotlin bug.


#2

This is a Kotlin bug. Please file a YouTrack issue and post your code there.


#3

I also hit this:
https://youtrack.jetbrains.com/issue/KT-20356

In my case, it was something becoming private, breaking import somewhere else (but instead of a normal error, this internal error happened)


#4

Thanks for the insight, I actually had the exact same bug and managed to finally solve it.