diff options
author | Martin Odersky <odersky@gmail.com> | 2015-07-02 14:36:36 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-07-02 14:37:12 +0200 |
commit | f57a6d9db6b8119bef1a78aabef4a527a0f9905c (patch) | |
tree | 7ecdb4b69efc356ef13d2e6196937510fa8245bd /tests/neg | |
parent | 257bf52c3d205359896e3c391274091b3fab732e (diff) | |
download | dotty-f57a6d9db6b8119bef1a78aabef4a527a0f9905c.tar.gz dotty-f57a6d9db6b8119bef1a78aabef4a527a0f9905c.tar.bz2 dotty-f57a6d9db6b8119bef1a78aabef4a527a0f9905c.zip |
Check value class member restrictions
According to SIP 15 a value class C must obey the following restrictions:
C may not have secondary constructors.
C may not declare fields (other than the parameter of a value class).
C may not contain object definitions.
C may not have initialization statements.
These are enforced by this commit. We are still missing restrictions on
value class paremeters. We should review what the right set of conditions
is (probably we want to admit non-vals, and maybe even multiple
parameters).
Diffstat (limited to 'tests/neg')
-rw-r--r-- | tests/neg/i705-inner-value-class.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/neg/i705-inner-value-class.scala b/tests/neg/i705-inner-value-class.scala index 6dec7b0f9..f638b0670 100644 --- a/tests/neg/i705-inner-value-class.scala +++ b/tests/neg/i705-inner-value-class.scala @@ -2,6 +2,13 @@ class Foo { class B(val a: Int) extends AnyVal // error } +class VCwithBadMembers(val a: Int) extends AnyVal { + def this() = this(1) // error + var x = 0 // error + val y = 2 // error + println("hi") // error +} + object Test { class B(val a: Int) extends AnyVal // ok def f = { |