`FirFunctionCallRefinementExtension` is acting ver...
# compiler
y
FirFunctionCallRefinementExtension
is acting very weird (on Kotlin 2.2.20). I'm getting a lot of calls where
intercept
is called, but
transform
isn't. The culprit seems to be that its return value is immediately used as an argument for another statement:
Copy code
Foo(x.someCallThatShouldGetRefined())
This is resulting in ill-formed IR, among other things. Why is my
transform
not being called? I know it's an experimental extension and everything, but this feels like an issue that might thus plague
DataFrame
as well. EDIT: The culprit seems to be this check because
reference is FirNamedReferenecWithCandidate
for some reason. I think most uses of DataFrame don't run into this because
FirNamedReferenecWithCandidate
only happens (I think) when you have a function call surrounded by another function call, but the natural pattern for DataFrame is to use extension methods. Is this intended behaviour?
cc: @Nikita Klimenko [JB] since you worked on this
I understand that maybe
FirNamedReferenecWithCandidate
means that the call is not guaranteed to have been chosen yet, but I'd then expect
transform
to be called eventually elsewhere.
n
Hi, can you share more details: what's signature of Foo, is the expression being transformed inside a function body? This simple test works:
Copy code
fun <T> take(value: T): T = value

fun box(): String {
    val df = take(dataFrameOf("a" to columnOf(42)).add("test") { "str" })
    df.a
    df.test
    return "OK"
}
Foo(x.someCallThatShouldGetRefined())
compiles if you disable the plugin?
y
Investigating deeper, I realise that this can't be reproduced with data frame. The problem happens specifically when
intercept
returns a type that includes a type parameter of the function, and that type parameter must only show up in the return type of a lambda. In other words, consider a dumb
intercept
that always returns the same type as the one passed in. Then, this would cause the issue:
Copy code
fun <T> foo(block: () -> T): T = block()
with(foo { "hi" }) { }
But, if
intercept
never incorporates those type parameters in its return type, which seems to be the case for DataFrame, then the problem never manifests