diff options
author | odersky <odersky@gmail.com> | 2017-02-02 09:28:14 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 09:28:14 +1100 |
commit | cca5dd9bd0c8f0d2e5679c81f2c40247a45d7a02 (patch) | |
tree | 5fb6048ffe8f75d9d36271cc76f791ed00888935 /tests | |
parent | b5185f1b4481ef61243741c7f7ed0ba8f696776b (diff) | |
parent | ab32f4c42d10e830a4d61e50099b03894db78bbe (diff) | |
download | dotty-cca5dd9bd0c8f0d2e5679c81f2c40247a45d7a02.tar.gz dotty-cca5dd9bd0c8f0d2e5679c81f2c40247a45d7a02.tar.bz2 dotty-cca5dd9bd0c8f0d2e5679c81f2c40247a45d7a02.zip |
Merge pull request #1925 from dotty-staging/fix/inner-vc
Fix #1644: Disallow inner classes in value classes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/valueclasses-impl-restrictions.scala | 19 | ||||
-rw-r--r-- | tests/untried/neg/valueclasses-impl-restrictions.scala | 29 |
2 files changed, 19 insertions, 29 deletions
diff --git a/tests/neg/valueclasses-impl-restrictions.scala b/tests/neg/valueclasses-impl-restrictions.scala new file mode 100644 index 000000000..9f33b7e7c --- /dev/null +++ b/tests/neg/valueclasses-impl-restrictions.scala @@ -0,0 +1,19 @@ +class X1(val s: String) extends AnyVal { + trait I2 { // error: value class may not define an inner class or trait + val q: String + def z = s + q + } +} + +class X2(val s: String) extends AnyVal { + private[this] class I2(val q: String) // error: value class may not define an inner class or trait + + def y(i: Int) = { + val i2 = new I2(i.toString) + i2.q + s + } +} + +class X3(val s: String) extends AnyVal { + object I3 // error: value class may not define non-parameter field +} diff --git a/tests/untried/neg/valueclasses-impl-restrictions.scala b/tests/untried/neg/valueclasses-impl-restrictions.scala deleted file mode 100644 index f0577a94a..000000000 --- a/tests/untried/neg/valueclasses-impl-restrictions.scala +++ /dev/null @@ -1,29 +0,0 @@ -class M(val t: Int) extends AnyVal { - def lazyString = { - object X - () => X - } -} - -class X1(val s: String) extends AnyVal { - trait I2 { - val q: String - def z = s + q - } - - def y(x: X1) = { - val i2 = new I2 { val q = x.s } // allowed as of SI-7571 - i2.z - - { case x => x } : PartialFunction[Int, Int] // allowed - } -} - -class X2(val s: String) extends AnyVal { - private[this] class I2(val q: String) - - def y(i: Int) = { - val i2 = new I2(i.toString) - i2.q + s - } -} |