Closed
Description
object Test {
if ({ println("hi"); true })
1
else
2
}
Becomes, after RefChecks
:
Test$() extends Object() {
1
}
There are two very wrong things here:
- This sort of optimization should be done in its own mini-phase, it has nothing to do with
RefChecks
- The optimization is wrong because it only looks at the type of the condition (and check that it's a
ConstantType
), it should also check the purity of the tree. This should be done by sharing code withTreeInfo#constToLiteral