diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-11-02 18:12:40 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-11-02 18:12:40 -0700 |
commit | 0d90320c918db8024a58ebef727d8b957410d0af (patch) | |
tree | 1f0ed35f2ff65e4fb6db4c8f4e320511518b4a0b /src | |
parent | 424072aeaa391de40531f33694985072cbb70152 (diff) | |
parent | 817da386e456be422861ac6e974838e6eb6db836 (diff) | |
download | scala-0d90320c918db8024a58ebef727d8b957410d0af.tar.gz scala-0d90320c918db8024a58ebef727d8b957410d0af.tar.bz2 scala-0d90320c918db8024a58ebef727d8b957410d0af.zip |
Merge pull request #1562 from paulp/issue/6600
Fix for SI-6600, regression with ScalaNumber.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/math/ScalaNumericConversions.scala | 15 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaNumberProxy.scala | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index edf243e5df..08c4118b00 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -10,15 +10,22 @@ package scala.math import java.{ lang => jl } +/** A slightly more specific conversion trait for classes which + * extend ScalaNumber (which excludes value classes.) + */ +trait ScalaNumericConversions extends ScalaNumber with ScalaNumericAnyConversions { + def underlying(): Object +} + /** Conversions which present a consistent conversion interface - * across all the numeric types. + * across all the numeric types, suitable for use in value classes. */ -trait ScalaNumericConversions extends Any { +trait ScalaNumericAnyConversions extends Any { def isWhole(): Boolean def underlying(): Any - def byteValue(): Byte = intValue().toByte - def shortValue(): Short = intValue().toShort + def byteValue(): Byte + def shortValue(): Short def intValue(): Int def longValue(): Long def floatValue(): Float diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index df2d209e3e..e461783423 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -9,7 +9,7 @@ package scala.runtime import scala.collection.{ mutable, immutable } -import scala.math.ScalaNumericConversions +import scala.math.{ ScalaNumericConversions, ScalaNumericAnyConversions } import immutable.NumericRange import Proxy.Typed @@ -20,7 +20,7 @@ import Proxy.Typed * @version 2.9 * @since 2.9 */ -trait ScalaNumberProxy[T] extends Any with ScalaNumericConversions with Typed[T] with OrderedProxy[T] { +trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed[T] with OrderedProxy[T] { protected implicit def num: Numeric[T] def underlying() = self.asInstanceOf[AnyRef] @@ -28,6 +28,8 @@ trait ScalaNumberProxy[T] extends Any with ScalaNumericConversions with Typed[T] def floatValue() = num.toFloat(self) def longValue() = num.toLong(self) def intValue() = num.toInt(self) + def byteValue() = intValue.toByte + def shortValue() = intValue.toShort def min(that: T): T = num.min(self, that) def max(that: T): T = num.max(self, that) |