Skip to content

Commit

Permalink
Extract typecheck to Compat since it was renamed in 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
makkarpov committed Apr 24, 2016
1 parent 1ce8840 commit 281b8c9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val common = Seq(
version <<= version in LocalRootProject,

crossPaths := true,
scalaVersion := "2.11.7",
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.4", "2.11.7"),
scalacOptions ++= Seq( "-Xfatal-warnings", "-feature", "-deprecation" ),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ object Compat {
type Context = scala.reflect.macros.Context
def prettyPrint(c: Context)(e: c.Tree): String = c.universe.show(e)
def termName(c: Context)(s: String): c.TermName = c.universe.newTermName(c.fresh(s))
def typecheck(c: Context)(e: c.Tree): c.Tree = c.typeCheck(e)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ object Compat {
type Context = whitebox.Context
def prettyPrint(c: Context)(e: c.Tree): String = c.universe.showCode(e)
def termName(c: Context)(s: String): c.TermName = c.universe.TermName(c.freshName(s))
def typecheck(c: Context)(e: c.Tree): c.Tree = c.typecheck(e)
}
4 changes: 2 additions & 2 deletions scalingua/src/main/scala/ru/makkarpov/scalingua/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ object Macros {
// Find a variable that represents plural number and strip `.nVar`s, if any.
val (filteredArgs, nVar) = {
val intVars = args.indices.filter { i =>
val tpe = c.typecheck(args(i)).tpe
val tpe = typecheck(c)(args(i)).tpe
(tpe <:< typeOf[Int]) || (tpe <:< typeOf[Long])
}

Expand Down Expand Up @@ -200,7 +200,7 @@ object Macros {

for {
arg <- args
tpe = c.typecheck(arg).tpe
tpe = typecheck(c)(arg).tpe
} if (tpe <:< weakTypeOf[Suffix]) {
val rawSuffix =
if (tpe <:< weakTypeOf[Suffix.S]) "s"
Expand Down

0 comments on commit 281b8c9

Please sign in to comment.