Skip to content

Commit

Permalink
Add macro -Xlint tests (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
htmldoug authored Jul 14, 2021
1 parent d20954c commit 180ab7c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,9 @@ lazy val weexml = project
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.12.3",
)
)

lazy val `weepickle-macro-lint-tests` = project
.dependsOn(weepickle)
.settings(noPublish)
.settings(scalacOptions := (scalacOptions.value ++ Seq("-Xlint", "-Xfatal-warnings")).distinct)
// .settings(scalacOptions += "-Ymacro-debug-lite")
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ private object MacroImplicits {
def storeAggregatedValue(currentIndex: Int, v: Any): Unit = currentIndex match{
case ..${for (arg <- args)
yield cq"${arg.i} => ${arg.aggregate} = v.asInstanceOf[${arg.argType}]"}
case _ => throw new java.lang.IndexOutOfBoundsException(currentIndex.toString)
}
def visitKey() = com.rallyhealth.weepickle.v1.core.StringVisitor
def visitKeyValue(s: Any) = {
Expand Down Expand Up @@ -550,6 +551,8 @@ private object MacroImplicits {
} yield i match{
case ..${for (arg <- args)
yield cq"${arg.i} => ${arg.mapped}"}
case _ => throw new java.lang.IndexOutOfBoundsException(i.toString)

}
throw new com.rallyhealth.weepickle.v1.core.Abort(
"missing keys in dictionary: " + keys.mkString(", ")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.rallyhealth.weepickle.v1

import com.rallyhealth.weepickle.v1.WeePickle.{FromTo, macroFromTo}

/**
* @see https://github.com/com-lihaoyi/upickle/issues/345
*/
case class SingleInt(num: Int)
object SingleInt {
implicit val pickler: FromTo[SingleInt] = macroFromTo
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The macro expansions of these classes should compile without any `-Xlint` errors.

0 comments on commit 180ab7c

Please sign in to comment.