kotlinx/ast

Argument with unary prefix is incomplete in summary AST

Closed this issue · 2 comments

If I run:

KotlinGrammarAntlrKotlinParser.parseKotlinFile(AstSource.String("source", "val b = f(!thisIsNotAvailable)"))

Then !thisIsNotAvailable is represented in the raw AST as a prefixUnaryExpression with a unaryPrefix (!) and postfixUnaryExpression (thisIsNotAvailable).

When i look at the corresponding summary AST, there is a KlassDeclaration with keyword argument supposedly representing !thisIsNotAvailable. However, looking at the argument's expression shows only a unaryPrefix node for the ! but no node for the identifier thisIsNotAvailable. If I look at the attached raw AST, the identifier is still there as expected.

Unless I'm missing something, I guess this is a bug.

Unless I'm completely confused at the moment and doing something stupid, it seems to apply to more types of expressions when used as function arguments.

I get the same behavior for:

val s = f("a" + "b") // see only the +, not the string literals
val o = f(this ?: that) // does not see this/that or even an elvis operator literal

Hi @henrikbarium, this library can parse only the code outline, the content of functions are not implemented. I close this ticket as a duplicate of #69 and #21, I hope this is fine for you.