https://kotlinlang.org logo
Join Slack
Powered by
# compiler
  • 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
    • 11
  • 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?
  • j

    Javier

    11/04/2025, 9:27 AM
    I'm generating a property in FIR that gets completed later in IR. This property is annotated with
    @Transient
    from Kotlin Serialization. It seems that something has recently changed in Kotlin Serialization — perhaps the checker has been moved to FIR — because now I'm getting the following error:
    Copy code
    This property is marked as @Transient and therefore must have an initializing expression
    I tried changing the order in which the plugins are applied, as I had a similar issue before with the AtomicFU plugin, but that workaround doesn’t work this time. I suppose creating a fake in FIR for that property would fix the issue, but since that’s not allowed, what other workaround could I use?
    d
    • 2
    • 10
  • y

    Youssef Shoaib [MOD]

    11/04/2025, 6:19 PM
    I want to commend the compiler team on the work done for suspend function codegen. I was revisiting a project recently that in 2.0 was having memory leaks because continuations would hold onto parameters for too long, and that's just completely fixed now! A bunch of other weirdness I observed before, like circular references to continuations, are also gone. It's hard to notice these improvements on the outside sometimes, but it really does make a difference, so thank you guys!
    🙌 10
    🙌🏾 2
    d
    • 2
    • 1
  • e

    elect

    11/06/2025, 11:28 AM
    is it possible to write a frontend compiler plugin to manipulating the AST?
    y
    c
    • 3
    • 8
  • m

    martmists

    11/09/2025, 11:26 PM
    If there's a setup like this:
    Copy code
    // Foo.java
    public interface Foo {
        Bar XYZ = new Bar { ... }
    }
    is there a way for me to emit an irGetField for it? I tried fooKlass.getFieldByName("XYZ") but that didn't seem to work, and fooKlass.fields.toList() returns an empty list. In kotlin I'd just write
    Foo.XYZ
    . Or is there some other way to access these fields instead of irGetField?
    s
    • 2
    • 1
  • c

    Caleb B

    11/10/2025, 3:38 PM
    Is there any way to get the type information for the RHS of an assignment when using an FIR AssignmentAltererExtension? Or do you just need to blindly change the call target and defer checking if it's a valid target to a later FIR stage?
  • m

    martmists

    11/10/2025, 4:40 PM
    Copy code
    Caused by: java.lang.AssertionError: Unexpected IR element found during code generation. Either code generation for it is not implemented, or it should have been lowered:
    FUN name:<anonymous> visibility:public modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Any
    How do I fix this? I'm trying to build a lambda, and in the parent declaration (see thread) the generated IR largely seems fine to me.
    y
    • 2
    • 10
  • y

    y9san9

    11/11/2025, 8:26 AM
    Hey guys. Am I stupid or it is a bug in the compiler? I tried 3 versions (2.2.20, 2.2.21, 2.3.0-Beta2) and it has this warning. I think it's changing though.
    d
    • 2
    • 7
  • c

    Caleb B

    11/11/2025, 10:55 PM
    Can you set the priority of your compiler plugin? I want to make sure my plugin is run last so I don't conflict with others treading the same ground.
    j
    z
    +3
    • 6
    • 15
  • z

    Zac Sweers

    11/12/2025, 6:38 PM
    I'm looking into an odd IC issue someone reported with Metro, where we do recompile and can look up a given recompiled class, but the class is missing all its declarations and annotations. Usually with IC it's a matter of linking two files/symbols together in compilation, but I've not encountered a situation where we get a symbol and it's just lossy. In this case, the symbol it's trying to read is in a separate upstream compilation ref: https://github.com/ZacSweers/metro/pull/1349
    d
    • 2
    • 33
  • c

    Caleb B

    11/12/2025, 10:06 PM
    Since there's no concrete plugin-priority system, I wanted to see if anyone could help me figure out how to design my "overloaded setters" plugin such that it doesn't need to run last. Details in thread.
    • 1
    • 4
  • c

    crowforkotlin

    11/14/2025, 2:01 AM
    # Kotlin Compiler IR & FIR pdf https://ssw.jku.at/Teaching/BachelorTheses/2025/Weinstabl_David.pdf
    👏 4
    🏆 4
    👀 2
    y
    j
    +2
    • 5
    • 6
  • j

    Jonas

    11/14/2025, 8:38 AM
    The IntelliJ feature where compiler generated code is shown inline is quite new, right? @Zac Sweers showed it in his stream with Code with Italians. I currently try to figure out in which IntelliJ Version it was added and when it will probably land in Android Studio.
    solved 1
    h
    z
    • 3
    • 8
  • j

    Javier

    11/14/2025, 3:07 PM
    Is it not possible to find annotated references from dependencies with FIR without knowing the exact
    FqName
    , right? So the only workaround about this is that the Gradle Plugin uses something like Classgraph to find those references and pass them to the compiler when syncing/building?
    👌 1
    l
    • 2
    • 6
  • m

    martmists

    11/15/2025, 10:44 PM
    Running into a weird issue where a IrFunctionReferenceImpl passed as argument to an irCall, it seems to get lowered to
    null.INSTANCE
    , what could be the cause of this? Sample snippet where I pass a ctor reference:
    Copy code
    val result = irCall(apply).apply {
        typeArguments[0] = klass.defaultType
        dispatchReceiver = product
        arguments.addAll(1,
            listOf(
                builder,
                IrFunctionReferenceImpl(
                    klass.startOffset,
                    klass.endOffset,
                    pluginContext.irBuiltIns.functionN(ctor.nonDispatchParameters.size).typeWith(*ctor.nonDispatchParameters.map { it.type }.toTypedArray(), klass.defaultType),
                    ctor.symbol,
                    0,
                )
            )
        )
    }
  • f

    Fergus Hewson

    11/16/2025, 10:01 PM
    Copy code
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.intellij.util.containers.Unsafe (file:/Users/fergushewson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler/2.2.20/cdea4080fdae6867e9826af835df82e7f2b48a16/kotlin-compiler-2.2.20.jar)
    WARNING: Please consider reporting this to the maintainers of class com.intellij.util.containers.Unsafe
    WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
    I'm getting this message when writing a compiler plugin, where/how should I report this?
    e
    • 2
    • 3
  • c

    Caleb B

    11/17/2025, 12:22 AM
    How robust is the "run .kts in the context of a project" system? Is it secure enough to be used as a
    constexpr
    interpreter?