Skip to content

Commit 08afc2f

Browse files
Stable names for lambda lifted methods (#18281)
This is a straightforward port of the LambdaLift changes from scala/scala@69d60cb Sorting using Symbol#id is not stable since we may create symbols in different orders depending on how typechecking proceeds.
2 parents ce1ce99 + be5af89 commit 08afc2f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/src/dotty/tools/dotc/transform/Dependencies.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package transform
44
import core.*
55
import Symbols.*, Contexts.*, Types.*, Flags.*, Decorators.*
66
import SymUtils.*
7-
import collection.mutable.{LinkedHashMap, TreeSet}
7+
import collection.mutable.{LinkedHashMap, LinkedHashSet}
88
import annotation.constructorOnly
99

1010
import dotty.tools.backend.sjs.JSDefinitions.jsdefn
@@ -33,7 +33,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
3333
*/
3434
def logicalOwner: collection.Map[Symbol, Symbol] = logicOwner
3535

36-
private type SymSet = TreeSet[Symbol]
36+
private type SymSet = LinkedHashSet[Symbol]
3737

3838
/** A map storing free variables of functions and classes */
3939
private val free: LinkedHashMap[Symbol, SymSet] = new LinkedHashMap
@@ -56,8 +56,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
5656
/** A flag to indicate whether lifted owners have changed */
5757
private var changedLogicOwner: Boolean = _
5858

59-
private val ord: Ordering[Symbol] = Ordering.by(_.id)
60-
private def newSymSet = TreeSet.empty[Symbol](ord)
59+
private def newSymSet: LinkedHashSet[Symbol] = new LinkedHashSet[Symbol]
6160

6261
private def symSet(f: LinkedHashMap[Symbol, SymSet], sym: Symbol): SymSet =
6362
f.getOrElseUpdate(sym, newSymSet)

0 commit comments

Comments
 (0)