Skip to content

Commit 4a8b7b4

Browse files
Fix multiple executions of optimisation transformation due to by name
1 parent ec804ad commit 4a8b7b4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/transform/localopt/Simplify.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
101101
var rhs1: Tree = null
102102
while (rhs1 ne rhs0) {
103103
rhs1 = rhs0
104-
val context = ctx.withOwner(tree.symbol)
105-
optimisations.foreach { optimisation => // TODO: fuse for performance
104+
optimisations.foreach { optimisation =>
106105
// Visit
107106
rhs0.foreachSubTree(optimisation.visitor)
108107

@@ -130,14 +129,16 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
130129
else if (fuel == 0)
131130
tree1 // No more fuel? No more transformations for you!
132131
else { // Print the trees if different and consume fuel accordingly.
133-
if (tree1 ne tree2) {
134-
if (fuel > 0) fuel -= 1
135-
if (fuel != -1) {
132+
val t2 = tree2
133+
if (tree1 ne t2) {
134+
if (fuel > 0)
135+
fuel -= 1
136+
if (fuel != -1 && fuel < 5) {
136137
println(s"${tree1.symbol} was simplified by ${opt.name} (fuel=$fuel): ${tree1.show}")
137-
println(s"became after ${opt.name}: (fuel=$fuel) ${tree2.show}")
138+
println(s"became after ${opt.name}: (fuel=$fuel) ${t2.show}")
138139
}
139140
}
140-
tree2
141+
t2
141142
}
142143
}
143144
}

0 commit comments

Comments
 (0)