Skip to content

Fix #2738: Use a LinkedHashMap for traversal determinism #2766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
* Note: During tree transform (which runs at phase LambdaLift + 1), liftedOwner
* is also used to decide whether a method had a term owner before.
*/
private val liftedOwner = new HashMap[Symbol, Symbol]
private val liftedOwner = new LinkedHashMap[Symbol, Symbol]

/** The outer parameter of a constructor */
private val outerParam = new HashMap[Symbol, Symbol]
Expand Down
8 changes: 8 additions & 0 deletions tests/run/i2738.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
foo
bar$1
foo
bar$2
baz
Test$qux$2$
baz
Test$qux$4$
49 changes: 49 additions & 0 deletions tests/run/i2738.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
object Test {

def main(args: Array[String]): Unit = {
foo(1)
foo("a")
baz(2)
baz("b")
}

def foo[X <: Int](x: X) = {
def bar = printlnThisMethodName()
printlnThisMethodName()
bar
}

def foo(x: String) = {
def bar = printlnThisMethodName()
printlnThisMethodName()
bar
}

def baz[X <: Int](x: X) = {
object qux {
override def toString() = {
printlnThisMethodsClassName()
"a"
}
}
printlnThisMethodName()
qux.toString()
}

def baz(x: String) = {
object qux {
override def toString() = {
printlnThisMethodsClassName()
"b"
}
}
printlnThisMethodName()
qux.toString()
}

def printlnThisMethodName() =
println(Thread.currentThread().getStackTrace()(2).getMethodName)

def printlnThisMethodsClassName() =
println(Thread.currentThread().getStackTrace()(2).getClassName)
}