diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-24 13:23:54 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-24 13:52:41 -0700 |
commit | a7276d5976f57d4f182a55f92693de97acf1de64 (patch) | |
tree | d8aef3889d0ae87cc4ea5ae75ed5addd8b34ea86 /test/files/run | |
parent | 2c554249fd8e99286134b217027b6e3cb2c92d77 (diff) | |
download | scala-a7276d5976f57d4f182a55f92693de97acf1de64.tar.gz scala-a7276d5976f57d4f182a55f92693de97acf1de64.tar.bz2 scala-a7276d5976f57d4f182a55f92693de97acf1de64.zip |
New take on SI-6534, value classes.
Don't prohibit equals and hashCode in universal traits;
instead, always override them in value classes.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t6534.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/files/run/t6534.scala b/test/files/run/t6534.scala new file mode 100644 index 0000000000..33df97e41e --- /dev/null +++ b/test/files/run/t6534.scala @@ -0,0 +1,14 @@ +trait Foo extends Any { override def equals(x: Any) = false } +trait Ding extends Any { override def hashCode = -1 } + +class Bippy1(val x: Int) extends AnyVal with Foo { } // warn +class Bippy2(val x: Int) extends AnyVal with Ding { } // warn + +object Test { + def main(args: Array[String]): Unit = { + val b1 = new Bippy1(71) + val b2 = new Bippy2(71) + assert(b1 == b1 && b1.## == b1.x.##, ((b1, b1.##))) + assert(b2 == b2 && b2.## == b2.x.##, ((b2, b2.##))) + } +} |