https://kotlinlang.org logo
Join Slack
Powered by
# compiler
  • a

    Alexander Ioffe

    10/12/2025, 5:00 AM
    I am eagerly tracking KT-49508 in order to see what the stable compiler API is going to look like. Any ideas what kind of API to expect? If this is an entirely new API will it look more like FIR or IR or something else entirely?
    o
    • 2
    • 1
  • y

    Youssef Shoaib [MOD]

    10/12/2025, 10:29 AM
    It would be nice if we could inject our own
    ConeInferenceContext
    or
    KotlinTypeRefiner
    in a FIR plugin. This was possible in K1 through
    REFINER_CAPABILITY
    .
  • z

    Zac Sweers

    10/13/2025, 4:20 AM
    found what seems like a bug in default value lowering: https://youtrack.jetbrains.com/issue/KT-81656/
  • z

    Zac Sweers

    10/13/2025, 10:17 PM
    it's possible in a compiler plugin to create a field with a name like
    foo<bar
    even though it won't be legal in the JVM (and fail later). Java has things like
    Character.isJavaIdentifierPart()
    , is there anything/reference we should have for targeting other platforms like JS for ensuring names are safely escaped?
    e
    m
    b
    • 4
    • 18
  • z

    Zac Sweers

    10/16/2025, 6:47 AM
    in 2.3.x it seems it's no longer safe to call
    testServices.sourceFileProvider.getContentOfSourceFile(testFile)
    in
    AdditionalSourceProvider.produceAdditionalFiles()
    because it calls through to
    testServices.moduleStructure
    under the hood, and seems that's no longer available at that time. I can just call
    testFile.originalContent
    directly but that skips other preprocessors. Worth filing an issue or is there a different API we should be using for this?
    Copy code
    java.lang.IllegalStateException: No 'org.jetbrains.kotlin.test.services.TestModuleStructure'(19) in array owner: org.jetbrains.kotlin.test.services.TestServices@7af2910e
    	at org.jetbrains.kotlin.util.ArrayMapAccessor.getValue(ArrayMapOwner.kt:53)
    	at org.jetbrains.kotlin.test.services.TestModuleStructureKt.getModuleStructure(TestModuleStructure.kt:22)
    	at org.jetbrains.kotlin.test.preprocessors.JvmInlineSourceTransformer.process(JvmInlineSourceTransformer.kt:42)
    	at org.jetbrains.kotlin.test.services.SourceFileProviderImpl.getContentOfSourceFile(SourceFileProvider.kt:63)
    	at dev.zacsweers.metro.compiler.interop.Ksp2AdditionalSourceProvider.produceAdditionalFiles(Ksp2AdditionalSourceProvider.kt:55)
    d
    b
    • 3
    • 6
  • y

    Youssef Shoaib [MOD]

    10/16/2025, 9:45 AM
    For all the same reasons that context receivers became context parameters, I think having a version of
    addNewImplicitReceivers
    that adds context parameters instead would be very very useful. Currently, it adds extension receivers, but that has that problem of scope pollution In fact, this could be done just by allowing it to return
    ImplicitValue<*>
    👍 1
    d
    • 2
    • 1
  • y

    Youssef Shoaib [MOD]

    10/16/2025, 1:25 PM
    I want to trace back a receiver reference in IR to the IrFunctionCall corresponding to the FirFunctionCall that resulted in its creation in
    addNewImplicitReceivers
    . Is there a simple way to do that? I'm thinking of using declaration origins, but I can't see how to easily associate that with the
    FirFunctionCall
    in a way that'll persist to the Ir. My use case is incredibly simple: I want a call like:
    Copy code
    with(foo, bar)
    to result in 2 receivers added. Thus in the IR I want to add variables for
    foo
    and
    bar
    , and simply replace the receiver references to instead refer to them.
    d
    • 2
    • 3
  • y

    Youssef Shoaib [MOD]

    10/16/2025, 4:14 PM
    The new
    addNewImplicitReceivers
    signature is very hard to use. In IR, it results in either an error call (which is fine, I can work with that) or a seemingly-undetectable reference to a real extension parameter but with the wrong type (i.e. it might refer to the extension param of a local
    apply {}
    ). The latter I really can't detect easily. DataFrame gets lucky because the calls one may ever want to make on the new implicit receiver are calls to fir generated properties. In my case, I have real properties and such I want to access on it. If somehow it could always be an error call, that'd be great. Ideally, I wish it'd actually keep the
    origin
    and maybe even provide a reference to the function call that resulted in this new implicit receiver (more on that in the post above)
    d
    • 2
    • 2
  • y

    Youssef Shoaib [MOD]

    10/17/2025, 2:23 AM
    Any simple way for a compiler plugin to suppress a warning? I know I can go through Gradle by adding the relevant compiler argument, but is there a compiler plugin only way to do it?
    d
    • 2
    • 1
  • y

    Youssef Shoaib [MOD]

    10/17/2025, 4:19 AM
    Can I suppress a CS system error? I want to suppress "Inference error: InferredEmptyIntersectionWarning". This comes about because I suppress the warning
    INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION
    , which somehow surfaces those inference errors. My understanding though is that they should only be warnings, no?
    d
    • 2
    • 1
  • y

    Youssef Shoaib [MOD]

    10/17/2025, 10:24 AM
    I'm getting
    NEW_INFERENCE_ERROR
    but only in normal compilation. When running through the test infra, the error never shows up. How come ?
    d
    • 2
    • 1
  • d

    Desmond van der Meer

    10/17/2025, 4:21 PM
    In a compiler plugin, if I want to add an additional value parameter to certain annotated functions in the FIR stage, how would I best go about this? None of the FIR extensions seem to support this.
    y
    • 2
    • 37
  • f

    François

    10/18/2025, 9:01 AM
    Hello, I have a cinterop question, when the Gradle Cache is enabled. If I modify the definition file, the CInteropProcess task should invalidate the cache and their dependencies? But, currently, the metadata generated (inside the .kotlin folder) is NOT updated. So the Kotlin/ObjC bridge is not updated and a clean/build need to be done, I would like to avoid that (It takes too much time).
    a
    • 2
    • 2
  • y

    Youssef Shoaib [MOD]

    10/18/2025, 3:18 PM
    In
    FirFunctionCallRefinementExtension.intercept
    , I get
    CallInfo
    and a
    FirNamedFunctionSymbol
    , from which I can get
    valueParameterSymbols
    . Is there an easy way to pair up those value params to the
    CallInfo.arguments
    ? I can do it manually, but wondering if there's a utility in the compiler already. In other words, given some
    arguments
    and
    valueParameterSymbols
    , I want to associate the arguments to the parameters, while respecting named arguments, varargs, trailing lambdas, etc.
    d
    • 2
    • 1
  • c

    Caleb B

    10/19/2025, 11:17 PM
    Is there documentation for what each type in the compiler does? For example: what a
    FirReference
    signifies?
    d
    • 2
    • 2
  • c

    Caleb B

    10/19/2025, 11:41 PM
    Also, why are all of the FIR classes generated like that with no docs? Doesn't that make developing the compiler difficult? Or is there something we aren't seeing?
    d
    w
    • 3
    • 2
  • p

    PHondogo

    10/20/2025, 9:43 AM
    What is the purpose of IrInstanceInitializerCall? https://github.com/JetBrains/kotlin/blob/master/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt
    s
    • 2
    • 1
  • z

    Zac Sweers

    10/20/2025, 9:36 PM
    in the compile test framework APIs, is there a way to replicate gradle api/impl behavior with
    // MODULE
    directives?
    d
    • 2
    • 1
  • o

    Oliver.O

    10/21/2025, 1:10 PM
    I have a case where
    IrPluginContext.referenceFunctions(callableId: CallableId)
    does not resolve a symbol (returning an empty collection) resolves to two symbols when called at the beginning of
    IrGenerationExtension.generate()
    , but then properly resolves to a single symbol later on during
    IrModuleFragment.transform
    . The situation only occurs with the Android Gradle Library Plugin for KMP and only with Android Local tests (a.k.a. host-based tests, unit tests). Why is that? More Details in 🧵.
    • 1
    • 2
  • e

    Eugen Martynov

    10/22/2025, 8:52 AM
    This is not compilable
    Copy code
    class CafHttpResult<T> {
        var result: T = null
    }
    But I write
    <T: Any>
    for that. Was it always like this?
    ✅ 1
    p
    f
    e
    • 4
    • 13
  • c

    chrisjenx

    10/22/2025, 9:53 PM
    Should "kotlinCompilerPluginClasspath" still work in Kotlin 2.x+ Or do we have to use a SubPlugin (and if so how is that even possible to create compiler/plugin/consume in the same project without publishing to maven(local)?)
    j
    • 2
    • 11
  • y

    Youssef Shoaib [MOD]

    10/24/2025, 2:20 PM
    FYI, DataFrame plugin doesn't add captured outer type parameters to its generated local classes. I haven't been able to reproduce an issue with it yet (I have a reproducer for my own plugin, whose generated local classes are user-referencible, unlike DataFrame), but it seems like an easy fix.
    thank you color 1
  • r

    rebok

    10/26/2025, 11:28 AM
    How to compile an executable file with kotlinc-js? I cannot find anything about doing that on the kotlin docs
  • e

    Eugen Martynov

    10/27/2025, 1:35 PM
    Are value classes supported on more platforms now? https://carrion.dev/en/posts/kotlin-inline-functions-value-classes/#performance-notes I can not find the official documentation - I was sure it is only JVM-based.
    e
    • 2
    • 1
  • e

    Edoardo Luppi

    10/29/2025, 6:09 PM
    I recall seeing a couple of issues regarding Protobuf and the fact it's not as performant as it should be, tho maybe I've mis-interpreted the problem. Did you consider testing out https://github.com/apache/fory?
    w
    • 2
    • 1
  • s

    Stefan Koppier

    10/30/2025, 2:31 PM
    I'm developing compiler plugin, and am looking for some input on resolving the arguments to type parameters in the IR stage. Suppose I have classes •
    class A : B
    •
    class B : C<MyImpl>
    •
    class <T : MyIF> C
    where
    MyImpl : MyIf
    . Does the compiler expose some functionality available in the IR stage to resolve
    T
    to
    MyImpl
    when processing IrClass
    A
    ? A lot of functionality (as expected) resolves to
    MyIF
    , but I can't find any functionalitity to resolve
    T
    to
    MyImpl
    while browsing the Kotlin compiler source-code.
    d
    • 2
    • 2
  • y

    Yang

    10/31/2025, 2:16 AM
    Has anyone tried the new
    -Xcompiler-plugin-ordering
    in 2.3? I tried https://youtrack.jetbrains.com/issue/KT-55300/Provide-a-mechanism-to-describe-ordering-and-dependencies-for-compiler-plugins#focus=Comm[…]915454.0-0 but it doesn’t seem to work so far.
    z
    b
    • 3
    • 10
  • c

    crowforkotlin

    10/31/2025, 9:59 AM
    Hi everyone, does anyone know how to debug Kotlin compiler plugins after setting breakpoints? When I run
    debug autoservice
    , the plugin registered by this plugin is printed, but I can't debug it with breakpoints. The implementation of
    KotlinCompilerPluginSupportPlugin
    allows for breakpoint debugging, but I don't understand why.
    p
    d
    • 3
    • 5
  • y

    Yang

    11/01/2025, 1:57 AM
    has anyone used the
    CHECK_COMPILER_OUTPUT
    directive to test IR errors in their plugin? I haven’t seen any 3rd party plugins do this so I’m wondering if it’s generally better to report errors with FIR diagnostics and test those with diagnostic tests, or test the IR errors in Gradle plugin’s integration tests?
  • z

    Zac Sweers

    11/01/2025, 3:19 PM
    When generating nested classifier names in an FIR generator, is there a way to check ahead of time if there will be a clashing name with an existing source-based classifier? Or does that require just using direct symbol access to be super safe?