From aad84ecba3eda180197bfbbb45a02393358c4c46 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 29 Jul 2012 16:23:20 +0200 Subject: SI-5799 Secondary constructors in value classes not allowed I changed the SIP and added a test. --- test/files/neg/t5799.check | 4 ++++ test/files/neg/t5799.scala | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/files/neg/t5799.check create mode 100644 test/files/neg/t5799.scala (limited to 'test') diff --git a/test/files/neg/t5799.check b/test/files/neg/t5799.check new file mode 100644 index 0000000000..10e2658d56 --- /dev/null +++ b/test/files/neg/t5799.check @@ -0,0 +1,4 @@ +t5799.scala:2: error: value class may not have secondary constructors + def this(s: String) = this(s.toDouble) + ^ +one error found diff --git a/test/files/neg/t5799.scala b/test/files/neg/t5799.scala new file mode 100644 index 0000000000..9bd6ab7dd1 --- /dev/null +++ b/test/files/neg/t5799.scala @@ -0,0 +1,8 @@ +class Foo(val bar: Double) extends AnyVal { + def this(s: String) = this(s.toDouble) +} +object Test { + def main(args: Array[String]): Unit = + new Foo("") + } + -- cgit v1.2.3