summaryrefslogtreecommitdiff
path: root/test/files/run/t10009.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/t10009.scala')
-rw-r--r--test/files/run/t10009.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/files/run/t10009.scala b/test/files/run/t10009.scala
new file mode 100644
index 0000000000..2a318752f1
--- /dev/null
+++ b/test/files/run/t10009.scala
@@ -0,0 +1,28 @@
+import scala.reflect.runtime.currentMirror
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+
+object Test {
+ def test(code: String, log: Boolean = false) {
+ val tb = currentMirror.mkToolBox()
+ val tree = tb.parse(code)
+ val typed = tb.typecheck(tree)
+ if (log) {
+ println("=" * 80)
+ println(typed)
+ }
+ val untyped = tb.untypecheck(typed)
+ if (log) println(untyped)
+ val retyped = tb.typecheck(untyped)
+ if (log) println(retyped)
+ }
+ def main(args: Array[String]): Unit = {
+ test("{ class a { val x = 42 }; new a }") // failed
+ test("{ trait a { val x = 42 }; new a {} }") // worked
+ test("{ abstract class a { val x: Int } }") // worked
+ test("{ abstract class a { val x: Int }; new a { val x = 42 } }") // failed
+ test("{ class a { private val x = 42 }; new a }") // failed
+ test("{ class a { protected val x = 42 }; new a { x } }") // failed
+ test("{ class a { protected[a] val x = 42 }; new a }") // failed
+ }
+} \ No newline at end of file