All Downloads are FREE. Search and download functionalities are using the official Maven repository.

miniboxing.plugin.transform.tweakerasure.TweakErasureTreeTransformer.scala Maven / Gradle / Ivy

There is a newer version: 0.4-M8
Show newest version
package miniboxing.plugin
package transform
package tweakerasure

import scala.tools.nsc.plugins.PluginComponent
import scala.tools.nsc.transform.TypingTransformers
import scala.reflect.internal.Phase
import miniboxing.plugin.transform.infrastructure.TreeRewriters

trait TweakErasureTreeTransformer extends TreeRewriters with ScalacCrossCompilingLayer {
  self: TweakErasureComponent =>

  import global._

  class TweakErasurePhase(prev: Phase) extends StdPhase(prev) {
    override def name = TweakErasureTreeTransformer.this.phaseName
    def apply(unit: CompilationUnit): Unit = {
      val transformer = new TweakErasureTransformer(unit)
      transformer.transformUnit(unit)
    }
  }

  object CallNobridgeMethod {
    def unapply(tree: Tree): Boolean = tree match {
      case Apply(method, args) if method.symbol.hasAnnotation(interop.nobridgeClass) => true
      case _ => false
    }
  }

  class TweakErasureTransformer(unit: CompilationUnit) extends TreeRewriter(unit) {
    override def rewrite(tree: Tree) = tree match {
      case dd @ DefDef(mods, name, _, _, _, CallNobridgeMethod()) if dd.symbol.isBridge =>
//        println("wiped: " + dd)
        Nil
      case _ =>
        Descend
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy