Skip to content

Commit

Permalink
Merge pull request #282 from ThoughtWorksInc/fix-280
Browse files Browse the repository at this point in the history
Don't transform macros (fix #280)
  • Loading branch information
Atry authored Jul 27, 2019
2 parents 7cf0c54 + 58e8b8e commit 4aa9190
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compilerplugins-ResetEverywhere/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ scalacOptions ++= {
Seq()
}
}

scalacOptions in Test += raw"""-Xplugin:${(packageBin in Compile).value}"""
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ final class ResetEverywhere(override val global: Global) extends Plugin {
body.mapConserve {
case valDef: ValDef if !valDef.mods.isParamAccessor =>
transformRootValDef(valDef)
case defDef: DefDef if defDef.mods.hasFlag(Flag.MACRO) =>
defDef
case initializer: TermTree =>
annotatedReset(initializer)
case stat =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.thoughtworks.dsl.compilerplugins

object Issue280 {
import scala.language.experimental.macros

object ContainsMacro {

def apply: String = macro Macros.apply

}

class Macros(val c: scala.reflect.macros.blackbox.Context) {

import c.universe._

def apply: Tree = q"???"

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ import scala.runtime.NonLocalReturnControl
*/
class YieldSpec extends FreeSpec with Matchers {

{
!Yield(1)

def nested(): Stream[Int] = {
!Yield(2)
Stream.empty[Int]
}

nested()
} // Should compile

"Given a continuation that uses Yield and Each expressions" - {

def asyncFunction: Stream[String] !! Unit = _ {
Expand Down

0 comments on commit 4aa9190

Please sign in to comment.