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

dniHze

02/27/2024, 4:36 PM
Good afternoon all! We decided to run our benchmark against Beta4 (wanted to try k2 kapt too), and we faced some difficulties compiling modules (that were compiling perfectly fine with Beta1 and stable). I've created [an issue](https://youtrack.jetbrains.com/issue/KT-66148/K2-FileAnalysisException-in-Beta4) on YouTrack, but I wonder if someone might have an idea what it might be caused by? The code doesn't look suspicious at all. Code snipper is available in the ticket. Exception:
Copy code
e: org.jetbrains.kotlin.util.FileAnalysisException: While analysing /Users/a.dorosh/StudioProjects/*******/MviBaseDsl.kt:58:21: java.lang.IllegalArgumentException: Failed requirement.
        at org.jetbrains.kotlin.util.AnalysisExceptionsKt.wrapIntoFileAnalysisExceptionIfNeeded(AnalysisExceptions.kt:56)
        at org.jetbrains.kotlin.fir.FirCliExceptionHandler.handleExceptionOnFileAnalysis(Utils.kt:180)
        at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirDeclarationsResolveTransformer.transformFile(FirDeclarationsResolveTransformer.kt:1575)
        at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformerDispatcher.transformFile(FirAbstractBodyResolveTransformerDispatcher.kt:57)
        at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformerDispatcher.transformFile(FirAbstractBodyResolveTransformerDispatcher.kt:24)
        at org.jetbrains.kotlin.fir.declarations.FirFile.transform(FirFile.kt:48)
        ***
k

kirillrakhman

02/27/2024, 5:16 PM
Do you have some implicit
this
access in your code?
d

dmitriy.novozhilov

02/28/2024, 6:17 AM
It seems that the reason is builder inference @dniHze could you please provide an information I asked in the ticket?
d

dniHze

02/28/2024, 1:23 PM
Hey @dmitriy.novozhilov, tried to add all details requested. Let me know if anything else might be needed to identify the root cause.
thank you color 1
Hey @kirillrakhman,
innerTransformation()
is a function, scoped to the same class as
onBinding()
. I believe this qualifies as an implicit
this
call.
👍 1
d

dmitriy.novozhilov

02/28/2024, 1:37 PM
As a workaround you can add explicit type arguments to
binding
call I believe it would be
binding<String, Unit> {...}
, but I may be mistaken
👀 1
d

dniHze

02/28/2024, 1:59 PM
Indeed, adding explicit type arguments to this call no longer hinders the compiler. We can unlock our benchmarks for now, thanks!
👌 1
(unrelated to the main thread topic) We also tried K2 KAPT, and we encountered some difficulties. Still works well in compat mode, but fails in K2 mode. More details here: https://youtrack.jetbrains.com/issue/KT-66207/K2-w-kapt-JvmSuppressWildcards-is-not-properly-applied-to-generated-stubs
thank you color 2
Btw, it looks like metadata format was updated in the K2 KAPT? I've managed to rule out the above issue by just applying
@JvmSuppressWildcards
to type arguments instead of the collection, but Dagger now fails with NPE when tries to access the metadata here. They are using
org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.9.0
. Is that a bug or intended behaviour, as the
kotlinx-metadata-jvm
artefact may require an update to process thing properly?
d

dmitriy.novozhilov

02/29/2024, 6:12 AM
cc @Ilmir Usmanov [JB]