diff options
author | Martin Odersky <odersky@gmail.com> | 2012-03-06 17:48:42 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-03-06 17:50:40 +0100 |
commit | 1e9277689461452c594dc547dc0b0ceab8cd3e7d (patch) | |
tree | 07a4cb55a4f90d05dcd093e3d7b562ba28513e6d /test/files/run | |
parent | fa55e4f0f8d2834becdb9a9aef9c3ea65cb31fee (diff) | |
download | scala-1e9277689461452c594dc547dc0b0ceab8cd3e7d.tar.gz scala-1e9277689461452c594dc547dc0b0ceab8cd3e7d.tar.bz2 scala-1e9277689461452c594dc547dc0b0ceab8cd3e7d.zip |
Fixes to value classes: Flags now double definitions, private constructors as errors. Fixed erasure scheme.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/valueclasses-constr.check | 2 | ||||
-rw-r--r-- | test/files/run/valueclasses-constr.scala | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/valueclasses-constr.check b/test/files/run/valueclasses-constr.check new file mode 100644 index 0000000000..df37fbc723 --- /dev/null +++ b/test/files/run/valueclasses-constr.check @@ -0,0 +1,2 @@ +0 +00:16:40 diff --git a/test/files/run/valueclasses-constr.scala b/test/files/run/valueclasses-constr.scala new file mode 100644 index 0000000000..7a10299386 --- /dev/null +++ b/test/files/run/valueclasses-constr.scala @@ -0,0 +1,25 @@ +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 (val secondsOfDay: Int) extends AnyVal { + def hours = secondsOfDay / 3600 + def minutes = (secondsOfDay / 60) % 60 + def seconds = secondsOfDay % 60 + + override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) +} + +object Test extends App { + + val y: TOD = new TOD(1000) + val x: TOD = TOD(1000) + println(x.hours) + println(x) +} + |