Skip to content

Commit 74beb1b

Browse files
committed
Scala 2.10.1 compat: apply renaming to originals of TypeTrees
This time in the ANF/Inline transformation.
1 parent b60346c commit 74beb1b

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/main/scala/scala/async/AnfTransform.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ private[async] final case class AnfTransform[C <: Context](c: C) {
8888
if (renamed(tree.symbol)) {
8989
treeCopy.Select(tree, transform(fun), tree.symbol.name)
9090
} else super.transform(tree)
91+
case tt: TypeTree =>
92+
val tt1 = tt.asInstanceOf[symtab.TypeTree]
93+
val orig = tt1.original
94+
if (orig != null) tt1.setOriginal(transform(orig.asInstanceOf[Tree]).asInstanceOf[symtab.Tree])
95+
super.transform(tt)
9196
case _ => super.transform(tree)
9297
}
9398
}

src/test/scala/scala/async/run/anf/AnfTransformSpec.scala

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,23 @@ class AnfTransformSpec {
112112
State.result mustBe (14)
113113
}
114114

115-
// TODO 2.10.1
116-
// @Test
117-
// def `inlining block does not produce duplicate definition`() {
118-
// import scala.async.AsyncId
119-
//
120-
// AsyncId.async {
121-
// val f = 12
122-
// val x = AsyncId.await(f)
123-
//
124-
// {
125-
// type X = Int
126-
// val x: X = 42
127-
// println(x)
128-
// }
129-
// type X = Int
130-
// x: X
131-
// }
132-
// }
115+
@Test
116+
def `inlining block does not produce duplicate definition`() {
117+
import scala.async.AsyncId
118+
119+
AsyncId.async {
120+
val f = 12
121+
val x = AsyncId.await(f)
122+
123+
{
124+
type X = Int
125+
val x: X = 42
126+
println(x)
127+
}
128+
type X = Int
129+
x: X
130+
}
131+
}
133132

134133
@Test
135134
def `inlining block in tail position does not produce duplicate definition`() {

0 commit comments

Comments
 (0)