diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-06-25 16:40:27 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-06-25 16:40:27 -0700 |
commit | d22e8d282c538a711f6fdd33793c06cd7676959d (patch) | |
tree | 7e8cd0d67a73cd0bd309242233435dbf13c905e6 /test/files | |
parent | bdd5b4ad9f667fb7d61ed70cdf5ffacff55a5472 (diff) | |
parent | e7ac254349e56678824ade3027bca3908882e291 (diff) | |
download | scala-d22e8d282c538a711f6fdd33793c06cd7676959d.tar.gz scala-d22e8d282c538a711f6fdd33793c06cd7676959d.tar.bz2 scala-d22e8d282c538a711f6fdd33793c06cd7676959d.zip |
Merge pull request #2648 from retronym/ticket/7571
SI-7571 Allow nesting of anonymous classes in value classes
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/valueclasses-impl-restrictions.check | 8 | ||||
-rw-r--r-- | test/files/neg/valueclasses-impl-restrictions.scala | 4 | ||||
-rw-r--r-- | test/files/run/t7571.scala | 12 |
3 files changed, 17 insertions, 7 deletions
diff --git a/test/files/neg/valueclasses-impl-restrictions.check b/test/files/neg/valueclasses-impl-restrictions.check index 63924493aa..0af9173f74 100644 --- a/test/files/neg/valueclasses-impl-restrictions.check +++ b/test/files/neg/valueclasses-impl-restrictions.check @@ -6,12 +6,8 @@ valueclasses-impl-restrictions.scala:9: error: implementation restriction: neste This restriction is planned to be removed in subsequent releases. trait I2 { ^ -valueclasses-impl-restrictions.scala:15: error: implementation restriction: nested class is not allowed in value class -This restriction is planned to be removed in subsequent releases. - val i2 = new I2 { val q = x.s } - ^ -valueclasses-impl-restrictions.scala:21: error: implementation restriction: nested class is not allowed in value class +valueclasses-impl-restrictions.scala:23: error: implementation restriction: nested class is not allowed in value class This restriction is planned to be removed in subsequent releases. private[this] class I2(val q: String) ^ -four errors found +three errors found diff --git a/test/files/neg/valueclasses-impl-restrictions.scala b/test/files/neg/valueclasses-impl-restrictions.scala index 137f3f854c..f0577a94aa 100644 --- a/test/files/neg/valueclasses-impl-restrictions.scala +++ b/test/files/neg/valueclasses-impl-restrictions.scala @@ -12,8 +12,10 @@ class X1(val s: String) extends AnyVal { } def y(x: X1) = { - val i2 = new I2 { val q = x.s } + val i2 = new I2 { val q = x.s } // allowed as of SI-7571 i2.z + + { case x => x } : PartialFunction[Int, Int] // allowed } } diff --git a/test/files/run/t7571.scala b/test/files/run/t7571.scala new file mode 100644 index 0000000000..00b9695168 --- /dev/null +++ b/test/files/run/t7571.scala @@ -0,0 +1,12 @@ +class Foo(val a: Int) extends AnyVal { + def foo = { {case x => x + a}: PartialFunction[Int, Int]} + + def bar = (new {}).toString +} + +object Test extends App { + val x = new Foo(1).foo.apply(2) + assert(x == 3, x) + val s = new Foo(1).bar + assert(s.nonEmpty, s) +} |