Skip to content

Commit

Permalink
Position generated trees, allowing use under -Yrangepos / IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed May 7, 2015
1 parent 91e5636 commit 862d2a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ scalacOptions in Test <+= (packageBin in Compile) map {
pluginJar => "-Xplugin:" + pluginJar
}

scalacOptions in Test ++= Seq("-Yrangepos")

// Useful for debugging:
// scalacOptions in Test ++= Seq("-Xprint:typer", "-Xprint-pos")

crossScalaVersions := Seq("2.10.5", "2.11.6", "2.12.0-M1")

seq(bintrayPublishSettings: _*)
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/KindProjector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ class KindRewriter(plugin: Plugin, val global: Global)

tree match {
case Template(parents, self, body) =>
Template(parents.map(transform), self, body.map(transform))
treeCopy.Template(tree, parents.map(transform), self, body.map(transform))

// Lambda[A => Either[A, Int]] case.
case AppliedTypeTree(Ident(TypeLambda1), AppliedTypeTree(_, a :: as) :: Nil) =>
handleLambda(a, as)
atPos(tree.pos.makeTransparent)(handleLambda(a, as))

// λ[A => Either[A, Int]] case.
case AppliedTypeTree(Ident(TypeLambda2), AppliedTypeTree(_, a :: as) :: Nil) =>
handleLambda(a, as)
atPos(tree.pos.makeTransparent)(handleLambda(a, as))

// Either[?, Int] case (if no ? present this is a noop)
case AppliedTypeTree(t, as) =>
handlePlaceholders(t, as)
atPos(tree.pos.makeTransparent)(handlePlaceholders(t, as))

// Otherwise, carry on as normal.
case _ =>
Expand Down

0 comments on commit 862d2a4

Please sign in to comment.