aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/inlinevals.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/neg/inlinevals.scala b/tests/neg/inlinevals.scala
new file mode 100644
index 000000000..184aa2168
--- /dev/null
+++ b/tests/neg/inlinevals.scala
@@ -0,0 +1,24 @@
+object Test {
+
+ def power(x: Double, inline n: Int): Double = ???
+
+ inline val N = 10
+ def X = 20
+
+ inline inline val twice = 30 // error: repeated modifier
+
+ class C(inline x: Int, private inline val y: Int) {
+ inline val foo: Int // error: abstract member may not be inline
+ inline def bar: Int // error: abstract member may not be inline
+ }
+
+ power(2.0, N) // ok, since it's a by-name parameter
+ power(2.0, X) // error: argument to inline parameter must be a constant expression
+
+ inline val M = X // error: rhs must be constant expression
+
+ def byname(inline f: => String): Int = ??? // ok
+
+ byname("hello" ++ " world")
+
+}