What happens (what’s the recommended way to handle...
# compiler
m
What happens (what’s the recommended way to handle it) when
Copy code
override fun generateFunctions(
    callableId: CallableId,
    context: MemberGenerationContext?,
): List<FirNamedFunctionSymbol>
Returns a function with a signature that conflicts with an existing one?
d
If it happens, something will break (most likely some checker would return a conflict error). So make sure your extension doesn't do it.
m
Just to make sure I’ve got it right, are you saying that I cannot delegate handling conflicts to the compiler?
Copy code
class MyClass {
    fun f() {}
    fun f() {}
}
The compiler detects and generates a diagnostic for this conflict if this code is manually written.
Copy code
@MyAnnotation
class MyClass {
    fun f() {}
}
But if
@MyAnnotation
triggers my plugin to generate another (conflicting)
fun f()
method, my plugin should handle (prevent) conflicts by itself?
d
The compiler expects that everything is generated by plugins entirely correct. If the plugin breaks this assumption, something could go wrong in unpredictable ways.
m
That makes sense. But what counts as Correct? https://kotlinlang.slack.com/archives/C7L3JB43G/p1791788451078739
d
Informal definition: compiler accepts this declaration if it was written manually in code (by hand, not by plugin). Can't provide a formal definition.
m
So step 3 is incorrect even though the JVM allows it. That’s tricky. Thanks for the explanation.
d
It's trickier with such deep manipulations actually, and it always depends on the specific case. Your idea of changing everything to private could break in various places when internal declaration is actually accessible in some way. E.g. it's allowed to call internals of the main module in the test module. Or you could have public open class with an internal member and inheritor of it in the other module, and compiler could try to generate a bridge method to this internal from the base class (can't provide the exact example though).