diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-08-10 14:52:24 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-08-15 08:06:22 +0200 |
commit | 840ad7656456f014135c2a5e31e0d9ffd63625bd (patch) | |
tree | e3333eae1e5db6457638ba6455efebd1f54d8ca5 /test/files | |
parent | 1b5f73129fc2f678d00905e5d851536251f8821a (diff) | |
download | scala-840ad7656456f014135c2a5e31e0d9ffd63625bd.tar.gz scala-840ad7656456f014135c2a5e31e0d9ffd63625bd.tar.bz2 scala-840ad7656456f014135c2a5e31e0d9ffd63625bd.zip |
marks Expr.splice and Expr.value with @compileTimeOnly
Now that @compileTimeOnly is part of the standard library, why don't
we use it within the standard library.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/compile-time-only-b.check | 7 | ||||
-rw-r--r-- | test/files/neg/compile-time-only-b.scala | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/files/neg/compile-time-only-b.check b/test/files/neg/compile-time-only-b.check new file mode 100644 index 0000000000..8292a0ddeb --- /dev/null +++ b/test/files/neg/compile-time-only-b.check @@ -0,0 +1,7 @@ +compile-time-only-b.scala:13: error: splice must be enclosed within a reify {} block + val ignored3 = reify(fortyTwo).splice + ^ +compile-time-only-b.scala:14: error: cannot use value except for signatures of macro implementations + val ignored4 = reify(fortyTwo).value + ^ +two errors found diff --git a/test/files/neg/compile-time-only-b.scala b/test/files/neg/compile-time-only-b.scala new file mode 100644 index 0000000000..d5568dbe67 --- /dev/null +++ b/test/files/neg/compile-time-only-b.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + // HAHA!!! + // no compileTimeOnly errors here, because scalac does constant folding + // the type of reify(42) is Expr[42.type] + // therefore the type of expr.splice is 42.type, which is then constfolded + val expr = reify(42) + val ignored1 = expr.splice + val ignored2 = expr.value + + val fortyTwo = 42 + val ignored3 = reify(fortyTwo).splice + val ignored4 = reify(fortyTwo).value +}
\ No newline at end of file |