aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/SamplePhase.scala
blob: 137ab2eda67f540e2eb42636b1bd3695510c5778 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package dotty.tools.dotc
package transform

import TreeTransforms._
import core.DenotTransformers._
import core.Denotations._
import core.Contexts._
import ast.Trees._
import ast.tpd.{Apply, Tree, cpy}

class SamplePhase extends TreeTransformer {

  def init(implicit ctx: Context) = {
    ctx.base.denotTransformers.install(id, new UncurryDenotTransform(_))
  }

  def name = "sample"

  def transformations = Array(new UncurryTreeTransform(_, _))

}

class UncurryDenotTransform(group: DenotTransformerGroup) extends DenotTransformer(group) {

  def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = ???

}

class UncurryTreeTransform(group: TreeTransformer, idx: Int) extends TreeTransform(group, idx) {

  override def transformApply(tree: Apply)(implicit ctx: Context, info: TransformerInfo): Tree =
    tree match {
      case Apply(fn, args) => cpy.Apply(tree, fn, args ++ tree.args)
      case _ => tree
    }
}