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

[BUG] IllegalStateException for commented annotations #820

Open
sebastianludwig opened this issue Jun 2, 2021 · 0 comments
Open

[BUG] IllegalStateException for commented annotations #820

sebastianludwig opened this issue Jun 2, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@sebastianludwig
Copy link

Describe the bug

Having a comment on the same line as an annotation causes an IllegalStateException, if an overridden property is annotated

interface Fruit {
    val weight: Int
}

class Banana: Fruit {
    @Deprecated("causes exception") // evil comment
    override val weight: Int = 120

    @Deprecated("this works") // tame comment
    val color: String = "green"
}

The resulting stacktrace is

java.lang.IllegalStateException: Unrecognized modifier: // evil comment
        at arrow.meta.internal.kastree.ast.psi.Converter$convertModifiers$1.invoke(Converter.kt:468)
        at arrow.meta.internal.kastree.ast.psi.Converter$convertModifiers$1.invoke(Converter.kt:453)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:170)
        at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194)
        at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:786)
        at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:816)
        at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:807)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertModifiers(Converter.kt:472)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertModifiers(Converter.kt:451)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertProperty(Converter.kt:524)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertDecl(Converter.kt:295)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertClassBody(Converter.kt:805)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertStructured(Converter.kt:627)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertDecl(Converter.kt:291)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertFile(Converter.kt:393)
        at arrow.meta.internal.kastree.ast.psi.Converter.convertFile$default(Converter.kt:388)
        at arrow.meta.quotes.MetaExtensionsKt$classDeclaration$$inlined$quote$1$1.invoke(Quote.kt:289)
        at arrow.meta.quotes.MetaExtensionsKt$classDeclaration$$inlined$quote$1$1.invoke(Quote.kt:152)
        at arrow.meta.dsl.analysis.AnalysisSyntax$analysis$1.doAnalysis(AnalysisSyntax.kt:66)
        at arrow.meta.internal.registry.InternalRegistry$registerAnalysisHandler$1$1.doAnalysis(InternalRegistry.kt:529)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:119)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:85)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:514)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:505)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:112)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:505)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:189)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:155)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:303)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:99)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:124)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
        at jdk.internal.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
        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(Native Method)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

The same (similar?) error seems to happen if a class has multiple annotations and any but the first one is annotated:

This works

// tame comment
@TestMethodOrder(MethodOrderer.Alphanumeric::class)
@ExtendWith(CorrectTestReportingExtension::class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class MyTest {
}

this does not

@TestMethodOrder(MethodOrderer.Alphanumeric::class)
@ExtendWith(CorrectTestReportingExtension::class)
// evil comment
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class MyTest {
}

Environment (please complete the following information):

@sebastianludwig sebastianludwig added the bug Something isn't working label Jun 2, 2021
@renovate renovate bot mentioned this issue Jan 19, 2024
1 task
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

No branches or pull requests

1 participant