@@ -16,9 +16,27 @@ class KindProjector(val global: Global) extends Plugin {
1616 val name = " kind-projector"
1717 val description = " Expand type lambda syntax"
1818 val components = new KindRewriter (this , global) :: Nil
19+
20+ var enableForall = false
21+
22+ override def processOptions (options : List [String ], error : String => Unit ): Unit = {
23+
24+ // enable ∀ rewrites if "forall=true" is present
25+ val (forallOpts, rest) = options partition { _.split(" =" )(0 ) == " forall" }
26+ enableForall = forallOpts.lastOption match {
27+ case Some (opt) =>
28+ opt.split(" =" ).tail match {
29+ case Array (" true" ) => true
30+ case _ => false
31+ }
32+ case None => false
33+ }
34+
35+ if (rest.nonEmpty) error(s " Unrecognized ${name} options: ${rest.mkString}" )
36+ }
1937}
2038
21- class KindRewriter (plugin : Plugin , val global : Global )
39+ class KindRewriter (plugin : KindProjector , val global : Global )
2240 extends PluginComponent with Transform with TypingTransformers with TreeDSL {
2341
2442 import global ._
@@ -191,7 +209,7 @@ class KindRewriter(plugin: Plugin, val global: Global)
191209 atPos(tree.pos.makeTransparent)(
192210 q " new $arrowType { def $methodName[ $TParam]( $name: $f[ $TParam]): $g[ $TParam] = $body } "
193211 )
194- case PolyVal (targetType, methodName, tArgs, body) =>
212+ case PolyVal (targetType, methodName, tArgs, body) if plugin.enableForall =>
195213 atPos(tree.pos.makeTransparent)(tArgs match {
196214 case Nil =>
197215 val tParam = newTypeName(freshName(" A" ))
0 commit comments