diff options
author | Paul Phillips <paulp@improving.org> | 2012-06-04 12:05:57 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-06-06 14:23:45 -0700 |
commit | 241c7606d0bf5f3209b9d549fb751dbbc5b8e514 (patch) | |
tree | 1a9ce60b92f37cf6ca58f69a7fdcaecd90e532bb /src/library/scala/Float.scala | |
parent | a43e070e232ce35ef14fce34458ee3ea6e823078 (diff) | |
download | scala-241c7606d0bf5f3209b9d549fb751dbbc5b8e514.tar.gz scala-241c7606d0bf5f3209b9d549fb751dbbc5b8e514.tar.bz2 scala-241c7606d0bf5f3209b9d549fb751dbbc5b8e514.zip |
Generate abstract methods in scala.Byte and friends.
Rather than stub implementations. This saves over 50K of bytecode.
I also added the necessary imports to silence the feature warnings.
Diffstat (limited to 'src/library/scala/Float.scala')
-rw-r--r-- | src/library/scala/Float.scala | 185 |
1 files changed, 95 insertions, 90 deletions
diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index bb03581062..bd7a07fece 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Float`, a 32-bit IEEE-754 floating point number (equivalent to Java's `float` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Float` are not * represented by an object in the underlying runtime system. @@ -17,349 +19,349 @@ package scala * There is an implicit conversion from [[scala.Float]] => [[scala.runtime.RichFloat]] * which provides useful non-primitive operations. */ -final class Float private extends AnyVal { - def toByte: Byte = sys.error("stub") - def toShort: Short = sys.error("stub") - def toChar: Char = sys.error("stub") - def toInt: Int = sys.error("stub") - def toLong: Long = sys.error("stub") - def toFloat: Float = sys.error("stub") - def toDouble: Double = sys.error("stub") +final abstract class Float private extends AnyVal { + def toByte: Byte + def toShort: Short + def toChar: Char + def toInt: Int + def toLong: Long + def toFloat: Float + def toDouble: Double /** * Returns this value, unmodified. */ - def unary_+ : Float = sys.error("stub") + def unary_+ : Float /** * Returns the negation of this value. */ - def unary_- : Float = sys.error("stub") + def unary_- : Float - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Byte): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Short): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Char): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Int): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Long): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Float): Boolean /** * Returns `true` if this value is equal to x, `false` otherwise. */ - def ==(x: Double): Boolean = sys.error("stub") + def ==(x: Double): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Byte): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Short): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Char): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Int): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Long): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Float): Boolean /** * Returns `true` if this value is not equal to x, `false` otherwise. */ - def !=(x: Double): Boolean = sys.error("stub") + def !=(x: Double): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Byte): Boolean = sys.error("stub") + def <(x: Byte): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Short): Boolean = sys.error("stub") + def <(x: Short): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Char): Boolean = sys.error("stub") + def <(x: Char): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Int): Boolean = sys.error("stub") + def <(x: Int): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Long): Boolean = sys.error("stub") + def <(x: Long): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Float): Boolean = sys.error("stub") + def <(x: Float): Boolean /** * Returns `true` if this value is less than x, `false` otherwise. */ - def <(x: Double): Boolean = sys.error("stub") + def <(x: Double): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Byte): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Short): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Char): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Int): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Long): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Float): Boolean /** * Returns `true` if this value is less than or equal to x, `false` otherwise. */ - def <=(x: Double): Boolean = sys.error("stub") + def <=(x: Double): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Byte): Boolean = sys.error("stub") + def >(x: Byte): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Short): Boolean = sys.error("stub") + def >(x: Short): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Char): Boolean = sys.error("stub") + def >(x: Char): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Int): Boolean = sys.error("stub") + def >(x: Int): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Long): Boolean = sys.error("stub") + def >(x: Long): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Float): Boolean = sys.error("stub") + def >(x: Float): Boolean /** * Returns `true` if this value is greater than x, `false` otherwise. */ - def >(x: Double): Boolean = sys.error("stub") + def >(x: Double): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Byte): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Short): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Char): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Int): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Long): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Float): Boolean /** * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ - def >=(x: Double): Boolean = sys.error("stub") + def >=(x: Double): Boolean /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Float = sys.error("stub") + def +(x: Byte): Float /** * Returns the sum of this value and `x`. */ - def +(x: Short): Float = sys.error("stub") + def +(x: Short): Float /** * Returns the sum of this value and `x`. */ - def +(x: Char): Float = sys.error("stub") + def +(x: Char): Float /** * Returns the sum of this value and `x`. */ - def +(x: Int): Float = sys.error("stub") + def +(x: Int): Float /** * Returns the sum of this value and `x`. */ - def +(x: Long): Float = sys.error("stub") + def +(x: Long): Float /** * Returns the sum of this value and `x`. */ - def +(x: Float): Float = sys.error("stub") + def +(x: Float): Float /** * Returns the sum of this value and `x`. */ - def +(x: Double): Double = sys.error("stub") + def +(x: Double): Double /** * Returns the difference of this value and `x`. */ - def -(x: Byte): Float = sys.error("stub") + def -(x: Byte): Float /** * Returns the difference of this value and `x`. */ - def -(x: Short): Float = sys.error("stub") + def -(x: Short): Float /** * Returns the difference of this value and `x`. */ - def -(x: Char): Float = sys.error("stub") + def -(x: Char): Float /** * Returns the difference of this value and `x`. */ - def -(x: Int): Float = sys.error("stub") + def -(x: Int): Float /** * Returns the difference of this value and `x`. */ - def -(x: Long): Float = sys.error("stub") + def -(x: Long): Float /** * Returns the difference of this value and `x`. */ - def -(x: Float): Float = sys.error("stub") + def -(x: Float): Float /** * Returns the difference of this value and `x`. */ - def -(x: Double): Double = sys.error("stub") + def -(x: Double): Double /** * Returns the product of this value and `x`. */ - def *(x: Byte): Float = sys.error("stub") + def *(x: Byte): Float /** * Returns the product of this value and `x`. */ - def *(x: Short): Float = sys.error("stub") + def *(x: Short): Float /** * Returns the product of this value and `x`. */ - def *(x: Char): Float = sys.error("stub") + def *(x: Char): Float /** * Returns the product of this value and `x`. */ - def *(x: Int): Float = sys.error("stub") + def *(x: Int): Float /** * Returns the product of this value and `x`. */ - def *(x: Long): Float = sys.error("stub") + def *(x: Long): Float /** * Returns the product of this value and `x`. */ - def *(x: Float): Float = sys.error("stub") + def *(x: Float): Float /** * Returns the product of this value and `x`. */ - def *(x: Double): Double = sys.error("stub") + def *(x: Double): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Byte): Float = sys.error("stub") + def /(x: Byte): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Float = sys.error("stub") + def /(x: Short): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Float = sys.error("stub") + def /(x: Char): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Float = sys.error("stub") + def /(x: Int): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Float = sys.error("stub") + def /(x: Long): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Float): Float = sys.error("stub") + def /(x: Float): Float /** * Returns the quotient of this value and `x`. */ - def /(x: Double): Double = sys.error("stub") + def /(x: Double): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Byte): Float = sys.error("stub") + def %(x: Byte): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Float = sys.error("stub") + def %(x: Short): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Float = sys.error("stub") + def %(x: Char): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Float = sys.error("stub") + def %(x: Int): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Float = sys.error("stub") + def %(x: Long): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Float): Float = sys.error("stub") + def %(x: Float): Float /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Double): Double = sys.error("stub") + def %(x: Double): Double - override def getClass(): Class[Float] = sys.error("stub") + override def getClass(): Class[Float] = null } -object Float extends AnyValCompanion { +object Float extends AnyValCompanion { /** The smallest positive value greater than 0.0f which is * representable as a Float. */ @@ -401,6 +403,9 @@ object Float extends AnyValCompanion { /** The String representation of the scala.Float companion object. */ override def toString = "object scala.Float" + + /** Language mandated coercions from Float to "wider" types. + */ implicit def float2double(x: Float): Double = x.toDouble } |