From 241c7606d0bf5f3209b9d549fb751dbbc5b8e514 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 4 Jun 2012 12:05:57 -0700 Subject: 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. --- .../scala/reflect/internal/Definitions.scala | 2 - src/compiler/scala/tools/cmd/gen/AnyVals.scala | 33 +-- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 6 +- src/library/scala/AnyVal.scala | 4 +- src/library/scala/Boolean.scala | 29 +-- src/library/scala/Byte.scala | 229 +++++++++++---------- src/library/scala/Char.scala | 229 +++++++++++---------- src/library/scala/Double.scala | 182 ++++++++-------- src/library/scala/Float.scala | 185 +++++++++-------- src/library/scala/Int.scala | 229 +++++++++++---------- src/library/scala/Long.scala | 229 +++++++++++---------- src/library/scala/Short.scala | 229 +++++++++++---------- src/library/scala/Unit.scala | 8 +- 13 files changed, 816 insertions(+), 778 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 0cdef9e79a..96819eab91 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -293,8 +293,6 @@ trait Definitions extends reflect.api.StandardDefinitions { anyval }).asInstanceOf[ClassSymbol] - lazy val AnyVal_getClass = enterNewMethod(AnyValClass, nme.getClass_, Nil, getClassReturnType(AnyValClass.tpe)) - // bottom types lazy val RuntimeNothingClass = getClass(fulltpnme.RuntimeNothing) lazy val RuntimeNullClass = getClass(fulltpnme.RuntimeNull) diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 83cd9c2578..9d0795b2f6 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -177,7 +177,7 @@ trait AnyValReps { case (res, lines) => val xs = lines map { case "" => "" - case s => interpolate(s) + " = " + stub + case s => interpolate(s) } res ++ xs } @@ -205,7 +205,7 @@ trait AnyValReps { def classLines: List[String] def objectLines: List[String] def commonClassLines = List( - "override def getClass(): Class[@name@]" + "override def getClass(): Class[@name@] = null" ) def lcname = name.toLowerCase @@ -248,7 +248,7 @@ trait AnyValReps { def objectDoc = "" def mkImports = "" - def mkClass = assemble("final class " + name + " private extends AnyVal", classLines) + def mkClass = assemble("final abstract class " + name + " private extends AnyVal", classLines) def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines) def make() = List[String]( headerTemplate, @@ -281,6 +281,8 @@ trait AnyValTemplates { %s package scala +import language.implicitConversions + """.trim.format(timestampString) + "\n\n") def classDocTemplate = (""" @@ -294,7 +296,6 @@ package scala """.trim + "\n") def timestampString = "// DO NOT EDIT, CHANGES WILL BE LOST.\n" - def stub = """sys.error("stub")""" def allCompanions = """ /** Transform a value type into a boxed reference type. @@ -373,7 +374,7 @@ class AnyVals extends AnyValReps with AnyValTemplates { * * @return the negated expression */ -def unary_! : Boolean = sys.error("stub") +def unary_! : Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to the same value. @@ -382,7 +383,7 @@ def unary_! : Boolean = sys.error("stub") * - `a` and `b` are `true` or * - `a` and `b` are `false`. */ -def ==(x: Boolean): Boolean = sys.error("stub") +def ==(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to a different value. @@ -391,7 +392,7 @@ def ==(x: Boolean): Boolean = sys.error("stub") * - `a` is `true` and `b` is `false` or * - `a` is `false` and `b` is `true`. */ -def !=(x: Boolean): Boolean = sys.error("stub") +def !=(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. @@ -405,7 +406,7 @@ def !=(x: Boolean): Boolean = sys.error("stub") * behaves as if it was declared as `def ||(x: => Boolean): Boolean`. * If `a` evaluates to `true`, `true` is returned without evaluating `b`. */ -def ||(x: Boolean): Boolean = sys.error("stub") +def ||(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if both of them evaluate to true. @@ -417,11 +418,11 @@ def ||(x: Boolean): Boolean = sys.error("stub") * behaves as if it was declared as `def &&(x: => Boolean): Boolean`. * If `a` evaluates to `false`, `false` is returned without evaluating `b`. */ -def &&(x: Boolean): Boolean = sys.error("stub") +def &&(x: Boolean): Boolean // Compiler won't build with these seemingly more accurate signatures -// def ||(x: => Boolean): Boolean = sys.error("stub") -// def &&(x: => Boolean): Boolean = sys.error("stub") +// def ||(x: => Boolean): Boolean +// def &&(x: => Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. @@ -433,7 +434,7 @@ def &&(x: Boolean): Boolean = sys.error("stub") * * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. */ -def |(x: Boolean): Boolean = sys.error("stub") +def |(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if both of them evaluate to true. @@ -443,7 +444,7 @@ def |(x: Boolean): Boolean = sys.error("stub") * * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. */ -def &(x: Boolean): Boolean = sys.error("stub") +def &(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to a different value. @@ -452,9 +453,9 @@ def &(x: Boolean): Boolean = sys.error("stub") * - `a` is `true` and `b` is `false` or * - `a` is `false` and `b` is `true`. */ -def ^(x: Boolean): Boolean = sys.error("stub") +def ^(x: Boolean): Boolean -override def getClass(): Class[Boolean] = sys.error("stub") +override def getClass(): Class[Boolean] = null """.trim.lines.toList def objectLines = interpolate(allCompanions + "\n" + nonUnitCompanions).lines.toList @@ -468,7 +469,7 @@ override def getClass(): Class[Boolean] = sys.error("stub") */ """ def classLines = List( - """override def getClass(): Class[Unit] = sys.error("stub")""" + """override def getClass(): Class[Unit] = null""" ) def objectLines = interpolate(allCompanions).lines.toList diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index c29630d04b..73bcd08f4b 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1961,11 +1961,15 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with && !sym.isMutable // lazy vals and vars both ) + // Primitives are "abstract final" to prohibit instantiation + // without having to provide any implementations, but that is an + // illegal combination of modifiers at the bytecode level so + // suppress final if abstract if present. mkFlags( if (privateFlag) ACC_PRIVATE else ACC_PUBLIC, if (sym.isDeferred || sym.hasAbstractFlag) ACC_ABSTRACT else 0, if (sym.isInterface) ACC_INTERFACE else 0, - if (finalFlag) ACC_FINAL else 0, + if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0, if (sym.isStaticMember) ACC_STATIC else 0, if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0, if (sym.isClass && !sym.isInterface) ACC_SUPER else 0, diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala index 393f0899f4..d637527b30 100644 --- a/src/library/scala/AnyVal.scala +++ b/src/library/scala/AnyVal.scala @@ -26,7 +26,5 @@ package scala * The ''floating point types'' are [[scala.Float]] and [[scala.Double]]. */ abstract class AnyVal extends Any with NotNull { - // disabled for now to make the standard build go through. - // Once we have a new strap we can uncomment this and delete the AnyVal_getClass entry in Definitions. - def getClass(): Class[_ <: AnyVal] = ??? + def getClass(): Class[_ <: AnyVal] = null } diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index edb82b33fe..014928d986 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Boolean` (equivalent to Java's `boolean` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Boolean` are not * represented by an object in the underlying runtime system. @@ -17,7 +19,7 @@ package scala * There is an implicit conversion from [[scala.Boolean]] => [[scala.runtime.RichBoolean]] * which provides useful non-primitive operations. */ -final class Boolean private extends AnyVal { +final abstract class Boolean private extends AnyVal { /** * Negates a Boolean expression. * @@ -26,7 +28,7 @@ final class Boolean private extends AnyVal { * * @return the negated expression */ - def unary_! : Boolean = sys.error("stub") + def unary_! : Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to the same value. @@ -35,7 +37,7 @@ final class Boolean private extends AnyVal { * - `a` and `b` are `true` or * - `a` and `b` are `false`. */ - def ==(x: Boolean): Boolean = sys.error("stub") + def ==(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to a different value. @@ -44,7 +46,7 @@ final class Boolean private extends AnyVal { * - `a` is `true` and `b` is `false` or * - `a` is `false` and `b` is `true`. */ - def !=(x: Boolean): Boolean = sys.error("stub") + def !=(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. @@ -58,7 +60,7 @@ final class Boolean private extends AnyVal { * behaves as if it was declared as `def ||(x: => Boolean): Boolean`. * If `a` evaluates to `true`, `true` is returned without evaluating `b`. */ - def ||(x: Boolean): Boolean = sys.error("stub") + def ||(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if both of them evaluate to true. @@ -70,11 +72,11 @@ final class Boolean private extends AnyVal { * behaves as if it was declared as `def &&(x: => Boolean): Boolean`. * If `a` evaluates to `false`, `false` is returned without evaluating `b`. */ - def &&(x: Boolean): Boolean = sys.error("stub") + def &&(x: Boolean): Boolean // Compiler won't build with these seemingly more accurate signatures - // def ||(x: => Boolean): Boolean = sys.error("stub") - // def &&(x: => Boolean): Boolean = sys.error("stub") + // def ||(x: => Boolean): Boolean + // def &&(x: => Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. @@ -86,7 +88,7 @@ final class Boolean private extends AnyVal { * * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. */ - def |(x: Boolean): Boolean = sys.error("stub") + def |(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if both of them evaluate to true. @@ -96,7 +98,7 @@ final class Boolean private extends AnyVal { * * @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`. */ - def &(x: Boolean): Boolean = sys.error("stub") + def &(x: Boolean): Boolean /** * Compares two Boolean expressions and returns `true` if they evaluate to a different value. @@ -105,12 +107,12 @@ final class Boolean private extends AnyVal { * - `a` is `true` and `b` is `false` or * - `a` is `false` and `b` is `true`. */ - def ^(x: Boolean): Boolean = sys.error("stub") + def ^(x: Boolean): Boolean - override def getClass(): Class[Boolean] = sys.error("stub") + override def getClass(): Class[Boolean] = null } -object Boolean extends AnyValCompanion { +object Boolean extends AnyValCompanion { /** Transform a value type into a boxed reference type. * @@ -132,5 +134,6 @@ object Boolean extends AnyValCompanion { /** The String representation of the scala.Boolean companion object. */ override def toString = "object scala.Boolean" + } diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index b5b3d88e3f..6f54f6cedf 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Byte`, a 8-bit signed integer (equivalent to Java's `byte` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Byte` are not * represented by an object in the underlying runtime system. @@ -17,14 +19,14 @@ package scala * There is an implicit conversion from [[scala.Byte]] => [[scala.runtime.RichByte]] * which provides useful non-primitive operations. */ -final class Byte 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 Byte 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 the bitwise negation of this value. @@ -34,30 +36,30 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def unary_~ : Int = sys.error("stub") + def unary_~ : Int /** * Returns this value, unmodified. */ - def unary_+ : Int = sys.error("stub") + def unary_+ : Int /** * Returns the negation of this value. */ - def unary_- : Int = sys.error("stub") + def unary_- : Int - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Int): Int = sys.error("stub") + def <<(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Long): Int = sys.error("stub") + def <<(x: Long): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -68,7 +70,7 @@ final class Byte private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Int): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -79,7 +81,7 @@ final class Byte private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Long): Int = sys.error("stub") + def >>>(x: Long): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -90,7 +92,7 @@ final class Byte private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Int): Int = sys.error("stub") + def >>(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -101,181 +103,181 @@ final class Byte private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Long): Int = sys.error("stub") + def >>(x: Long): Int /** * 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 bitwise OR of this value and `x`. @@ -287,7 +289,7 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def |(x: Byte): Int = sys.error("stub") + def |(x: Byte): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -298,7 +300,7 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def |(x: Short): Int = sys.error("stub") + def |(x: Short): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -309,7 +311,7 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def |(x: Char): Int = sys.error("stub") + def |(x: Char): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -320,7 +322,7 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def |(x: Int): Int = sys.error("stub") + def |(x: Int): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -331,7 +333,7 @@ final class Byte private extends AnyVal { * // 11111010 * }}} */ - def |(x: Long): Long = sys.error("stub") + def |(x: Long): Long /** * Returns the bitwise AND of this value and `x`. @@ -343,7 +345,7 @@ final class Byte private extends AnyVal { * // 10100000 * }}} */ - def &(x: Byte): Int = sys.error("stub") + def &(x: Byte): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -354,7 +356,7 @@ final class Byte private extends AnyVal { * // 10100000 * }}} */ - def &(x: Short): Int = sys.error("stub") + def &(x: Short): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -365,7 +367,7 @@ final class Byte private extends AnyVal { * // 10100000 * }}} */ - def &(x: Char): Int = sys.error("stub") + def &(x: Char): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -376,7 +378,7 @@ final class Byte private extends AnyVal { * // 10100000 * }}} */ - def &(x: Int): Int = sys.error("stub") + def &(x: Int): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -387,7 +389,7 @@ final class Byte private extends AnyVal { * // 10100000 * }}} */ - def &(x: Long): Long = sys.error("stub") + def &(x: Long): Long /** * Returns the bitwise XOR of this value and `x`. @@ -399,7 +401,7 @@ final class Byte private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Byte): Int = sys.error("stub") + def ^(x: Byte): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -410,7 +412,7 @@ final class Byte private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Short): Int = sys.error("stub") + def ^(x: Short): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -421,7 +423,7 @@ final class Byte private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Char): Int = sys.error("stub") + def ^(x: Char): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -432,7 +434,7 @@ final class Byte private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Int): Int = sys.error("stub") + def ^(x: Int): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -443,157 +445,157 @@ final class Byte private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Long): Long = sys.error("stub") + def ^(x: Long): Long /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Int = sys.error("stub") + def +(x: Byte): Int /** * Returns the sum of this value and `x`. */ - def +(x: Short): Int = sys.error("stub") + def +(x: Short): Int /** * Returns the sum of this value and `x`. */ - def +(x: Char): Int = sys.error("stub") + def +(x: Char): Int /** * Returns the sum of this value and `x`. */ - def +(x: Int): Int = sys.error("stub") + def +(x: Int): Int /** * Returns the sum of this value and `x`. */ - def +(x: Long): Long = sys.error("stub") + def +(x: Long): Long /** * 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): Int = sys.error("stub") + def -(x: Byte): Int /** * Returns the difference of this value and `x`. */ - def -(x: Short): Int = sys.error("stub") + def -(x: Short): Int /** * Returns the difference of this value and `x`. */ - def -(x: Char): Int = sys.error("stub") + def -(x: Char): Int /** * Returns the difference of this value and `x`. */ - def -(x: Int): Int = sys.error("stub") + def -(x: Int): Int /** * Returns the difference of this value and `x`. */ - def -(x: Long): Long = sys.error("stub") + def -(x: Long): Long /** * 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): Int = sys.error("stub") + def *(x: Byte): Int /** * Returns the product of this value and `x`. */ - def *(x: Short): Int = sys.error("stub") + def *(x: Short): Int /** * Returns the product of this value and `x`. */ - def *(x: Char): Int = sys.error("stub") + def *(x: Char): Int /** * Returns the product of this value and `x`. */ - def *(x: Int): Int = sys.error("stub") + def *(x: Int): Int /** * Returns the product of this value and `x`. */ - def *(x: Long): Long = sys.error("stub") + def *(x: Long): Long /** * 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): Int = sys.error("stub") + def /(x: Byte): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Int = sys.error("stub") + def /(x: Short): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Int = sys.error("stub") + def /(x: Char): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Int = sys.error("stub") + def /(x: Int): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Long = sys.error("stub") + def /(x: Long): Long /** * 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): Int = sys.error("stub") + def %(x: Byte): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Int = sys.error("stub") + def %(x: Short): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Int = sys.error("stub") + def %(x: Char): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Int = sys.error("stub") + def %(x: Int): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Long = sys.error("stub") + def %(x: Long): Long /** * 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[Byte] = sys.error("stub") + override def getClass(): Class[Byte] = null } -object Byte extends AnyValCompanion { +object Byte extends AnyValCompanion { /** The smallest value representable as a Byte. */ final val MinValue = java.lang.Byte.MIN_VALUE @@ -622,6 +624,9 @@ object Byte extends AnyValCompanion { /** The String representation of the scala.Byte companion object. */ override def toString = "object scala.Byte" + + /** Language mandated coercions from Byte to "wider" types. + */ implicit def byte2short(x: Byte): Short = x.toShort implicit def byte2int(x: Byte): Int = x.toInt implicit def byte2long(x: Byte): Long = x.toLong diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index e0ac9a2550..b681ae1693 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Char`, a 16-bit unsigned integer (equivalent to Java's `char` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Char` are not * represented by an object in the underlying runtime system. @@ -17,14 +19,14 @@ package scala * There is an implicit conversion from [[scala.Char]] => [[scala.runtime.RichChar]] * which provides useful non-primitive operations. */ -final class Char 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 Char 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 the bitwise negation of this value. @@ -34,30 +36,30 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def unary_~ : Int = sys.error("stub") + def unary_~ : Int /** * Returns this value, unmodified. */ - def unary_+ : Int = sys.error("stub") + def unary_+ : Int /** * Returns the negation of this value. */ - def unary_- : Int = sys.error("stub") + def unary_- : Int - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Int): Int = sys.error("stub") + def <<(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Long): Int = sys.error("stub") + def <<(x: Long): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -68,7 +70,7 @@ final class Char private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Int): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -79,7 +81,7 @@ final class Char private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Long): Int = sys.error("stub") + def >>>(x: Long): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -90,7 +92,7 @@ final class Char private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Int): Int = sys.error("stub") + def >>(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -101,181 +103,181 @@ final class Char private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Long): Int = sys.error("stub") + def >>(x: Long): Int /** * 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 bitwise OR of this value and `x`. @@ -287,7 +289,7 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def |(x: Byte): Int = sys.error("stub") + def |(x: Byte): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -298,7 +300,7 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def |(x: Short): Int = sys.error("stub") + def |(x: Short): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -309,7 +311,7 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def |(x: Char): Int = sys.error("stub") + def |(x: Char): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -320,7 +322,7 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def |(x: Int): Int = sys.error("stub") + def |(x: Int): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -331,7 +333,7 @@ final class Char private extends AnyVal { * // 11111010 * }}} */ - def |(x: Long): Long = sys.error("stub") + def |(x: Long): Long /** * Returns the bitwise AND of this value and `x`. @@ -343,7 +345,7 @@ final class Char private extends AnyVal { * // 10100000 * }}} */ - def &(x: Byte): Int = sys.error("stub") + def &(x: Byte): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -354,7 +356,7 @@ final class Char private extends AnyVal { * // 10100000 * }}} */ - def &(x: Short): Int = sys.error("stub") + def &(x: Short): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -365,7 +367,7 @@ final class Char private extends AnyVal { * // 10100000 * }}} */ - def &(x: Char): Int = sys.error("stub") + def &(x: Char): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -376,7 +378,7 @@ final class Char private extends AnyVal { * // 10100000 * }}} */ - def &(x: Int): Int = sys.error("stub") + def &(x: Int): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -387,7 +389,7 @@ final class Char private extends AnyVal { * // 10100000 * }}} */ - def &(x: Long): Long = sys.error("stub") + def &(x: Long): Long /** * Returns the bitwise XOR of this value and `x`. @@ -399,7 +401,7 @@ final class Char private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Byte): Int = sys.error("stub") + def ^(x: Byte): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -410,7 +412,7 @@ final class Char private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Short): Int = sys.error("stub") + def ^(x: Short): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -421,7 +423,7 @@ final class Char private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Char): Int = sys.error("stub") + def ^(x: Char): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -432,7 +434,7 @@ final class Char private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Int): Int = sys.error("stub") + def ^(x: Int): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -443,157 +445,157 @@ final class Char private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Long): Long = sys.error("stub") + def ^(x: Long): Long /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Int = sys.error("stub") + def +(x: Byte): Int /** * Returns the sum of this value and `x`. */ - def +(x: Short): Int = sys.error("stub") + def +(x: Short): Int /** * Returns the sum of this value and `x`. */ - def +(x: Char): Int = sys.error("stub") + def +(x: Char): Int /** * Returns the sum of this value and `x`. */ - def +(x: Int): Int = sys.error("stub") + def +(x: Int): Int /** * Returns the sum of this value and `x`. */ - def +(x: Long): Long = sys.error("stub") + def +(x: Long): Long /** * 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): Int = sys.error("stub") + def -(x: Byte): Int /** * Returns the difference of this value and `x`. */ - def -(x: Short): Int = sys.error("stub") + def -(x: Short): Int /** * Returns the difference of this value and `x`. */ - def -(x: Char): Int = sys.error("stub") + def -(x: Char): Int /** * Returns the difference of this value and `x`. */ - def -(x: Int): Int = sys.error("stub") + def -(x: Int): Int /** * Returns the difference of this value and `x`. */ - def -(x: Long): Long = sys.error("stub") + def -(x: Long): Long /** * 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): Int = sys.error("stub") + def *(x: Byte): Int /** * Returns the product of this value and `x`. */ - def *(x: Short): Int = sys.error("stub") + def *(x: Short): Int /** * Returns the product of this value and `x`. */ - def *(x: Char): Int = sys.error("stub") + def *(x: Char): Int /** * Returns the product of this value and `x`. */ - def *(x: Int): Int = sys.error("stub") + def *(x: Int): Int /** * Returns the product of this value and `x`. */ - def *(x: Long): Long = sys.error("stub") + def *(x: Long): Long /** * 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): Int = sys.error("stub") + def /(x: Byte): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Int = sys.error("stub") + def /(x: Short): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Int = sys.error("stub") + def /(x: Char): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Int = sys.error("stub") + def /(x: Int): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Long = sys.error("stub") + def /(x: Long): Long /** * 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): Int = sys.error("stub") + def %(x: Byte): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Int = sys.error("stub") + def %(x: Short): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Int = sys.error("stub") + def %(x: Char): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Int = sys.error("stub") + def %(x: Int): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Long = sys.error("stub") + def %(x: Long): Long /** * 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[Char] = sys.error("stub") + override def getClass(): Class[Char] = null } -object Char extends AnyValCompanion { +object Char extends AnyValCompanion { /** The smallest value representable as a Char. */ final val MinValue = java.lang.Character.MIN_VALUE @@ -622,6 +624,9 @@ object Char extends AnyValCompanion { /** The String representation of the scala.Char companion object. */ override def toString = "object scala.Char" + + /** Language mandated coercions from Char to "wider" types. + */ implicit def char2int(x: Char): Int = x.toInt implicit def char2long(x: Char): Long = x.toLong implicit def char2float(x: Char): Float = x.toFloat diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index bb659b963a..2ff46c433d 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Double` are not * represented by an object in the underlying runtime system. @@ -17,349 +19,349 @@ package scala * There is an implicit conversion from [[scala.Double]] => [[scala.runtime.RichDouble]] * which provides useful non-primitive operations. */ -final class Double 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 Double 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_+ : Double = sys.error("stub") + def unary_+ : Double /** * Returns the negation of this value. */ - def unary_- : Double = sys.error("stub") + def unary_- : Double - 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): Double = sys.error("stub") + def +(x: Byte): Double /** * Returns the sum of this value and `x`. */ - def +(x: Short): Double = sys.error("stub") + def +(x: Short): Double /** * Returns the sum of this value and `x`. */ - def +(x: Char): Double = sys.error("stub") + def +(x: Char): Double /** * Returns the sum of this value and `x`. */ - def +(x: Int): Double = sys.error("stub") + def +(x: Int): Double /** * Returns the sum of this value and `x`. */ - def +(x: Long): Double = sys.error("stub") + def +(x: Long): Double /** * Returns the sum of this value and `x`. */ - def +(x: Float): Double = sys.error("stub") + def +(x: Float): Double /** * 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): Double = sys.error("stub") + def -(x: Byte): Double /** * Returns the difference of this value and `x`. */ - def -(x: Short): Double = sys.error("stub") + def -(x: Short): Double /** * Returns the difference of this value and `x`. */ - def -(x: Char): Double = sys.error("stub") + def -(x: Char): Double /** * Returns the difference of this value and `x`. */ - def -(x: Int): Double = sys.error("stub") + def -(x: Int): Double /** * Returns the difference of this value and `x`. */ - def -(x: Long): Double = sys.error("stub") + def -(x: Long): Double /** * Returns the difference of this value and `x`. */ - def -(x: Float): Double = sys.error("stub") + def -(x: Float): Double /** * 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): Double = sys.error("stub") + def *(x: Byte): Double /** * Returns the product of this value and `x`. */ - def *(x: Short): Double = sys.error("stub") + def *(x: Short): Double /** * Returns the product of this value and `x`. */ - def *(x: Char): Double = sys.error("stub") + def *(x: Char): Double /** * Returns the product of this value and `x`. */ - def *(x: Int): Double = sys.error("stub") + def *(x: Int): Double /** * Returns the product of this value and `x`. */ - def *(x: Long): Double = sys.error("stub") + def *(x: Long): Double /** * Returns the product of this value and `x`. */ - def *(x: Float): Double = sys.error("stub") + def *(x: Float): Double /** * 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): Double = sys.error("stub") + def /(x: Byte): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Double = sys.error("stub") + def /(x: Short): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Double = sys.error("stub") + def /(x: Char): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Double = sys.error("stub") + def /(x: Int): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Double = sys.error("stub") + def /(x: Long): Double /** * Returns the quotient of this value and `x`. */ - def /(x: Float): Double = sys.error("stub") + def /(x: Float): Double /** * 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): Double = sys.error("stub") + def %(x: Byte): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Double = sys.error("stub") + def %(x: Short): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Double = sys.error("stub") + def %(x: Char): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Double = sys.error("stub") + def %(x: Int): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Double = sys.error("stub") + def %(x: Long): Double /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Float): Double = sys.error("stub") + def %(x: Float): Double /** * 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[Double] = sys.error("stub") + override def getClass(): Class[Double] = null } -object Double extends AnyValCompanion { +object Double extends AnyValCompanion { /** The smallest positive value greater than 0.0d which is * representable as a Double. */ 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 } diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index d5d7ef011d..b2a4f93253 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Int`, a 32-bit signed integer (equivalent to Java's `int` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Int` are not * represented by an object in the underlying runtime system. @@ -17,14 +19,14 @@ package scala * There is an implicit conversion from [[scala.Int]] => [[scala.runtime.RichInt]] * which provides useful non-primitive operations. */ -final class Int 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 Int 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 the bitwise negation of this value. @@ -34,30 +36,30 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def unary_~ : Int = sys.error("stub") + def unary_~ : Int /** * Returns this value, unmodified. */ - def unary_+ : Int = sys.error("stub") + def unary_+ : Int /** * Returns the negation of this value. */ - def unary_- : Int = sys.error("stub") + def unary_- : Int - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Int): Int = sys.error("stub") + def <<(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Long): Int = sys.error("stub") + def <<(x: Long): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -68,7 +70,7 @@ final class Int private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Int): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -79,7 +81,7 @@ final class Int private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Long): Int = sys.error("stub") + def >>>(x: Long): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -90,7 +92,7 @@ final class Int private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Int): Int = sys.error("stub") + def >>(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -101,181 +103,181 @@ final class Int private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Long): Int = sys.error("stub") + def >>(x: Long): Int /** * 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 bitwise OR of this value and `x`. @@ -287,7 +289,7 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def |(x: Byte): Int = sys.error("stub") + def |(x: Byte): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -298,7 +300,7 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def |(x: Short): Int = sys.error("stub") + def |(x: Short): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -309,7 +311,7 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def |(x: Char): Int = sys.error("stub") + def |(x: Char): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -320,7 +322,7 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def |(x: Int): Int = sys.error("stub") + def |(x: Int): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -331,7 +333,7 @@ final class Int private extends AnyVal { * // 11111010 * }}} */ - def |(x: Long): Long = sys.error("stub") + def |(x: Long): Long /** * Returns the bitwise AND of this value and `x`. @@ -343,7 +345,7 @@ final class Int private extends AnyVal { * // 10100000 * }}} */ - def &(x: Byte): Int = sys.error("stub") + def &(x: Byte): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -354,7 +356,7 @@ final class Int private extends AnyVal { * // 10100000 * }}} */ - def &(x: Short): Int = sys.error("stub") + def &(x: Short): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -365,7 +367,7 @@ final class Int private extends AnyVal { * // 10100000 * }}} */ - def &(x: Char): Int = sys.error("stub") + def &(x: Char): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -376,7 +378,7 @@ final class Int private extends AnyVal { * // 10100000 * }}} */ - def &(x: Int): Int = sys.error("stub") + def &(x: Int): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -387,7 +389,7 @@ final class Int private extends AnyVal { * // 10100000 * }}} */ - def &(x: Long): Long = sys.error("stub") + def &(x: Long): Long /** * Returns the bitwise XOR of this value and `x`. @@ -399,7 +401,7 @@ final class Int private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Byte): Int = sys.error("stub") + def ^(x: Byte): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -410,7 +412,7 @@ final class Int private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Short): Int = sys.error("stub") + def ^(x: Short): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -421,7 +423,7 @@ final class Int private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Char): Int = sys.error("stub") + def ^(x: Char): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -432,7 +434,7 @@ final class Int private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Int): Int = sys.error("stub") + def ^(x: Int): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -443,157 +445,157 @@ final class Int private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Long): Long = sys.error("stub") + def ^(x: Long): Long /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Int = sys.error("stub") + def +(x: Byte): Int /** * Returns the sum of this value and `x`. */ - def +(x: Short): Int = sys.error("stub") + def +(x: Short): Int /** * Returns the sum of this value and `x`. */ - def +(x: Char): Int = sys.error("stub") + def +(x: Char): Int /** * Returns the sum of this value and `x`. */ - def +(x: Int): Int = sys.error("stub") + def +(x: Int): Int /** * Returns the sum of this value and `x`. */ - def +(x: Long): Long = sys.error("stub") + def +(x: Long): Long /** * 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): Int = sys.error("stub") + def -(x: Byte): Int /** * Returns the difference of this value and `x`. */ - def -(x: Short): Int = sys.error("stub") + def -(x: Short): Int /** * Returns the difference of this value and `x`. */ - def -(x: Char): Int = sys.error("stub") + def -(x: Char): Int /** * Returns the difference of this value and `x`. */ - def -(x: Int): Int = sys.error("stub") + def -(x: Int): Int /** * Returns the difference of this value and `x`. */ - def -(x: Long): Long = sys.error("stub") + def -(x: Long): Long /** * 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): Int = sys.error("stub") + def *(x: Byte): Int /** * Returns the product of this value and `x`. */ - def *(x: Short): Int = sys.error("stub") + def *(x: Short): Int /** * Returns the product of this value and `x`. */ - def *(x: Char): Int = sys.error("stub") + def *(x: Char): Int /** * Returns the product of this value and `x`. */ - def *(x: Int): Int = sys.error("stub") + def *(x: Int): Int /** * Returns the product of this value and `x`. */ - def *(x: Long): Long = sys.error("stub") + def *(x: Long): Long /** * 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): Int = sys.error("stub") + def /(x: Byte): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Int = sys.error("stub") + def /(x: Short): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Int = sys.error("stub") + def /(x: Char): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Int = sys.error("stub") + def /(x: Int): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Long = sys.error("stub") + def /(x: Long): Long /** * 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): Int = sys.error("stub") + def %(x: Byte): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Int = sys.error("stub") + def %(x: Short): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Int = sys.error("stub") + def %(x: Char): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Int = sys.error("stub") + def %(x: Int): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Long = sys.error("stub") + def %(x: Long): Long /** * 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[Int] = sys.error("stub") + override def getClass(): Class[Int] = null } -object Int extends AnyValCompanion { +object Int extends AnyValCompanion { /** The smallest value representable as a Int. */ final val MinValue = java.lang.Integer.MIN_VALUE @@ -622,6 +624,9 @@ object Int extends AnyValCompanion { /** The String representation of the scala.Int companion object. */ override def toString = "object scala.Int" + + /** Language mandated coercions from Int to "wider" types. + */ implicit def int2long(x: Int): Long = x.toLong implicit def int2float(x: Int): Float = x.toFloat implicit def int2double(x: Int): Double = x.toDouble diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 85131b4f54..40932a65a7 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Long`, a 64-bit signed integer (equivalent to Java's `long` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Long` are not * represented by an object in the underlying runtime system. @@ -17,14 +19,14 @@ package scala * There is an implicit conversion from [[scala.Long]] => [[scala.runtime.RichLong]] * which provides useful non-primitive operations. */ -final class Long 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 Long 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 the bitwise negation of this value. @@ -34,30 +36,30 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def unary_~ : Long = sys.error("stub") + def unary_~ : Long /** * Returns this value, unmodified. */ - def unary_+ : Long = sys.error("stub") + def unary_+ : Long /** * Returns the negation of this value. */ - def unary_- : Long = sys.error("stub") + def unary_- : Long - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Int): Long = sys.error("stub") + def <<(x: Int): Long /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Long): Long = sys.error("stub") + def <<(x: Long): Long /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -68,7 +70,7 @@ final class Long private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Int): Long = sys.error("stub") + def >>>(x: Int): Long /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -79,7 +81,7 @@ final class Long private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Long): Long = sys.error("stub") + def >>>(x: Long): Long /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -90,7 +92,7 @@ final class Long private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Int): Long = sys.error("stub") + def >>(x: Int): Long /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -101,181 +103,181 @@ final class Long private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Long): Long = sys.error("stub") + def >>(x: Long): Long /** * 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 bitwise OR of this value and `x`. @@ -287,7 +289,7 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def |(x: Byte): Long = sys.error("stub") + def |(x: Byte): Long /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -298,7 +300,7 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def |(x: Short): Long = sys.error("stub") + def |(x: Short): Long /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -309,7 +311,7 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def |(x: Char): Long = sys.error("stub") + def |(x: Char): Long /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -320,7 +322,7 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def |(x: Int): Long = sys.error("stub") + def |(x: Int): Long /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -331,7 +333,7 @@ final class Long private extends AnyVal { * // 11111010 * }}} */ - def |(x: Long): Long = sys.error("stub") + def |(x: Long): Long /** * Returns the bitwise AND of this value and `x`. @@ -343,7 +345,7 @@ final class Long private extends AnyVal { * // 10100000 * }}} */ - def &(x: Byte): Long = sys.error("stub") + def &(x: Byte): Long /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -354,7 +356,7 @@ final class Long private extends AnyVal { * // 10100000 * }}} */ - def &(x: Short): Long = sys.error("stub") + def &(x: Short): Long /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -365,7 +367,7 @@ final class Long private extends AnyVal { * // 10100000 * }}} */ - def &(x: Char): Long = sys.error("stub") + def &(x: Char): Long /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -376,7 +378,7 @@ final class Long private extends AnyVal { * // 10100000 * }}} */ - def &(x: Int): Long = sys.error("stub") + def &(x: Int): Long /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -387,7 +389,7 @@ final class Long private extends AnyVal { * // 10100000 * }}} */ - def &(x: Long): Long = sys.error("stub") + def &(x: Long): Long /** * Returns the bitwise XOR of this value and `x`. @@ -399,7 +401,7 @@ final class Long private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Byte): Long = sys.error("stub") + def ^(x: Byte): Long /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -410,7 +412,7 @@ final class Long private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Short): Long = sys.error("stub") + def ^(x: Short): Long /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -421,7 +423,7 @@ final class Long private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Char): Long = sys.error("stub") + def ^(x: Char): Long /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -432,7 +434,7 @@ final class Long private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Int): Long = sys.error("stub") + def ^(x: Int): Long /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -443,157 +445,157 @@ final class Long private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Long): Long = sys.error("stub") + def ^(x: Long): Long /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Long = sys.error("stub") + def +(x: Byte): Long /** * Returns the sum of this value and `x`. */ - def +(x: Short): Long = sys.error("stub") + def +(x: Short): Long /** * Returns the sum of this value and `x`. */ - def +(x: Char): Long = sys.error("stub") + def +(x: Char): Long /** * Returns the sum of this value and `x`. */ - def +(x: Int): Long = sys.error("stub") + def +(x: Int): Long /** * Returns the sum of this value and `x`. */ - def +(x: Long): Long = sys.error("stub") + def +(x: Long): Long /** * 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): Long = sys.error("stub") + def -(x: Byte): Long /** * Returns the difference of this value and `x`. */ - def -(x: Short): Long = sys.error("stub") + def -(x: Short): Long /** * Returns the difference of this value and `x`. */ - def -(x: Char): Long = sys.error("stub") + def -(x: Char): Long /** * Returns the difference of this value and `x`. */ - def -(x: Int): Long = sys.error("stub") + def -(x: Int): Long /** * Returns the difference of this value and `x`. */ - def -(x: Long): Long = sys.error("stub") + def -(x: Long): Long /** * 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): Long = sys.error("stub") + def *(x: Byte): Long /** * Returns the product of this value and `x`. */ - def *(x: Short): Long = sys.error("stub") + def *(x: Short): Long /** * Returns the product of this value and `x`. */ - def *(x: Char): Long = sys.error("stub") + def *(x: Char): Long /** * Returns the product of this value and `x`. */ - def *(x: Int): Long = sys.error("stub") + def *(x: Int): Long /** * Returns the product of this value and `x`. */ - def *(x: Long): Long = sys.error("stub") + def *(x: Long): Long /** * 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): Long = sys.error("stub") + def /(x: Byte): Long /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Long = sys.error("stub") + def /(x: Short): Long /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Long = sys.error("stub") + def /(x: Char): Long /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Long = sys.error("stub") + def /(x: Int): Long /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Long = sys.error("stub") + def /(x: Long): Long /** * 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): Long = sys.error("stub") + def %(x: Byte): Long /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Long = sys.error("stub") + def %(x: Short): Long /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Long = sys.error("stub") + def %(x: Char): Long /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Long = sys.error("stub") + def %(x: Int): Long /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Long = sys.error("stub") + def %(x: Long): Long /** * 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[Long] = sys.error("stub") + override def getClass(): Class[Long] = null } -object Long extends AnyValCompanion { +object Long extends AnyValCompanion { /** The smallest value representable as a Long. */ final val MinValue = java.lang.Long.MIN_VALUE @@ -622,6 +624,9 @@ object Long extends AnyValCompanion { /** The String representation of the scala.Long companion object. */ override def toString = "object scala.Long" + + /** Language mandated coercions from Long to "wider" types. + */ implicit def long2float(x: Long): Float = x.toFloat implicit def long2double(x: Long): Double = x.toDouble } diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 1060a9db16..687b198a11 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** `Short`, a 16-bit signed integer (equivalent to Java's `short` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Short` are not * represented by an object in the underlying runtime system. @@ -17,14 +19,14 @@ package scala * There is an implicit conversion from [[scala.Short]] => [[scala.runtime.RichShort]] * which provides useful non-primitive operations. */ -final class Short 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 Short 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 the bitwise negation of this value. @@ -34,30 +36,30 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def unary_~ : Int = sys.error("stub") + def unary_~ : Int /** * Returns this value, unmodified. */ - def unary_+ : Int = sys.error("stub") + def unary_+ : Int /** * Returns the negation of this value. */ - def unary_- : Int = sys.error("stub") + def unary_- : Int - def +(x: String): String = sys.error("stub") + def +(x: String): String /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Int): Int = sys.error("stub") + def <<(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ - def <<(x: Long): Int = sys.error("stub") + def <<(x: Long): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -68,7 +70,7 @@ final class Short private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Int): Int /** * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. @@ -79,7 +81,7 @@ final class Short private extends AnyVal { * // 00011111 11111111 11111111 11111101 * }}} */ - def >>>(x: Long): Int = sys.error("stub") + def >>>(x: Long): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -90,7 +92,7 @@ final class Short private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Int): Int = sys.error("stub") + def >>(x: Int): Int /** * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. @@ -101,181 +103,181 @@ final class Short private extends AnyVal { * // 11111111 11111111 11111111 11111101 * }}} */ - def >>(x: Long): Int = sys.error("stub") + def >>(x: Long): Int /** * 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 bitwise OR of this value and `x`. @@ -287,7 +289,7 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def |(x: Byte): Int = sys.error("stub") + def |(x: Byte): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -298,7 +300,7 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def |(x: Short): Int = sys.error("stub") + def |(x: Short): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -309,7 +311,7 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def |(x: Char): Int = sys.error("stub") + def |(x: Char): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -320,7 +322,7 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def |(x: Int): Int = sys.error("stub") + def |(x: Int): Int /** * Returns the bitwise OR of this value and `x`. * @example {{{ @@ -331,7 +333,7 @@ final class Short private extends AnyVal { * // 11111010 * }}} */ - def |(x: Long): Long = sys.error("stub") + def |(x: Long): Long /** * Returns the bitwise AND of this value and `x`. @@ -343,7 +345,7 @@ final class Short private extends AnyVal { * // 10100000 * }}} */ - def &(x: Byte): Int = sys.error("stub") + def &(x: Byte): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -354,7 +356,7 @@ final class Short private extends AnyVal { * // 10100000 * }}} */ - def &(x: Short): Int = sys.error("stub") + def &(x: Short): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -365,7 +367,7 @@ final class Short private extends AnyVal { * // 10100000 * }}} */ - def &(x: Char): Int = sys.error("stub") + def &(x: Char): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -376,7 +378,7 @@ final class Short private extends AnyVal { * // 10100000 * }}} */ - def &(x: Int): Int = sys.error("stub") + def &(x: Int): Int /** * Returns the bitwise AND of this value and `x`. * @example {{{ @@ -387,7 +389,7 @@ final class Short private extends AnyVal { * // 10100000 * }}} */ - def &(x: Long): Long = sys.error("stub") + def &(x: Long): Long /** * Returns the bitwise XOR of this value and `x`. @@ -399,7 +401,7 @@ final class Short private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Byte): Int = sys.error("stub") + def ^(x: Byte): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -410,7 +412,7 @@ final class Short private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Short): Int = sys.error("stub") + def ^(x: Short): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -421,7 +423,7 @@ final class Short private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Char): Int = sys.error("stub") + def ^(x: Char): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -432,7 +434,7 @@ final class Short private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Int): Int = sys.error("stub") + def ^(x: Int): Int /** * Returns the bitwise XOR of this value and `x`. * @example {{{ @@ -443,157 +445,157 @@ final class Short private extends AnyVal { * // 01011010 * }}} */ - def ^(x: Long): Long = sys.error("stub") + def ^(x: Long): Long /** * Returns the sum of this value and `x`. */ - def +(x: Byte): Int = sys.error("stub") + def +(x: Byte): Int /** * Returns the sum of this value and `x`. */ - def +(x: Short): Int = sys.error("stub") + def +(x: Short): Int /** * Returns the sum of this value and `x`. */ - def +(x: Char): Int = sys.error("stub") + def +(x: Char): Int /** * Returns the sum of this value and `x`. */ - def +(x: Int): Int = sys.error("stub") + def +(x: Int): Int /** * Returns the sum of this value and `x`. */ - def +(x: Long): Long = sys.error("stub") + def +(x: Long): Long /** * 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): Int = sys.error("stub") + def -(x: Byte): Int /** * Returns the difference of this value and `x`. */ - def -(x: Short): Int = sys.error("stub") + def -(x: Short): Int /** * Returns the difference of this value and `x`. */ - def -(x: Char): Int = sys.error("stub") + def -(x: Char): Int /** * Returns the difference of this value and `x`. */ - def -(x: Int): Int = sys.error("stub") + def -(x: Int): Int /** * Returns the difference of this value and `x`. */ - def -(x: Long): Long = sys.error("stub") + def -(x: Long): Long /** * 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): Int = sys.error("stub") + def *(x: Byte): Int /** * Returns the product of this value and `x`. */ - def *(x: Short): Int = sys.error("stub") + def *(x: Short): Int /** * Returns the product of this value and `x`. */ - def *(x: Char): Int = sys.error("stub") + def *(x: Char): Int /** * Returns the product of this value and `x`. */ - def *(x: Int): Int = sys.error("stub") + def *(x: Int): Int /** * Returns the product of this value and `x`. */ - def *(x: Long): Long = sys.error("stub") + def *(x: Long): Long /** * 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): Int = sys.error("stub") + def /(x: Byte): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Short): Int = sys.error("stub") + def /(x: Short): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Char): Int = sys.error("stub") + def /(x: Char): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Int): Int = sys.error("stub") + def /(x: Int): Int /** * Returns the quotient of this value and `x`. */ - def /(x: Long): Long = sys.error("stub") + def /(x: Long): Long /** * 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): Int = sys.error("stub") + def %(x: Byte): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Short): Int = sys.error("stub") + def %(x: Short): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Char): Int = sys.error("stub") + def %(x: Char): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Int): Int = sys.error("stub") + def %(x: Int): Int /** * Returns the remainder of the division of this value by `x`. */ - def %(x: Long): Long = sys.error("stub") + def %(x: Long): Long /** * 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[Short] = sys.error("stub") + override def getClass(): Class[Short] = null } -object Short extends AnyValCompanion { +object Short extends AnyValCompanion { /** The smallest value representable as a Short. */ final val MinValue = java.lang.Short.MIN_VALUE @@ -622,6 +624,9 @@ object Short extends AnyValCompanion { /** The String representation of the scala.Short companion object. */ override def toString = "object scala.Short" + + /** Language mandated coercions from Short to "wider" types. + */ implicit def short2int(x: Short): Int = x.toInt implicit def short2long(x: Short): Long = x.toLong implicit def short2float(x: Short): Float = x.toFloat diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 3da5c083d4..4156071f29 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -10,17 +10,19 @@ package scala +import language.implicitConversions + /** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type * `Unit`, `()`, and it is not represented by any object in the underlying * runtime system. A method with return type `Unit` is analogous to a Java * method which is declared `void`. */ -final class Unit private extends AnyVal { - override def getClass(): Class[Unit] = sys.error("stub") +final abstract class Unit private extends AnyVal { + override def getClass(): Class[Unit] = null } -object Unit extends AnyValCompanion { +object Unit extends AnyValCompanion { /** Transform a value type into a boxed reference type. * -- cgit v1.2.3