https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
a

apatrida

10/14/2023, 9:10 PM
Looks like K2 has regressions in 1.9.20-RC. • First, some previously broken K2 code with context receivers now is broken completely in a different way • interfaces with default implementations with context receivers are no longer seen as implemented by the implementing class and produce an error "_Class PersonEntity.Typesafe is not abstract and does not implement abstract member refresh_" yet it does via this interface that it implements, but maybe that's a cascading failure.
Copy code
interface JooqRefreshableTrait<out ENTITY : KEntity>
    : RefreshableTrait<ENTITY> {
    context(DSLContext)
    override fun refresh(): ENTITY? {
        return refreshFrom(this@DSLContext)
    }
• The previous item if I take some modules out of language level
2_0
and only try to compile edge application layers, blows up the compiler:
Copy code
e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: .../backend-services/datadog-reporter/src/main/kotlin/.../service/datadog/DataDogReporter.kt
The root cause org.jetbrains.kotlin.backend.common.CompilationException was thrown at: org.jetbrains.kotlin.backend.jvm.lower.JvmDefaultParameterInjector$argumentsForCall$mainArguments$1.invoke(JvmDefaultParameterInjector.kt:73)
        at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:253)
        at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:237)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:65)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:52)
        at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:38)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
        at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
        at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:16)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.phaseBody(CompilerPhase.kt:147)
        at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeLowerings(JvmIrCodegenFactory.kt:348)
        at org.jetbrains.kotlin.codegen.CodegenFactory.generateModule(CodegenFactory.kt:44)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModuleInFrontendIRMode(JvmIrCodegenFactory.kt:379)
        at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.CompilerPipelineKt.generateCodeFromIr(compilerPipeline.kt:244)
        at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.CompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(compilerPipeline.kt:151)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:146)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
        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.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:463)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:62)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:477)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:400)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:281)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:125)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:657)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:105)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1624)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        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:714)
        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:400)
        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:1583)
Caused by: org.jetbrains.kotlin.backend.common.CompilationException: Back-end: Please report this problem <https://kotl.in/issue>
.../backend-services/datadog-reporter/src/main/kotlin/.../datadog/DataDogReporter.kt:43:1
Problem with
• Cannot differentiate between context receivers and claims methods are ambiguous:
Copy code
Overload resolution ambiguity between candidates: [context(ERROR CLASS: ?!id:0)
fun <S : Schema<SI>, SI : SchemaImpl, R> inferSchema(block: @ExtensionFunctionType @ContextFunctionTypeParams SI.(DSLContext) -> R): R, context(ERROR CLASS: ?!id:0)
fun <S : WritableSchema<SI>, SI : SchemaImpl, R> inferSchema(block: @ExtensionFunctionType @ContextFunctionTypeParams SI.(DSLContext) -> R): R]

these are peer interfaces:

interface Schema<S : SchemaImpl> : DSLContext, SchemaContext<S>
interface WritableSchema<S : SchemaImpl> : DSLContext, SchemaContext<S>
• Similar ambiguity between Java methods from JOOQ library:
Copy code
Overload resolution ambiguity between candidates: [@Support() @NotNull() @CheckReturnValue() fun <R : Record!> selectFrom(p0: ft<TableLike<ft<R & Any, R?>>, TableLike<ft<R & Any, R?>>?>): @EnhancedNullability @R|org/jetbrains/annotations/NotNull|()  SelectWhereStep<ft<R & Any, R?>>, @Support() @NotNull() @CheckReturnValue() fun selectFrom(p0: Name!): @EnhancedNullability @R|org/jetbrains/annotations/NotNull|()  SelectWhereStep<Record!>, @Support() @PlainSQL() @NotNull() @CheckReturnValue() fun selectFrom(p0: SQL!): @EnhancedNullability @R|org/jetbrains/annotations/NotNull|()  SelectWhereStep<Record!>, ...]
Trying almost any module in this project just doesn't work, whereas before I was only blocked by https://youtrack.jetbrains.com/issue/KT-59752 but now it is like walking into a hurricane of errors. I can give someone at JB compiler team access to this project for them to see, because the errors just cascade and it's really hard to separate them out.
I also included the project there for jb team
3 Views