summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-03-05 16:05:07 +0100
committerMartin Odersky <odersky@gmail.com>2012-03-05 16:05:44 +0100
commitedaf481155a550c2b5199de6702c7cbdc2007d58 (patch)
tree1fc03da097d60cdce0e3cd752d768c7864055e07 /test/files/neg
parent0df343a0c614d6a7468105769568b2fba3f9b03c (diff)
downloadscala-edaf481155a550c2b5199de6702c7cbdc2007d58.tar.gz
scala-edaf481155a550c2b5199de6702c7cbdc2007d58.tar.bz2
scala-edaf481155a550c2b5199de6702c7cbdc2007d58.zip
new and updated test cases for value classes.
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t900.check4
-rw-r--r--test/files/neg/valueclasses.scala18
2 files changed, 20 insertions, 2 deletions
diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check
index cede26258b..047094ad6e 100644
--- a/test/files/neg/t900.check
+++ b/test/files/neg/t900.check
@@ -2,8 +2,8 @@ t900.scala:4: error: type mismatch;
found : Foo.this.x.type (with underlying type Foo.this.bar)
required: AnyRef
Note that implicit conversions are not applicable because they are ambiguous:
- both method any2Ensuring in object Predef of type [A](x: A)Ensuring[A]
- and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A]
+ both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd
+ and method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat
are possible conversion functions from Foo.this.x.type to AnyRef
def break(): x.type
^
diff --git a/test/files/neg/valueclasses.scala b/test/files/neg/valueclasses.scala
index 5979f6f684..e405d95489 100644
--- a/test/files/neg/valueclasses.scala
+++ b/test/files/neg/valueclasses.scala
@@ -31,6 +31,24 @@ class V12[@specialized T, U](val x: (T, U)) extends AnyVal // fail
class V13(x: Int) extends AnyVal // fail
+package time {
+object TOD {
+ final val SecondsPerDay = 86400
+
+ def apply(seconds: Int) = {
+ val n = seconds % SecondsPerDay
+ new TOD(if (n >= 0) n else n + SecondsPerDay)
+ }
+}
+
+final class TOD private (val secondsOfDay: Int) extends AnyVal { // should fail with private constructor
+ def hours = secondsOfDay / 3600
+ def minutes = (secondsOfDay / 60) % 60
+ def seconds = secondsOfDay % 60
+
+ override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds)
+}
+}