From 5d9cde105e804d14e2c15c3e15c147a56cb67ff1 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Wed, 3 Oct 2012 14:43:30 +0200 Subject: Put more implementation restrictions on value classes. Nested objects, classes and lazy vals are disallowed at any nesting level in value classes; e.g. lazy vals local to a method defined in a value class. There are still allowed in universal traits. This is a temporary, implementation restriction that is planned to be addressed in future releases of Scala. Error messages has been updated to communicate that intent. Moved tests for SI-5582 and SI-6408 to pending folder. They have to stay there until implementation restrictions are addressed. Closes SI-6408 and SI-6432. Review by @odersky, @harrah and @adriaanm. --- test/pending/run/t5882.scala | 14 ++++++++++++++ test/pending/run/t6408.scala | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/pending/run/t5882.scala create mode 100644 test/pending/run/t6408.scala (limited to 'test/pending') diff --git a/test/pending/run/t5882.scala b/test/pending/run/t5882.scala new file mode 100644 index 0000000000..47996d3068 --- /dev/null +++ b/test/pending/run/t5882.scala @@ -0,0 +1,14 @@ +// SIP-15 was revised to allow nested classes in value classes. +// This test checks that their basic functionality. + +class NodeOps(val n: Any) extends AnyVal { self => + class Foo() { def show = self.show(n) } + def show(x: Any) = x.toString +} + + +object Test extends App { + + val n = new NodeOps("abc") + assert(new n.Foo().show == "abc") +} diff --git a/test/pending/run/t6408.scala b/test/pending/run/t6408.scala new file mode 100644 index 0000000000..ff17480b35 --- /dev/null +++ b/test/pending/run/t6408.scala @@ -0,0 +1,11 @@ +class X(val i: Int) extends AnyVal { + class Inner(val q: Int) { + def plus = i + q + } +} + +object Test extends App { + val x = new X(11) + val i = new x.Inner(22) + assert(i.plus == 33) +} -- cgit v1.2.3