SBT 0.13.0 - can't expand macros compiled by previous versions of Scala -


given following:

src/main/scala/net/equals5.scala

package net  import scala.language.experimental.macros import scala.reflect.macros.context  case class equals5(value: int) {     require(value == 5) }  object equals5 {     implicit def wrapint(n: int): equals5 = macro verifyintequals5      def verifyintequals5(c: context)(n: c.expr[int]): c.expr[equals5] = {     import c.universe._      val tree = n.tree match {       case literal(constant(x: int)) if x == 5 =>         q"_root_.net.equals5($n)"       case literal(constant(x: int)) =>         c.abort(c.enclosingposition, s"$x != 0")       case _ =>          q"_root_.net.equals5($n)"     }     c.expr(tree)   } } 

build.sbt

val paradiseversion = "2.1.0-m5"  scalaversion := "2.11.7"  librarydependencies += "org.scala-lang" % "scala-reflect" % "2.11.7"  librarydependencies += "org.scalatest" % "scalatest_2.10" % "3.0.0-m7" 

project/build.properties

sbt.version=0.13.0 

i can compile successfully, trying run following test:

src/test/scala/net/equals5test.scala

package net  import org.scalatest.matchers  import org.scalatest._ import org.scalatest.prop.checkers._  class equals5test extends flatspec matchers {      "trying create `equals5` case class invalid int" should "fail compile" in {         "equals5(-555)" shouldnot compile     } } 

gives compile-time error:

.../equals5test.scala:11: can't expand macros compiled        previous versions of scala [error]         "equals5(-555)" shouldnot compile [error]                                   ^ 

looking @ answer, expected using scala 2.11 sbt 0.13.0 would've fixed issue.

please let me know how resolve compile-time error.

you requesting scalatest version compiled scala 2.10, macros compile won't expanded correctly (and it's quite not compatible scala 2.11 in other ways well). (also current sbt version 0.13.9, may want update well.)


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -