Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[split] Eval.scala: Allow @deprecated

The Scala compiler propagates warnings through exceptions.  So Eval
failed if an Eval'ed file uses something deprecated.  Disable
warnings.

RB_ID=63167
  • Loading branch information...
commit aa03e89b7c29d40fb21a2f9d694d70e1ecbd0e10 1 parent 5017ce0
@dhelder dhelder authored
View
3  util-eval/src/main/scala/com/twitter/util/Eval.scala
@@ -418,8 +418,7 @@ class Eval(target: Option[File]) {
val cache = new mutable.HashMap[String, Class[_]]()
val settings = new Settings
- settings.deprecation.value = true // enable detailed deprecation warnings
- settings.unchecked.value = true // enable detailed unchecked warnings
+ settings.nowarnings.value = true // warnings are exceptions, so disable
settings.outputDirs.setSingleOutput(target)
val pathList = compilerPath ::: libPath
View
6 util-eval/src/test/resources/Deprecated.scala
@@ -0,0 +1,6 @@
+new (() => String) {
+ @deprecated("don't use hello")
+ def hello() = "hello"
+
+ def apply() = hello()
+}
View
6 util-eval/src/test/scala/com/twitter/util/EvalSpec.scala
@@ -93,6 +93,12 @@ class EvalSpec extends SpecificationWithJUnit {
(new Eval).apply[Int](getClass.getResourceAsStream("/OnePlusOne.scala")) mustEqual 2
}
+ "uses deprecated" in {
+ val deprecated = (new Eval).apply[() => String](
+ TempFile.fromResourcePath("/Deprecated.scala"))
+ deprecated() mustEqual "hello"
+ }
+
"inPlace('expression')" in {
// Old object API works
Eval.compile("object Doubler { def apply(n: Int) = n * 2 }")
Please sign in to comment.
Something went wrong with that request. Please try again.