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] Parameter processing desn't work if a project contains data classes #786

Open
Shpota opened this issue Jan 3, 2021 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Shpota
Copy link

Shpota commented Jan 3, 2021

Describe the bug
Parameter processing desn't work if a project contains data classes

To Reproduce

  1. Create a plugin that handles parameters
class MyParameterPlugin : Meta {
    @ExperimentalContracts
    override fun intercept(ctx: CompilerContext) = listOf(parameterPlugin)
}

val Meta.parameterPlugin
    get() = "Parameter plugin" {
        meta(
            parameter(this, { true }) { parameter ->
                Transform.replace(
                    replacing = parameter,
                    newDeclaration = identity()
                )
            }
        )
    }
  1. Crete a sample project containing data classes, eg:
data class User(val name: String)
  1. Try to build the sample project using the plugin from step 1.

Result:

> Task :compileKotlin FAILED
e: java.lang.IllegalStateException: Unrecognized expression type from VALUE_PARAMETER
        at arrow.meta.internal.kastree.ast.psi.Converter.convertExpr(Converter.kt:385)
        at arrow.meta.internal.kastree.ast.psi.ConverterKt.getAst(Converter.kt:946)
        at arrow.meta.quotes.QuoteKt$replace$1.invoke(Quote.kt:345)
        at arrow.meta.quotes.QuoteKt$replace$1.invoke(Quote.kt)
        at arrow.meta.internal.kastree.ast.MutableVisitor$Companion$preVisit$1.preVisit(MutableVisitor.kt:347)
        at arrow.meta.internal.kastree.ast.MutableVisitor$visit$$inlined$run$lambda$1.invoke(MutableVisitor.kt:10)
        at arrow.meta.internal.kastree.ast.MutableVisitor$visit$$inlined$run$lambda$1.invoke(MutableVisitor.kt:3)
        at arrow.meta.internal.kastree.ast.MutableVisitor$ChangedRef.sub(MutableVisitor.kt:341)
        at arrow.meta.internal.kastree.ast.MutableVisitor.visit(MutableVisitor.kt:9)
        at arrow.meta.internal.kastree.ast.MutableVisitor.visit$default(MutableVisitor.kt:8)
        at arrow.meta.internal.kastree.ast.MutableVisitor$Companion.preVisit(MutableVisitor.kt:348)
        at arrow.meta.quotes.QuoteKt.replace(Quote.kt:344)
        at arrow.meta.quotes.QuoteKt.replace$default(Quote.kt:344)
        at arrow.meta.quotes.MetaExtensionsKt$parameter$$inlined$quote$1$1.invoke(Quote.kt:469)
        at arrow.meta.quotes.MetaExtensionsKt$parameter$$inlined$quote$1$1.invoke(Quote.kt)
        at arrow.meta.dsl.analysis.AnalysisSyntax$analysis$1.doAnalysis(AnalysisSyntax.kt:66)
        at arrow.meta.internal.registry.InternalRegistry$registerAnalysisHandler$1$1.doAnalysis(InternalRegistry.kt:515)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:116)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:93)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:526)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:90)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:517)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:185)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86)
        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:346)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:102)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:240)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:39)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:81)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:93)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:601)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1633)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        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(AccessController.java:691)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)

Expected behavior
Compilation should be successful.

Environment:

Additional context

  • If a project contains only a main function, compilation works (adding a single data class breaks compilation).
  • The build fails after the code from Meta.parameterPlugin has successfully processed the sources.
  • If I use Meta.property() instead of Meta.parameter(), the code builds and runs fine (but I need parameter).
  • If I use 1.3.61-SNAPSHOT instead of 1.4.10-SNAPSHOT, compilation fails on registering meta components.
@Shpota Shpota added the bug Something isn't working label Jan 3, 2021
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