diff --git a/plugintest/project/build/project.scala b/plugintest/project/build/project.scala new file mode 100644 index 0000000000000000000000000000000000000000..4fbe5b8a72d3dd57b0fab808cd20e109efeaaa53 --- /dev/null +++ b/plugintest/project/build/project.scala @@ -0,0 +1,4 @@ +import sbt._ + +class PluginTestProject(info: ProjectInfo) extends DefaultProject(info) { +} diff --git a/plugintest/src/main/scala/plugintest/Plugin.scala b/plugintest/src/main/scala/plugintest/Plugin.scala new file mode 100644 index 0000000000000000000000000000000000000000..0df83947cb44f1dfd94f145697b9f44a6c97b924 --- /dev/null +++ b/plugintest/src/main/scala/plugintest/Plugin.scala @@ -0,0 +1,34 @@ +package plugintest + +import scala.tools.nsc +import scala.tools.nsc.{Global,Phase} +import scala.tools.nsc.plugins._ + +class TestPlugin(val global : Global) extends Plugin { + import global._ + + val name = "test!" + val description = "Mini plugin to toy with ``MyAny'' type of things" + + override val optionsHelp : Option[String] = None + + val components = List[PluginComponent](new Component(global)) + val descriptions : List[String]("tests with ``MyAny''") +} + +class Component(val global : Global) extends PluginComponent { + import global._ + + override val runsRightAfter : Option[String] = None + override val runsAfter : List[String] = List("refchecks") + + val phaseName = "test!" + + def newPhase(previous : Phase) = new PluginPhase(previous) +} + +class PluginPhase(previous : Phase) extends StdPhase(previous) { + def apply(unit : CompilationUnit) : Unit = { + println("Phase ran !") + } +} diff --git a/plugintest/src/main/scala/plugintest/package.scala b/plugintest/src/main/scala/plugintest/package.scala new file mode 100644 index 0000000000000000000000000000000000000000..e1e92fda482f5d8574657463dc782c57e061ec95 --- /dev/null +++ b/plugintest/src/main/scala/plugintest/package.scala @@ -0,0 +1,19 @@ +package object plugintest { + trait MyAny + + sealed trait IsMyAny[T] { + val manifest : ClassManifest[T] + } + + implicit def isMyAny[T <: MyAny : ClassManifest] = new IsMyAny[T] { + val manifest = implicitly[ClassManifest[T]] + } + + implicit object IntIsMyAny extends IsMyAny[Int] { + val manifest = implicitly[ClassManifest[Int]] + } + + implicit object BooleanIsMyAny extends IsMyAny[Boolean] { + val manifest = implicitly[ClassManifest[Boolean]] + } +}