diff options
author | Martin Odersky <odersky@gmail.com> | 2012-09-16 20:55:44 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-09-17 16:28:09 +0200 |
commit | c30a9bddc49592fef6d054cd0ce4e7ec2c035f71 (patch) | |
tree | 21f8401798184c34be4239cd6ce4f6dc6fa142c0 /test | |
parent | 61c83d2903f1c68c943ea646e75b4ca32d75f991 (diff) | |
download | scala-c30a9bddc49592fef6d054cd0ce4e7ec2c035f71.tar.gz scala-c30a9bddc49592fef6d054cd0ce4e7ec2c035f71.tar.bz2 scala-c30a9bddc49592fef6d054cd0ce4e7ec2c035f71.zip |
Fixes SI-6337 by disallowing nested value classes.
It seems for the moment too hard to allow this, and the functionality to have value classes wrap other value classes does not seem essential.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t5878.check | 16 | ||||
-rw-r--r-- | test/files/neg/t6337.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6337.scala | 21 |
3 files changed, 36 insertions, 8 deletions
diff --git a/test/files/neg/t5878.check b/test/files/neg/t5878.check index 50dba0d272..c60c4653a2 100644 --- a/test/files/neg/t5878.check +++ b/test/files/neg/t5878.check @@ -1,13 +1,13 @@ -t5878.scala:1: error: value class may not unbox to itself +t5878.scala:1: error: value class may not wrap another user-defined value class case class Foo(x: Bar) extends AnyVal - ^ -t5878.scala:2: error: value class may not unbox to itself + ^ +t5878.scala:2: error: value class may not wrap another user-defined value class case class Bar(x: Foo) extends AnyVal - ^ -t5878.scala:4: error: value class may not unbox to itself + ^ +t5878.scala:4: error: value class may not wrap another user-defined value class class Foo1(val x: Bar1) extends AnyVal - ^ -t5878.scala:5: error: value class may not unbox to itself + ^ +t5878.scala:5: error: value class may not wrap another user-defined value class class Bar1(val x: Foo1) extends AnyVal - ^ + ^ four errors found diff --git a/test/files/neg/t6337.check b/test/files/neg/t6337.check new file mode 100644 index 0000000000..8448f71320 --- /dev/null +++ b/test/files/neg/t6337.check @@ -0,0 +1,7 @@ +t6337.scala:10: error: value class may not wrap another user-defined value class +class X[T](val i: XX[T]) extends AnyVal + ^ +t6337.scala:20: error: value class may not wrap another user-defined value class +class X1[T](val i: XX1[T]) extends AnyVal + ^ +two errors found diff --git a/test/files/neg/t6337.scala b/test/files/neg/t6337.scala new file mode 100644 index 0000000000..c3858f8c04 --- /dev/null +++ b/test/files/neg/t6337.scala @@ -0,0 +1,21 @@ +object C { + + def main(args: Array[String]) = { + val x = new X(new XX(3)) + println(x.i.x + 9) + } + +} + +class X[T](val i: XX[T]) extends AnyVal +class XX[T](val x: T) extends AnyVal + +object C1 { + def main(args: Array[String]) { + val x = new X1(new XX1(Some(3))) + println(x.i.x.get + 9) + } +} + +class X1[T](val i: XX1[T]) extends AnyVal +class XX1[T](val x: Option[T]) extends AnyVal |