I see that "if" expressions are represented as "wh...
# k2-adopters
r
I see that "if" expressions are represented as "when" expressions in FIR. I'm trying to distinguish "else" branch in "if" expression. To do this I'm checking for instanceof FirElseIfTrueCondition. In result, I'm getting compilation error - java compiler cannot access FirElseIfTrueCondition class. This happens in both 1.9 and 2.0 Beta2.
Copy code
java: cannot access org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
  bad class file: /.../kotlin-compiler-2.0.0-Beta2.jar!/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.class
    undeclared type variable: T
    Please remove or make sure it appears in the correct subdirectory of the classpath.
Is there any other way I can check for "else" branch using K2 API?
d
Did you try to do the same using kotlin?
r
It works from kotlin, I can compile it with kotlinc
d
It's curios why it can't be loaded by javac
The reason is most likely KT-52706
r
So looks like the best way is to use K2 API from Kotlin rather than from Java, right? What about checking for
element.getSource() == null
in this particular case? As a temporary solution.
d
So looks like the best way is to use K2 API from Kotlin rather than from Java, right?
Yes, it's better to use it from Kotlin
What about checking for
element.getSource() == null
in this particular case? As a temporary solution.
source
is not reliable source of information If you really want to stick with java you can use smth like that:
Copy code
element.class.getName().equals("FirElseIfTrueCondition")
r
Thank you very much for the tip!
👌 1