File tree Expand file tree Collapse file tree 3 files changed +27
-19
lines changed Expand file tree Collapse file tree 3 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ private[async] final case class TransformUtils[C <: Context](c: C) {
5858 val renamer = new Transformer {
5959 override def transform (tree : Tree ) = tree match {
6060 case Ident (_) => (renameMap get tree.symbol).fold(tree)(Ident (_))
61+ case tt : TypeTree if tt.original != EmptyTree && tt.original != null =>
62+ // We also have to apply our renaming transform on originals of TypeTrees.
63+ // TODO 2.10.1 Can we find a cleaner way?
64+ val symTab = c.universe.asInstanceOf [reflect.internal.SymbolTable ]
65+ val tt1 = tt.asInstanceOf [symTab.TypeTree ]
66+ tt1.setOriginal(transform(tt.original).asInstanceOf [symTab.Tree ])
67+ super .transform(tree)
6168 case _ => super .transform(tree)
6269 }
6370 }
Original file line number Diff line number Diff line change @@ -69,8 +69,10 @@ object TreeInterrogation extends App {
6969 withDebug {
7070 val cm = reflect.runtime.currentMirror
7171 val tb = mkToolbox(" -cp target/scala-2.10/classes -Xprint:flatten" )
72+ import scala .async .Async ._
7273 val tree = tb.parse(
73- """ async {
74+ """ import scala.async.AsyncId._
75+ | async {
7476 | val x = 1
7577 | val opt = Some("")
7678 | await(0)
Original file line number Diff line number Diff line change @@ -83,24 +83,23 @@ class MatchSpec {
8383 result mustBe (2 )
8484 }
8585
86- // TODO 2.10.1
87- // @Test def `support await referring to pattern matching vals`() {
88- // import AsyncId.{async, await}
89- // val result = async {
90- // val x = 1
91- // val opt = Some("")
92- // await(0)
93- // val o @ Some(y) = opt
94- //
95- // {
96- // val o @ Some(y) = Some(".")
97- // }
98- //
99- // await(0)
100- // await((o, y.isEmpty))
101- // }
102- // result mustBe ((Some(""), true))
103- // }
86+ @ Test def `support await referring to pattern matching vals` () {
87+ import AsyncId .{async , await }
88+ val result = async {
89+ val x = 1
90+ val opt = Some (" " )
91+ await(0 )
92+ val o @ Some (y) = opt
93+
94+ {
95+ val o @ Some (y) = Some (" ." )
96+ }
97+
98+ await(0 )
99+ await((o, y.isEmpty))
100+ }
101+ result mustBe ((Some (" " ), true ))
102+ }
104103
105104 @ Test def `await in scrutinee` () {
106105 import AsyncId .{async , await }
You can’t perform that action at this time.
0 commit comments