Closed SerVB closed 3 years ago
Piotr, don't you remember why it was decided to use lists for expressions? Maybe I just don't see something...
By checking git history, I see this commit: https://github.com/krzema12/kotlin-python/commit/1aab214e39f85788d3437c0ae4b22327de5da644 (Make IrElementToPyExpressionTransformer return Listexpr
a List<expr>
. So yeah, this change seems to be not well thought-through :sweat_smile: I was iterating and experimenting very quickly back then. With your PR you proved that we can simplify it :+1: The box tests are an excellent safety net in case of such refactorings.
This PR includes commits from #24, so let's deal with this PR after we deal with #24.Here we get rid of lists in expr transformer and use plain expr now. That's because I've noticed that I always have to box expressions in
listOf
and then unbox them via.single
. Logically, we don't need list of expressions since an expression is a single thing.It was true for almost every IR element but for vararg. I've adjusted vararg a bit and see we have some positive changes in the
out_ir.py
and also we have +1 passed box test now :)For statements, I've left lists as it's quite reasonable to me (but maybe in the future we will decide that it's more handy to have plain stmt, but we will need to do something with
stmt* body
appearing in multiple places, maybe extract a function that handles them).Piotr, don't you remember why it was decided to use lists for expressions? Maybe I just don't see something...