|
1 | 1 | package scala.async.internal |
2 | 2 |
|
3 | | -import scala.tools.nsc.Global |
4 | | -import scala.tools.nsc.transform.TypingTransformers |
5 | | - |
6 | 3 | object AsyncMacro { |
7 | | - def apply(c: reflect.macros.Context, base: AsyncBase): AsyncMacro = { |
| 4 | + def apply(c0: reflect.macros.Context, base: AsyncBase): AsyncMacro { val c: c0.type } = { |
8 | 5 | import language.reflectiveCalls |
9 | | - val powerContext = c.asInstanceOf[c.type { val universe: Global; val callsiteTyper: universe.analyzer.Typer }] |
10 | | - new AsyncMacro { |
11 | | - val global: powerContext.universe.type = powerContext.universe |
12 | | - val callSiteTyper: global.analyzer.Typer = powerContext.callsiteTyper |
13 | | - val macroApplication: global.Tree = c.macroApplication.asInstanceOf[global.Tree] |
| 6 | + new AsyncMacro { self => |
| 7 | + val c: c0.type = c0 |
14 | 8 | // This member is required by `AsyncTransform`: |
15 | | - val asyncBase: AsyncBase = base |
| 9 | + val asyncBase: AsyncBase = base |
16 | 10 | // These members are required by `ExprBuilder`: |
17 | | - val futureSystem: FutureSystem = base.futureSystem |
18 | | - val futureSystemOps: futureSystem.Ops {val universe: global.type} = futureSystem.mkOps(global) |
| 11 | + val futureSystem: FutureSystem = base.futureSystem |
| 12 | + val futureSystemOps: futureSystem.Ops {val c: self.c.type} = futureSystem.mkOps(c) |
19 | 13 | } |
20 | 14 | } |
21 | 15 | } |
22 | 16 |
|
23 | 17 | private[async] trait AsyncMacro |
24 | | - extends TypingTransformers |
25 | | - with AnfTransform with TransformUtils with Lifter |
| 18 | + extends AnfTransform with TransformUtils with Lifter |
26 | 19 | with ExprBuilder with AsyncTransform with AsyncAnalysis with LiveVariables { |
27 | 20 |
|
28 | | - val global: Global |
29 | | - val callSiteTyper: global.analyzer.Typer |
30 | | - val macroApplication: global.Tree |
31 | | - |
32 | | - lazy val macroPos = macroApplication.pos.makeTransparent |
33 | | - def atMacroPos(t: global.Tree) = global.atPos(macroPos)(t) |
34 | | - |
35 | | - def suppressExpansion() { |
36 | | - // Have your cake : Scala IDE sees original trees and hyperlinking, etc within async blocks "Just Works" |
37 | | - // Eat it too : (domain specific errors like "unsupported use of await" |
38 | | - // |
39 | | - // TODO remove this once we unsupport 2.10.x, scalac 2.11 does this automatically. |
40 | | - |
41 | | - import global.Tree |
42 | | - type Suppress = { def suppressMacroExpansion(a: Tree): Tree } |
43 | | - try { |
44 | | - global.asInstanceOf[Suppress].suppressMacroExpansion(macroApplication) |
45 | | - } catch { |
46 | | - case _: NoSuchMethodException => |
47 | | - global.analyzer.asInstanceOf[Suppress].suppressMacroExpansion(macroApplication) |
48 | | - } |
49 | | - } |
| 21 | + val c: scala.reflect.macros.Context |
50 | 22 |
|
| 23 | + lazy val macroPos = c.macroApplication.pos.makeTransparent |
| 24 | + def atMacroPos(t: c.Tree) = c.universe.atPos(macroPos)(t) |
51 | 25 | } |
0 commit comments