@@ -12,6 +12,7 @@ import core.Symbols._
12
12
import core .Flags ._
13
13
import ast .Trees ._
14
14
import scala .collection .mutable
15
+ import scala .collection .mutable .LinkedHashMap
15
16
import transform .SymUtils ._
16
17
import config .Printers .simplify
17
18
import Simplify ._
@@ -33,12 +34,12 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
33
34
// ValDefs whose lhs is used with `._1` (or any getter call).
34
35
val gettersCalled = mutable.HashSet [Symbol ]()
35
36
36
- // Map from class to new fields, initialised between visitor and transformer.
37
- var newFieldsMapping : Map [Symbol , Map [Symbol , Symbol ]] = null
38
- // | | |
39
- // | | New fields, replacements these getters
40
- // | Usages of getters of these classes
41
- // ValDefs of the classes that are being torn apart; = candidates.intersect(gettersCalled)
37
+ // Immutable sorted map from class to new fields, initialized between visitor and transformer.
38
+ var newFieldsMapping : Map [Symbol , LinkedHashMap [Symbol , Symbol ]] = null
39
+ // | | |
40
+ // | | New fields, replacements these getters
41
+ // | Usages of getters of these classes
42
+ // ValDefs of the classes that are being torn apart; = candidates.intersect(gettersCalled)
42
43
43
44
def clear (): Unit = {
44
45
candidates.clear()
@@ -57,7 +58,7 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
57
58
val info : Type = x.asSeenFrom(refVal.info).info.finalResultType.widenDealias
58
59
ctx.newSymbol(owner, name, flags, info)
59
60
}
60
- (refVal, accessors.zip(newLocals).toMap )
61
+ (refVal, LinkedHashMap [ Symbol , Symbol ]( accessors.zip(newLocals): _* ) )
61
62
}.toMap
62
63
}
63
64
@@ -99,7 +100,7 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
99
100
Thicket (newFieldsDefs :+ recreate)
100
101
101
102
case t @ Select (rec, _) if isImmutableAccessor(t) =>
102
- newFieldsMapping.getOrElse(rec.symbol, Map .empty).get(t.symbol) match {
103
+ newFieldsMapping.getOrElse(rec.symbol, Map .empty[ Symbol , Symbol ] ).get(t.symbol) match {
103
104
case None => t
104
105
case Some (newSym) => ref(newSym)
105
106
}
@@ -108,3 +109,4 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
108
109
}
109
110
}
110
111
}
112
+
0 commit comments