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

e: java.lang.AssertionError: Rewrite at slice LEXICAL_SCOPE key: ANNOTATION_ENTRY #1716

Open
jschneider opened this issue Feb 6, 2024 · 4 comments

Comments

@jschneider
Copy link

jschneider commented Feb 6, 2024

Hey guys, this exception still happens for me with:

  • 1.9.20-1.0.14
  • 1.9.21-1.0.15
  • 1.9.21-1.0.16
  • 1.9.22-1.0.17
  • 2.0.0-Beta3-1.0.17

last version without this bug:

  • 1.9.20-1.0.13

This is the same(?) issue:
#1591

But it is not fixed for me.

The exception can be provoked by marking methods with @JsExport

Full Stacktrace:

e: java.lang.AssertionError: Rewrite at slice LEXICAL_SCOPE key: ANNOTATION_ENTRY old value: org.jetbrains.kotlin.resolve.scopes.LexicalScope$Base@5d232184@1562583428 new value: org.jetbrains.kotlin.resolve.scopes.LexicalScope$Base@165ecc78@375311480
<File name: MeisterCharts.kt, Physical: true>
/**
 * Creates the [BarChartStacked] as a child of [element].
 * @see [createBarChartStacked]h
 */
<ELEMENT>@JsExport</ELEMENT>
@JsName("createBarChartStackedFromElement")
@Suppress("unused")
fun createBarChartStackedFromElement(
  element: Element,
): BarChartStacked {
  val barChartStacked = createBarChartStacked()
  element.appendChild(barChartStacked.holder)
  return barChartStacked
}
        at org.jetbrains.kotlin.com.intellij.openapi.diagnostic.DefaultLogger.error(DefaultLogger.java:54)
        at org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger.error(Logger.java:182)
        at org.jetbrains.kotlin.util.slicedMap.Slices.logErrorAboutRewritingNonEqualObjects(Slices.java:158)
        at org.jetbrains.kotlin.util.slicedMap.Slices.access$000(Slices.java:30)
        at org.jetbrains.kotlin.util.slicedMap.Slices$1.processRewrite(Slices.java:42)
        at org.jetbrains.kotlin.util.slicedMap.SlicedMapImpl.put(SlicedMapImpl.java:65)
        at org.jetbrains.kotlin.resolve.BindingTraceContext.record(BindingTraceContext.java:150)
        at org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager$LockProtectedTrace$record$1.invoke(LockBasedLazyResolveStorageManager.kt:70)
        at org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager$LockProtectedTrace$record$1.invoke(LockBasedLazyResolveStorageManager.kt:70)
        at org.jetbrains.kotlin.storage.LockBasedStorageManager.compute(LockBasedStorageManager.java:290)
        at org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager$LockProtectedTrace.record(LockBasedLazyResolveStorageManager.kt:70)
        at org.jetbrains.kotlin.resolve.calls.CallResolver.resolveCallForConstructor(CallResolver.java:380)
        at org.jetbrains.kotlin.resolve.calls.CallResolver.resolveFunctionCall(CallResolver.java:334)
        at org.jetbrains.kotlin.resolve.calls.CallResolver.resolveFunctionCall(CallResolver.java:303)
        at org.jetbrains.kotlin.resolve.AnnotationResolverImpl.resolveAnnotationCall(AnnotationResolverImpl.java:167)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor$valueArgumentsWithSourceInfo$2.invoke(LazyAnnotations.kt:107)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor$valueArgumentsWithSourceInfo$2.invoke(LazyAnnotations.kt:106)
        at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:408)
        at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:527)
        at org.jetbrains.kotlin.storage.StorageKt.getValue(storage.kt:42)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor.getValueArgumentsWithSourceInfo(LazyAnnotations.kt:106)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor.access$getValueArgumentsWithSourceInfo(LazyAnnotations.kt:76)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor$allValueArguments$2.invoke(LazyAnnotations.kt:121)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor$allValueArguments$2.invoke(LazyAnnotations.kt:120)
        at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:408)
        at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(LockBasedStorageManager.java:527)
        at org.jetbrains.kotlin.storage.StorageKt.getValue(storage.kt:42)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor.getAllValueArguments(LazyAnnotations.kt:120)
        at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor.forceResolveAllContents(LazyAnnotations.kt:138)
        at org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil.doForceResolveAllContents(ForceResolveUtil.java:78)
        at org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil.forceResolveAllContents(ForceResolveUtil.java:69)
        at org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil.doForceResolveAllContents(ForceResolveUtil.java:97)
        at org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil.forceResolveAllContents(ForceResolveUtil.java:42)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveDeclarationForLocal(ResolverImpl.kt:838)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveDeclaration(ResolverImpl.kt:497)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:45)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:44)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.getPropertyDescriptor(KSPropertyDeclarationImpl.kt:44)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.access$getPropertyDescriptor(KSPropertyDeclarationImpl.kt:36)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$type$2$1.invoke(KSPropertyDeclarationImpl.kt:98)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$type$2$1.invoke(KSPropertyDeclarationImpl.kt:97)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSTypeReferenceDeferredImpl$resolved$2.invoke(KSTypeReferenceDeferredImpl.kt:57)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSTypeReferenceDeferredImpl$resolved$2.invoke(KSTypeReferenceDeferredImpl.kt:56)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSTypeReferenceDeferredImpl.getResolved(KSTypeReferenceDeferredImpl.kt:56)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSTypeReferenceDeferredImpl.toString(KSTypeReferenceDeferredImpl.kt:67)
        at java.base/java.lang.String.valueOf(String.java:4225)
        at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
        at it.neckar.ksp.ts.LoggerVisitor.visitTypeReference(LoggerVisitor.kt:156)
        at it.neckar.ksp.ts.LoggerVisitor.visitTypeReference(LoggerVisitor.kt:34)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSTypeReferenceDeferredImpl.accept(KSTypeReferenceDeferredImpl.kt:63)
        at com.google.devtools.ksp.visitor.KSTopDownVisitor.accept(KSTopDownVisitor.kt:34)
        at com.google.devtools.ksp.visitor.KSTopDownVisitor.visitPropertyDeclaration(KSTopDownVisitor.kt:37)
        at it.neckar.ksp.ts.LoggerVisitor.visitPropertyDeclaration(LoggerVisitor.kt:52)
        at it.neckar.ksp.ts.LoggerVisitor.visitPropertyDeclaration(LoggerVisitor.kt:34)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.accept(KSPropertyDeclarationImpl.kt:115)
        at com.google.devtools.ksp.visitor.KSTopDownVisitor.accept(KSTopDownVisitor.kt:28)
        at com.google.devtools.ksp.visitor.KSTopDownVisitor.visitDeclarationContainer(KSTopDownVisitor.kt:60)
        at it.neckar.ksp.ts.LoggerVisitor.visitDeclarationContainer(LoggerVisitor.kt:92)
        at it.neckar.ksp.ts.LoggerVisitor.visitDeclarationContainer(LoggerVisitor.kt:34)
        at com.google.devtools.ksp.visitor.KSDefaultVisitor.visitFunctionDeclaration(KSDefaultVisitor.kt:38)
        at com.google.devtools.ksp.visitor.KSTopDownVisitor.visitFunctionDeclaration(KSTopDownVisitor.kt:74)
        at it.neckar.ksp.ts.LoggerVisitor.visitFunctionDeclaration(LoggerVisitor.kt:107)
        at it.neckar.ksp.ts.LoggerVisitor.visitFunctionDeclaration(LoggerVisitor.kt:34)
        at com.google.devtools.ksp.symbol.impl.kotlin.KSFunctionDeclarationImpl.accept(KSFunctionDeclarationImpl.kt:118)
        at it.neckar.ksp.ts.TypeScriptGeneratorProcessor.process(TypeScriptGeneratorProcessor.kt:66)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:306)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:304)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:410)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:304)
        at org.jetbrains.kotlin.js.analyze.AbstractTopDownAnalyzerFacadeForWeb.analyzeFilesWithGivenTrace(TopDownAnalyzerFacadeForJS.kt:142)
        at org.jetbrains.kotlin.js.analyze.AbstractTopDownAnalyzerFacadeForWeb.analyzeFiles(TopDownAnalyzerFacadeForJS.kt:94)
        at org.jetbrains.kotlin.ir.backend.js.ModulesStructure$runAnalysis$1.invoke(klib.kt:534)
        at org.jetbrains.kotlin.ir.backend.js.ModulesStructure$runAnalysis$1.invoke(klib.kt:533)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
        at org.jetbrains.kotlin.ir.backend.js.ModulesStructure.runAnalysis(klib.kt:533)
        at org.jetbrains.kotlin.ir.backend.js.PrepareAnalyzedSourceModuleKt.prepareAnalyzedSourceModule(prepareAnalyzedSourceModule.kt:30)
        at org.jetbrains.kotlin.ir.backend.js.PrepareAnalyzedSourceModuleKt.prepareAnalyzedSourceModule$default(prepareAnalyzedSourceModule.kt:17)
        at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.processSourceModule(K2JsIrCompiler.kt:427)
        at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:273)
        at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:181)
        at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:72)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1523)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.Throwable: Rewrite at slice LEXICAL_SCOPE key: ANNOTATION_ENTRY old value: org.jetbrains.kotlin.resolve.scopes.LexicalScope$Base@5d232184@1562583428 new value: org.jetbrains.kotlin.resolve.scopes.LexicalScope$Base@165ecc78@375311480
<File name: MeisterCharts.kt, Physical: true>
/**
 * Creates the [BarChartStacked] as a child of [element].
 * @see [createBarChartStacked]h
 */
<ELEMENT>@JsExport</ELEMENT>
@JsName("createBarChartStackedFromElement")
@Suppress("unused")
fun createBarChartStackedFromElement(
  element: Element,
): BarChartStacked {
  val barChartStacked = createBarChartStacked()
  element.appendChild(barChartStacked.holder)
  return barChartStacked
}
        ... 101 more


@neetopia
Copy link
Collaborator

Is it possible to provide a reproduce repo for this issue? That would greatly help with investigation.

@jschneider
Copy link
Author

The bug still exists with 2.0.0-Beta4-1.0.18

Last working version: 1.9.20-1.0.13

I have a monorepo here, which I can not share. But I am more than willing to help debugging this issue? (Remote Session / Screen share / ...)

@jschneider
Copy link
Author

jschneider commented Mar 4, 2024

This might be the same issue. Contains a link to a reproducer repo:

#1630 (comment)

@jschneider
Copy link
Author

I investigated a bit further. I can reproduce the exception with a very simple visitor:

Overwriting all visit methods and calling the super method.

class LoggerVisitor(val codeGenerator: CodeGenerator) : KSTopDownVisitor<Int, Unit>() {
...

  override fun visitTypeReference(typeReference: KSTypeReference, data: Int) {
    log("${indent(data)}visitTypeReference: $typeReference $data") //this line is the problem!
    super.visitTypeReference(typeReference, data + 1)
  }
}

Removing "valueArgument" from the log statement solves the exception.
Therefore, I suspect the toString() method might be the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants