summaryrefslogtreecommitdiff
path: root/sources/scala/tools/nsc/transform/InfoTransform.scala
blob: a5af6beb065e8c2fdcb928e09925af72a20ea200 (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
/* NSC -- new scala compiler
 * Copyright 2005 LAMP/EPFL
 * @author
 */
// $Id$
package scala.tools.nsc.transform;

/** A base class for transforms.
 *  A transform contains a compiler phase which applies a tree transformer.
 */
abstract class InfoTransform extends Transform {
  import global.{Symbol, Type, InfoTransformer, infoTransformers};

  def transformInfo(sym: Symbol, tpe: Type): Type;

  override def newPhase(prev: scala.tools.nsc.Phase): StdPhase = new Phase(prev);

  protected def changesBaseClasses = true;

  class Phase(prev: scala.tools.nsc.Phase) extends super.Phase(prev) {
    if (infoTransformers.nextFrom(id).pid != id) {
      val infoTransformer = new InfoTransformer {
	val pid = id;
	val changesBaseClasses = InfoTransform.this.changesBaseClasses;
	def transform(sym: Symbol, tpe: Type): Type = transformInfo(sym, tpe);
      }
      infoTransformers.insert(infoTransformer)
    }
  }
}