The AnyVal types become source files instead of polite

compiler fictions.

!! You'll need a serious "ant all.clean" now. !!

As of this commit the system is fully bootstrapped and the
synthetic code eliminated: only the source files remain.
The sort-of-AnyVal-companions in scala.runtime.* have all
been eliminated because the actual companions can do everything;
deprecated vals in the scala.runtime package object point to
the companions.  This left AnyValCompanion as the only AnyVal
related thing in the runtime package: that made little sense,
so I deprecated and moved it as well.

Starr is based on r24066 plus this commit.  Closes #4121.
Review by rytz, odersky.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@24068 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-01-24 06:18:01 +00:00
parent ebe3e42684
commit 0d7d9bc5f4
32 changed files with 1414 additions and 380 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,7 +22,6 @@ trait AnyValTemplates {
package scala package scala
import scala.runtime.AnyValCompanion
import java.{ lang => jl } import java.{ lang => jl }
""".trim.format(now) + "\n\n" """.trim.format(now) + "\n\n"

View File

@ -283,6 +283,16 @@ self =>
/** Are we inside the Scala package? Set for files that start with package scala /** Are we inside the Scala package? Set for files that start with package scala
*/ */
private var inScalaPackage = false private var inScalaPackage = false
private var currentPackage = ""
def resetPackage() {
inScalaPackage = false
currentPackage = ""
}
private lazy val anyValNames: Set[Name] = tpnme.ScalaValueNames.toSet + tpnme.AnyVal
private def inScalaRootPackage = inScalaPackage && currentPackage == "scala"
private def isScalaArray(name: Name) = inScalaRootPackage && name == tpnme.Array
private def isAnyValType(name: Name) = inScalaRootPackage && anyValNames(name)
def parseStartRule: () => Tree def parseStartRule: () => Tree
@ -600,7 +610,6 @@ self =>
def isUnaryOp = isIdent && raw.isUnary(in.name) def isUnaryOp = isIdent && raw.isUnary(in.name)
def isRawStar = isIdent && in.name == raw.STAR def isRawStar = isIdent && in.name == raw.STAR
def isRawBar = isIdent && in.name == raw.BAR def isRawBar = isIdent && in.name == raw.BAR
def isScalaArray(name: Name) = inScalaPackage && name == tpnme.Array
def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
@ -1049,6 +1058,20 @@ self =>
if (in.token == DOT) { selectors(id, false, in.skipToken()) } if (in.token == DOT) { selectors(id, false, in.skipToken()) }
else id else id
} }
/** Calls qualId() and manages some package state.
*/
private def pkgQualId() = {
if (in.token == IDENTIFIER && in.name.encode == nme.scala_)
inScalaPackage = true
val pkg = qualId()
newLineOptWhenFollowedBy(LBRACE)
if (currentPackage == "") currentPackage = pkg.toString
else currentPackage = currentPackage + "." + pkg
pkg
}
/** SimpleExpr ::= literal /** SimpleExpr ::= literal
* | symbol * | symbol
@ -2515,27 +2538,36 @@ self =>
* TraitExtends ::= 'extends' | `<:' * TraitExtends ::= 'extends' | `<:'
*/ */
def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]], tstart: Int): Template = { def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]], tstart: Int): Template = {
val (parents0, argss, self, body) = val (parents0, argss, self, body) = (
if (in.token == EXTENDS || settings.YvirtClasses && mods.hasTraitFlag && in.token == SUBTYPE) { if (in.token == EXTENDS || in.token == SUBTYPE && mods.hasTraitFlag) {
in.nextToken() in.nextToken()
template(mods.hasTraitFlag) template(mods.hasTraitFlag)
} else if ((in.token == SUBTYPE) && mods.hasTraitFlag) { }
in.nextToken() else {
template(true)
} else {
newLineOptWhenFollowedBy(LBRACE) newLineOptWhenFollowedBy(LBRACE)
val (self, body) = templateBodyOpt(false) val (self, body) = templateBodyOpt(false)
(List(), List(List()), self, body) (List(), List(List()), self, body)
} }
var parents = parents0 )
if (!isInterface(mods, body) && !isScalaArray(name))
parents = parents :+ scalaScalaObjectConstr
if (parents.isEmpty)
parents = List(scalaAnyRefConstr)
if (mods.isCase) parents ++= List(productConstr, serializableConstr)
val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart
atPos(tstart0) { atPos(tstart0) {
Template(parents, self, constrMods, vparamss, argss, body, o2p(tstart)) if (isAnyValType(name)) {
val parent = if (name == tpnme.AnyVal) tpnme.Any else tpnme.AnyVal
Template(List(scalaDot(parent)), self, body)
}
else {
val parents = (
if (!isInterface(mods, body) && !isScalaArray(name)) parents0 :+ scalaScalaObjectConstr
else if (parents0.isEmpty) List(scalaAnyRefConstr)
else parents0
) ++ (
if (mods.isCase) List(productConstr, serializableConstr)
else Nil
)
Template(parents, self, constrMods, vparamss, argss, body, o2p(tstart))
}
} }
} }
@ -2596,8 +2628,7 @@ self =>
/** Packaging ::= package QualId [nl] `{' TopStatSeq `}' /** Packaging ::= package QualId [nl] `{' TopStatSeq `}'
*/ */
def packaging(start: Int): Tree = { def packaging(start: Int): Tree = {
val pkg = qualId() val pkg = pkgQualId()
newLineOptWhenFollowedBy(LBRACE)
val stats = inBracesOrNil(topStatSeq()) val stats = inBracesOrNil(topStatSeq())
makePackaging(start, pkg, stats) makePackaging(start, pkg, stats)
} }
@ -2790,10 +2821,7 @@ self =>
} }
} else { } else {
in.flushDoc in.flushDoc
if (in.token == IDENTIFIER && in.name.encode == nme.scala_) val pkg = pkgQualId()
inScalaPackage = true
val pkg = qualId()
newLineOptWhenFollowedBy(LBRACE)
if (in.token == EOF) { if (in.token == EOF) {
ts += makePackaging(start, pkg, List()) ts += makePackaging(start, pkg, List())
} else if (isStatSep) { } else if (isStatSep) {
@ -2810,6 +2838,8 @@ self =>
} }
ts.toList ts.toList
} }
resetPackage()
topstats() match { topstats() match {
case List(stat @ PackageDef(_, _)) => stat case List(stat @ PackageDef(_, _)) => stat
case stats => case stats =>

View File

@ -29,7 +29,7 @@ abstract class GenICode extends SubComponent {
ArrayClass, ObjectClass, ThrowableClass, StringClass, StringModule, NothingClass, NullClass, AnyRefClass, ArrayClass, ObjectClass, ThrowableClass, StringClass, StringModule, NothingClass, NullClass, AnyRefClass,
Object_equals, Object_isInstanceOf, Object_asInstanceOf, ScalaRunTimeModule, Object_equals, Object_isInstanceOf, Object_asInstanceOf, ScalaRunTimeModule,
BoxedNumberClass, BoxedCharacterClass, BoxedNumberClass, BoxedCharacterClass,
getMember, runtimeCompanions getMember
} }
import scalaPrimitives.{ import scalaPrimitives.{
isArrayOp, isComparisonOp, isLogicalOp, isArrayOp, isComparisonOp, isLogicalOp,
@ -1221,7 +1221,7 @@ abstract class GenICode extends SubComponent {
} }
private def genLoadModule(ctx: Context, sym: Symbol, pos: Position) { private def genLoadModule(ctx: Context, sym: Symbol, pos: Position) {
ctx.bb.emit(LOAD_MODULE(runtimeCompanions.getOrElse(sym, sym)), pos) ctx.bb.emit(LOAD_MODULE(sym), pos)
} }
def genConversion(from: TypeKind, to: TypeKind, ctx: Context, cast: Boolean) = { def genConversion(from: TypeKind, to: TypeKind, ctx: Context, cast: Boolean) = {

View File

@ -42,10 +42,6 @@ trait GenJVMUtil {
NullClass -> RuntimeNullClass.fullName('/'), NullClass -> RuntimeNullClass.fullName('/'),
RuntimeNullClass -> RuntimeNullClass.fullName('/') RuntimeNullClass -> RuntimeNullClass.fullName('/')
) )
primitiveCompanions foreach { sym =>
map(sym) = "scala/runtime/" + sym.name + "$"
}
map map
} }

View File

@ -125,7 +125,8 @@ trait Matrix extends MatrixAdditions {
private val _syntheticSyms = mutable.HashSet[Symbol]() private val _syntheticSyms = mutable.HashSet[Symbol]()
def clearSyntheticSyms() = { def clearSyntheticSyms() = {
_syntheticSyms foreach (_ resetFlag (NO_EXHAUSTIVE|MUTABLE)) _syntheticSyms foreach (_ resetFlag (NO_EXHAUSTIVE|MUTABLE))
log("Cleared NO_EXHAUSTIVE/MUTABLE on " + _syntheticSyms.size + " synthetic symbols.") if (settings.debug.value)
log("Cleared NO_EXHAUSTIVE/MUTABLE on " + _syntheticSyms.size + " synthetic symbols.")
_syntheticSyms.clear() _syntheticSyms.clear()
} }
def recordSyntheticSym(sym: Symbol): Symbol = { def recordSyntheticSym(sym: Symbol): Symbol = {

View File

@ -15,8 +15,108 @@ import classfile.ClassfileConstants
trait Definitions extends reflect.generic.StandardDefinitions { trait Definitions extends reflect.generic.StandardDefinitions {
self: SymbolTable => self: SymbolTable =>
// the scala value classes
trait ValueClassDefinitions {
self: definitions.type =>
private[Definitions] def valueCache(name: Name) = {
if (name.isTypeName) ScalaPackageClass.info member name
else ScalaPackageClass.info member name suchThat (_ hasFlag MODULE)
}
private[Definitions] def valueModuleMethod(className: Name, methodName: Name): Symbol = {
valueCache(className.toTermName).moduleClass.tpe member methodName
}
object definitions extends AbsDefinitions { import ClassfileConstants._
private val nameToWeight = Map[Name, Int](
tpnme.Byte -> 2,
tpnme.Char -> 3,
tpnme.Short -> 4,
tpnme.Int -> 12,
tpnme.Long -> 24,
tpnme.Float -> 48,
tpnme.Double -> 96
)
private val nameToTag = Map[Name, Char](
tpnme.Byte -> BYTE_TAG,
tpnme.Char -> CHAR_TAG,
tpnme.Short -> SHORT_TAG,
tpnme.Int -> INT_TAG,
tpnme.Long -> LONG_TAG,
tpnme.Float -> FLOAT_TAG,
tpnme.Double -> DOUBLE_TAG,
tpnme.Boolean -> BOOL_TAG,
tpnme.Unit -> VOID_TAG
)
private def classesMap[T](f: Name => T) = symbolsMap(ScalaValueClassesNoUnit, f)
private def symbolsMap[T](syms: List[Symbol], f: Name => T): Map[Symbol, T] = syms zip (syms map (x => f(x.name))) toMap
private def symbolsMapFilt[T](syms: List[Symbol], p: Name => Boolean, f: Name => T) = symbolsMap(syms filter (x => p(x.name)), f)
private def boxedName(name: Name) = sn.Boxed(name.toTypeName)
lazy val abbrvTag = symbolsMap(ScalaValueClasses, nameToTag)
lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight)
lazy val boxedModule = classesMap(x => getModule(boxedName(x)))
lazy val boxedClass = classesMap(x => getClass(boxedName(x)))
lazy val refClass = classesMap(x => getClass("scala.runtime." + x + "Ref"))
lazy val volatileRefClass = classesMap(x => getClass("scala.runtime.Volatile" + x + "Ref"))
lazy val boxMethod = classesMap(x => valueModuleMethod(x, nme.box))
lazy val unboxMethod = classesMap(x => valueModuleMethod(x, nme.unbox))
private def newClass(owner: Symbol, name: TypeName, parents: List[Type]): Symbol = {
val clazz = owner.newClass(NoPosition, name)
clazz.setInfo(ClassInfoType(parents, new Scope, clazz))
owner.info.decls.enter(clazz)
clazz
}
def isNumericSubClass(sub: Symbol, sup: Symbol) = {
val cmp = for (w1 <- numericWeight get sub ; w2 <- numericWeight get sup) yield w2 % w1
cmp exists (_ == 0)
}
/** Is symbol a numeric value class? */
def isNumericValueClass(sym: Symbol): Boolean =
numericWeight contains sym
private[Definitions] def fullNameStrings: List[String] = nme.ScalaValueNames map ("scala." + _)
private[Definitions] lazy val fullValueName: Set[Name] = {
val values = nme.ScalaValueNames flatMap (x => List(newTypeName("scala." + x), newTermName("scala." + x)))
values.toSet + newTypeName("scala.AnyVal")
}
lazy val AnyValClass = valueCache(tpnme.AnyVal)
lazy val UnitClass = valueCache(tpnme.Unit)
lazy val ByteClass = valueCache(tpnme.Byte)
lazy val ShortClass = valueCache(tpnme.Short)
lazy val CharClass = valueCache(tpnme.Char)
lazy val IntClass = valueCache(tpnme.Int)
lazy val LongClass = valueCache(tpnme.Long)
lazy val FloatClass = valueCache(tpnme.Float)
lazy val DoubleClass = valueCache(tpnme.Double)
lazy val BooleanClass = valueCache(tpnme.Boolean)
def Boolean_and = getMember(BooleanClass, nme.ZAND)
def Boolean_or = getMember(BooleanClass, nme.ZOR)
def ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass)
def ScalaValueClasses: List[Symbol] = List(
UnitClass,
BooleanClass,
ByteClass,
ShortClass,
CharClass,
IntClass,
LongClass,
FloatClass,
DoubleClass
)
}
object definitions extends AbsDefinitions with ValueClassDefinitions {
private var isInitialized = false private var isInitialized = false
def isDefinitionsInitialized = isInitialized def isDefinitionsInitialized = isInitialized
@ -53,63 +153,35 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val anyrefparam = List(AnyRefClass.typeConstructor) lazy val anyrefparam = List(AnyRefClass.typeConstructor)
// private parameter conveniences // private parameter conveniences
private def booltype = BooleanClass.typeConstructor private def booltype = BooleanClass.typeConstructor
private def boolparam = List(booltype) private def boolparam = List(booltype)
private def bytetype = ByteClass.typeConstructor private def bytetype = ByteClass.typeConstructor
private def byteparam = List(bytetype) private def byteparam = List(bytetype)
private def shorttype = ShortClass.typeConstructor private def shorttype = ShortClass.typeConstructor
private def shortparam = List(shorttype) private def shortparam = List(shorttype)
private def inttype = IntClass.typeConstructor private def inttype = IntClass.typeConstructor
private def intparam = List(inttype) private def intparam = List(inttype)
private def longtype = LongClass.typeConstructor private def longtype = LongClass.typeConstructor
private def longparam = List(longtype) private def longparam = List(longtype)
private def floattype = FloatClass.typeConstructor private def floattype = FloatClass.typeConstructor
private def floatparam = List(floattype) private def floatparam = List(floattype)
private def doubletype = DoubleClass.typeConstructor private def doubletype = DoubleClass.typeConstructor
private def doubleparam = List(doubletype) private def doubleparam = List(doubletype)
private def chartype = CharClass.typeConstructor private def chartype = CharClass.typeConstructor
private def charparam = List(chartype) private def charparam = List(chartype)
private def stringtype = StringClass.typeConstructor private def stringtype = StringClass.typeConstructor
// top types // top types
lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil) setFlag (ABSTRACT) lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil) setFlag (ABSTRACT)
lazy val AnyValClass = newClass(ScalaPackageClass, tpnme.AnyVal, anyparam) setFlag (ABSTRACT | SEALED) lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor)
lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor) lazy val ObjectClass = getClass(sn.Object)
lazy val ObjectClass = getClass(sn.Object) lazy val AnyValCompanionClass = getClass("scala.AnyValCompanion") setFlag (SEALED | ABSTRACT | TRAIT)
// bottom types // bottom types
lazy val NullClass = newClass(ScalaPackageClass, tpnme.Null, anyrefparam) setFlag (ABSTRACT | TRAIT | FINAL) lazy val NullClass = newClass(ScalaPackageClass, tpnme.Null, anyrefparam) setFlag (ABSTRACT | TRAIT | FINAL)
lazy val NothingClass = newClass(ScalaPackageClass, tpnme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL) lazy val NothingClass = newClass(ScalaPackageClass, tpnme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
lazy val RuntimeNothingClass = getClass(ClassfileConstants.SCALA_NOTHING) lazy val RuntimeNothingClass = getClass(ClassfileConstants.SCALA_NOTHING)
lazy val RuntimeNullClass = getClass(ClassfileConstants.SCALA_NULL) lazy val RuntimeNullClass = getClass(ClassfileConstants.SCALA_NULL)
lazy val AnyValCompanionClass = getClass("scala.runtime.AnyValCompanion").setFlag(SEALED | ABSTRACT | TRAIT)
// the scala value classes
import ClassfileConstants._
lazy val UnitClass = newClass(ScalaPackageClass, tpnme.Unit, anyvalparam).setFlag(ABSTRACT | FINAL)
lazy val ByteClass = newValueClass(nme.Byte, BYTE_TAG, 2)
lazy val ShortClass = newValueClass(nme.Short, SHORT_TAG, 4)
lazy val CharClass = newValueClass(nme.Char, CHAR_TAG, 3)
lazy val IntClass = newValueClass(nme.Int, INT_TAG, 12)
lazy val LongClass = newValueClass(nme.Long, LONG_TAG, 24)
lazy val FloatClass = newValueClass(nme.Float, FLOAT_TAG, 48)
lazy val DoubleClass = newValueClass(nme.Double, DOUBLE_TAG, 96)
lazy val BooleanClass = newValueClass(nme.Boolean, BOOL_TAG, 0)
def Boolean_and = getMember(BooleanClass, nme.ZAND)
def Boolean_or = getMember(BooleanClass, nme.ZOR)
def ScalaValueClasses = List(
UnitClass,
BooleanClass,
ByteClass,
ShortClass,
CharClass,
IntClass,
LongClass,
FloatClass,
DoubleClass
)
// exceptions and other throwables // exceptions and other throwables
lazy val ClassCastExceptionClass = getClass("java.lang.ClassCastException") lazy val ClassCastExceptionClass = getClass("java.lang.ClassCastException")
@ -539,7 +611,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
case result => result case result => result
} }
} }
/** If you're looking for a class, pass a type name. /** If you're looking for a class, pass a type name.
* If a module, a term name. * If a module, a term name.
*/ */
@ -548,7 +620,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
val fullname = path.toTermName val fullname = path.toTermName
if (fullname == nme.NO_NAME) if (fullname == nme.NO_NAME)
return NoSymbol return NoSymbol
var sym: Symbol = RootClass var sym: Symbol = RootClass
var i = 0 var i = 0
var j = fullname.pos('.', i) var j = fullname.pos('.', i)
@ -565,7 +637,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
{ log(sym.info); log(sym.info.members) }//debug { log(sym.info); log(sym.info.members) }//debug
throw new MissingRequirementError((if (module) "object " else "class ") + fullname) throw new MissingRequirementError((if (module) "object " else "class ") + fullname)
} }
result result
} }
@ -605,7 +676,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
msym msym
} }
private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type): Symbol = { private[Definitions] def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type): Symbol = {
val msym = newMethod(owner, name) val msym = newMethod(owner, name)
val params = msym.newSyntheticValueParams(formals) val params = msym.newSyntheticValueParams(formals)
msym.setInfo(MethodType(params, restpe)) msym.setInfo(MethodType(params, restpe))
@ -628,198 +699,30 @@ trait Definitions extends reflect.generic.StandardDefinitions {
private def newTypeParam(owner: Symbol, index: Int): Symbol = private def newTypeParam(owner: Symbol, index: Int): Symbol =
owner.newTypeParameter(NoPosition, newTypeName("T" + index)) setInfo TypeBounds.empty owner.newTypeParameter(NoPosition, newTypeName("T" + index)) setInfo TypeBounds.empty
val boxedClass = new HashMap[Symbol, Symbol]
val boxedModule = new HashMap[Symbol, Symbol]
val unboxMethod = new HashMap[Symbol, Symbol] // Type -> Method
val boxMethod = new HashMap[Symbol, Symbol] // Type -> Method
val primitiveCompanions = new mutable.HashSet[Symbol] // AnyVal -> Companion
lazy val boxedClassValues = boxedClass.values.toSet lazy val boxedClassValues = boxedClass.values.toSet
lazy val isUnbox = unboxMethod.values.toSet
/** Maps a companion object like scala.Int to scala.runtime.Int. */ lazy val isBox = boxMethod.values.toSet
lazy val runtimeCompanions = (primitiveCompanions map { sym =>
sym -> getModule("scala.runtime." + sym.name)
}).toMap
def isUnbox(m: Symbol) = unboxMethod.valuesIterator contains m
def isBox(m: Symbol) = boxMethod.valuesIterator contains m
val refClass = new HashMap[Symbol, Symbol]
val volatileRefClass = new HashMap[Symbol, Symbol]
val abbrvTag = new HashMap[Symbol, Char]
private val numericWeight = new HashMap[Symbol, Int]
def isNumericSubClass(sub: Symbol, sup: Symbol) = {
val cmp = for (w1 <- numericWeight get sub ; w2 <- numericWeight get sup) yield w2 % w1
cmp exists (_ == 0)
}
/** Create a companion object for scala.Unit.
*/
private def initUnitCompanionObject() {
val module = ScalaPackageClass.newModule(NoPosition, "Unit")
ScalaPackageClass.info.decls.enter(module)
val mclass = module.moduleClass
mclass.setInfo(ClassInfoType(List(AnyRefClass.tpe, AnyValCompanionClass.tpe), new Scope, mclass))
module.setInfo(mclass.tpe)
primitiveCompanions += module
}
private[symtab] def newValueClass(name: TermName, tag: Char, weight: Int): Symbol = {
val tpName = name.toTypeName
val boxedName = sn.Boxed(tpName).toTermName
val clazz = newClass(ScalaPackageClass, tpName, anyvalparam) setFlag (ABSTRACT | FINAL)
boxedClass(clazz) = getClass(boxedName)
boxedModule(clazz) = getModule(boxedName)
refClass(clazz) = getClass("scala.runtime." + name + "Ref")
volatileRefClass(clazz) = getClass("scala.runtime.Volatile" + name + "Ref")
abbrvTag(clazz) = tag
if (weight > 0) numericWeight(clazz) = weight
val module = ScalaPackageClass.newModule(NoPosition, name)
ScalaPackageClass.info.decls.enter(module)
val mclass = module.moduleClass
mclass.setInfo(ClassInfoType(List(AnyRefClass.tpe, AnyValCompanionClass.tpe), new Scope, mclass))
module.setInfo(mclass.tpe)
primitiveCompanions += module
boxMethod(clazz) = newMethod(mclass, nme.box, List(clazz.typeConstructor), boxedClass(clazz).tpe)
unboxMethod(clazz) = newMethod(mclass, nme.unbox, List(ObjectClass.typeConstructor), clazz.typeConstructor)
clazz
}
/** Sets-up symbols etc. for value classes, and their boxed versions. This
* method is called once from within the body of init. */
private def initValueClasses() {
// init scala.Boolean
newParameterlessMethod(BooleanClass, nme.UNARY_!, booltype)
List(nme.EQ, nme.NE, nme.ZOR, nme.ZAND, nme.OR, nme.AND, nme.XOR) foreach {
newMethod(BooleanClass, _, boolparam, booltype)
}
def initValueClass(clazz: Symbol, isCardinal: Boolean) {
assert (clazz ne null)
val boolBinOps = List(nme.EQ, nme.NE, nme.LT, nme.LE, nme.GT, nme.GE)
val otherBinOps = List(nme.ADD, nme.SUB, nme.MUL, nme.DIV, nme.MOD)
val cardBinOps = List(nme.OR, nme.AND, nme.XOR)
val shiftOps = List(nme.LSL, nme.LSR, nme.ASR)
def addBinops(params: List[Type], restype: Type, isCardinal: Boolean) = {
boolBinOps foreach (x => newMethod(clazz, x, params, booltype))
otherBinOps foreach (x => newMethod(clazz, x, params, restype))
if (isCardinal)
cardBinOps foreach (x => newMethod(clazz, x, params, restype))
}
// conversion methods
newParameterlessMethod(clazz, nme.toByte, bytetype)
newParameterlessMethod(clazz, nme.toShort, shorttype)
newParameterlessMethod(clazz, nme.toChar, chartype)
newParameterlessMethod(clazz, nme.toInt, inttype)
newParameterlessMethod(clazz, nme.toLong, longtype)
newParameterlessMethod(clazz, nme.toFloat, floattype)
newParameterlessMethod(clazz, nme.toDouble, doubletype)
// def +(s: String): String
newMethod(clazz, nme.ADD, List(stringtype), stringtype)
def isLongFloatOrDouble = clazz match {
case LongClass | FloatClass | DoubleClass => true
case _ => false
}
val restype = if (isLongFloatOrDouble) clazz.typeConstructor else inttype
// shift operations
if (isCardinal)
for (op <- shiftOps ; param <- List(intparam, longparam))
newMethod(clazz, op, param, restype)
// unary operations
newParameterlessMethod(clazz, nme.UNARY_+, restype)
newParameterlessMethod(clazz, nme.UNARY_-, restype)
if (isCardinal) {
newParameterlessMethod(clazz, nme.UNARY_~, restype)
}
// binary operations
List(byteparam, shortparam, charparam, intparam) .
foreach (x => addBinops(x, restype, isCardinal))
addBinops(longparam, (if (isCardinal) longtype else restype), isCardinal)
addBinops(floatparam, (if (clazz eq DoubleClass) doubletype else floattype), false )
addBinops(doubleparam, doubletype, false )
}
List(ByteClass, ShortClass, CharClass, IntClass, LongClass) foreach (x => initValueClass(x, true))
List(FloatClass, DoubleClass) foreach (x => initValueClass(x, false))
def addModuleMethod(clazz: Symbol, name: TermName, value: Any) = {
val owner = clazz.linkedClassOfClass
newParameterlessMethod(owner, name, ConstantType(Constant(value)))
}
def addDeprecatedModuleMethod(clazz: Symbol, name: TermName, value: Any, msg: String) = {
val m = addModuleMethod(clazz, name, value)
val arg = Literal(Constant(msg))
m.addAnnotation(AnnotationInfo(DeprecatedAttr.tpe, List(arg), List()))
}
addModuleMethod(ByteClass, "MinValue", java.lang.Byte.MIN_VALUE)
addModuleMethod(ByteClass, "MaxValue", java.lang.Byte.MAX_VALUE)
addModuleMethod(ShortClass, "MinValue", java.lang.Short.MIN_VALUE)
addModuleMethod(ShortClass, "MaxValue", java.lang.Short.MAX_VALUE)
addModuleMethod(CharClass, "MinValue", java.lang.Character.MIN_VALUE)
addModuleMethod(CharClass, "MaxValue", java.lang.Character.MAX_VALUE)
addModuleMethod(IntClass, "MinValue", java.lang.Integer.MIN_VALUE)
addModuleMethod(IntClass, "MaxValue", java.lang.Integer.MAX_VALUE)
addModuleMethod(LongClass, "MinValue", java.lang.Long.MIN_VALUE)
addModuleMethod(LongClass, "MaxValue", java.lang.Long.MAX_VALUE)
addDeprecatedModuleMethod(FloatClass, "MinValue", -java.lang.Float.MAX_VALUE, "use Float.MinNegativeValue instead")
addModuleMethod(FloatClass, "MinNegativeValue", -java.lang.Float.MAX_VALUE)
addModuleMethod(FloatClass, "MaxValue", java.lang.Float.MAX_VALUE)
addDeprecatedModuleMethod(FloatClass, "Epsilon", java.lang.Float.MIN_VALUE, "use Float.MinPositiveValue instead")
addModuleMethod(FloatClass, "MinPositiveValue", java.lang.Float.MIN_VALUE)
addModuleMethod(FloatClass, "NaN", java.lang.Float.NaN)
addModuleMethod(FloatClass, "PositiveInfinity", java.lang.Float.POSITIVE_INFINITY)
addModuleMethod(FloatClass, "NegativeInfinity", java.lang.Float.NEGATIVE_INFINITY)
addDeprecatedModuleMethod(DoubleClass, "MinValue", -java.lang.Double.MAX_VALUE, "use Double.MinNegativeValue instead")
addModuleMethod(DoubleClass, "MinNegativeValue", -java.lang.Double.MAX_VALUE)
addModuleMethod(DoubleClass, "MaxValue", java.lang.Double.MAX_VALUE)
// see #3791. change cycle for `Epsilon`: 1. deprecate, 2. remove, 3. re-introduce as
// org.apache.commons.math.util.MathUtils.EPSILON (0x1.0p-53). not sure what to do for float.
addDeprecatedModuleMethod(DoubleClass, "Epsilon", java.lang.Double.MIN_VALUE, "use Double.MinPositiveValue instead")
addModuleMethod(DoubleClass, "MinPositiveValue", java.lang.Double.MIN_VALUE)
addModuleMethod(DoubleClass, "NaN", java.lang.Double.NaN)
addModuleMethod(DoubleClass, "PositiveInfinity", java.lang.Double.POSITIVE_INFINITY)
addModuleMethod(DoubleClass, "NegativeInfinity", java.lang.Double.NEGATIVE_INFINITY)
}
/** Is symbol a phantom class for which no runtime representation exists? */ /** Is symbol a phantom class for which no runtime representation exists? */
def isPhantomClass(sym: Symbol) = lazy val isPhantomClass = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass)
sym == AnyClass || sym == AnyValClass || sym == NullClass || sym == NothingClass
private lazy val scalaValueClassesSet = ScalaValueClasses.toSet
private lazy val boxedValueClassesSet = boxedClass.values.toSet + BoxedUnitClass
/** Is symbol a value class? */ /** Is symbol a value class? */
def isValueClass(sym: Symbol): Boolean = def isValueClass(sym: Symbol) = scalaValueClassesSet(sym)
(sym eq UnitClass) || (boxedClass contains sym)
/** Is symbol a boxed value class, e.g. java.lang.Integer? */ /** Is symbol a boxed value class, e.g. java.lang.Integer? */
def isBoxedValueClass(sym: Symbol): Boolean = def isBoxedValueClass(sym: Symbol) = boxedValueClassesSet(sym)
(sym eq BoxedUnitClass) || boxedClassValues(sym)
/** If symbol is a value class or a boxed value class, return the value class: otherwise NoSymbol. */ /** If symbol is a value class, return the value class, with the exception
* that BoxedUnit remains BoxedUnit. If not a value class, NoSymbol.
*/
def unboxedValueClass(sym: Symbol): Symbol = def unboxedValueClass(sym: Symbol): Symbol =
if (isValueClass(sym)) sym if (isValueClass(sym)) sym
else if (sym == BoxedUnitClass) sym else if (sym == BoxedUnitClass) sym
else boxedClass.map(_.swap).getOrElse(sym, NoSymbol) else boxedClass.map(_.swap).getOrElse(sym, NoSymbol)
/** Is symbol a numeric value class? */
def isNumericValueClass(sym: Symbol): Boolean =
numericWeight contains sym
/** Is type's symbol a numeric value class? */ /** Is type's symbol a numeric value class? */
def isNumericValueType(tp: Type): Boolean = tp match { def isNumericValueType(tp: Type): Boolean = tp match {
case TypeRef(_, sym, _) => isNumericValueClass(sym) case TypeRef(_, sym, _) => isNumericValueClass(sym)
@ -866,19 +769,26 @@ trait Definitions extends reflect.generic.StandardDefinitions {
// catch { case ex2: FatalError => throw ex1 } // catch { case ex2: FatalError => throw ex1 }
// } // }
// } // }
/** Surgery on the value classes. Without this, AnyVals defined in source
* files end up with an AnyRef parent. It is likely there is a better way
* to evade that AnyRef.
*/
private def setParents(sym: Symbol, parents: List[Type]): Symbol = sym.rawInfo match {
case ClassInfoType(_, scope, clazz) =>
sym setInfo ClassInfoType(parents, scope, clazz)
case _ =>
sym
}
def init { def init {
if (isInitialized) return if (isInitialized) return
EmptyPackageClass.setInfo(ClassInfoType(Nil, new Scope, EmptyPackageClass)) EmptyPackageClass setInfo ClassInfoType(Nil, new Scope, EmptyPackageClass)
EmptyPackage.setInfo(EmptyPackageClass.tpe) EmptyPackage setInfo EmptyPackageClass.tpe
RootClass.info.decls.enter(EmptyPackage)
RootClass.info.decls.enter(RootPackage)
abbrvTag(UnitClass) = 'V' RootClass.info.decls enter EmptyPackage
RootClass.info.decls enter RootPackage
initValueClasses()
initUnitCompanionObject()
// members of class scala.Any // members of class scala.Any
Any_== = newMethod(AnyClass, nme.EQ, anyparam, booltype) setFlag FINAL Any_== = newMethod(AnyClass, nme.EQ, anyparam, booltype) setFlag FINAL
@ -911,15 +821,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
RepeatedParamClass, RepeatedParamClass,
JavaRepeatedParamClass, JavaRepeatedParamClass,
ByNameParamClass, ByNameParamClass,
UnitClass,
ByteClass,
ShortClass,
CharClass,
IntClass,
LongClass,
FloatClass,
DoubleClass,
BooleanClass,
AnyClass, AnyClass,
AnyRefClass, AnyRefClass,
AnyValClass, AnyValClass,
@ -930,8 +831,13 @@ trait Definitions extends reflect.generic.StandardDefinitions {
Object_isInstanceOf, Object_isInstanceOf,
Object_asInstanceOf Object_asInstanceOf
) )
// AnyVal is sealed but needs to be made aware of its children
ScalaValueClasses foreach (AnyValClass addChild _) /** Removing the anyref parent they acquire from having a source file.
*/
setParents(AnyValClass, anyparam)
ScalaValueClasses foreach { sym =>
setParents(sym, anyvalparam)
}
if (forMSIL) { if (forMSIL) {
val intType = IntClass.typeConstructor val intType = IntClass.typeConstructor

View File

@ -23,6 +23,9 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
final val Short: NameType = "Short" final val Short: NameType = "Short"
final val Unit: NameType = "Unit" final val Unit: NameType = "Unit"
final val ScalaValueNames: scala.List[NameType] =
scala.List(Byte, Char, Short, Int, Long, Float, Double, Boolean, Unit)
// types whose companions we utilize // types whose companions we utilize
final val Array: NameType = "Array" final val Array: NameType = "Array"
final val List: NameType = "List" final val List: NameType = "List"

View File

@ -523,7 +523,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
override def transform(tree: Tree): Tree = override def transform(tree: Tree): Tree =
tree match { tree match {
case ClassDef(mods, name, tparams, impl) if !tree.symbol.isInterface => case ClassDef(mods, name, tparams, impl) if !tree.symbol.isInterface && !isValueClass(tree.symbol) =>
treeCopy.ClassDef(tree, mods, name, tparams, transformClassTemplate(impl)) treeCopy.ClassDef(tree, mods, name, tparams, transformClassTemplate(impl))
case _ => case _ =>
super.transform(tree) super.transform(tree)

View File

@ -174,7 +174,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
apply(atp) apply(atp)
case ClassInfoType(parents, decls, clazz) => case ClassInfoType(parents, decls, clazz) =>
ClassInfoType( ClassInfoType(
if ((clazz == ObjectClass) || (isValueClass(clazz))) List() if (clazz == ObjectClass || isValueClass(clazz)) Nil
else if (clazz == ArrayClass) List(erasedTypeRef(ObjectClass)) else if (clazz == ArrayClass) List(erasedTypeRef(ObjectClass))
else removeDoubleObject(parents map this), else removeDoubleObject(parents map this),
decls, clazz) decls, clazz)

View File

@ -241,10 +241,10 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
treatedClassInfos(clazz) = clazz.info treatedClassInfos(clazz) = clazz.info
assert(!clazz.isTrait, clazz) assert(!clazz.isTrait, clazz)
assert(!clazz.info.parents.isEmpty, clazz) assert(clazz.info.parents.nonEmpty, clazz)
// first complete the superclass with mixed in members // first complete the superclass with mixed in members
addMixedinMembers(clazz.superClass,unit) addMixedinMembers(clazz.superClass, unit)
//Console.println("adding members of " + clazz.info.baseClasses.tail.takeWhile(superclazz !=) + " to " + clazz);//DEBUG //Console.println("adding members of " + clazz.info.baseClasses.tail.takeWhile(superclazz !=) + " to " + clazz);//DEBUG
@ -485,13 +485,17 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
* - Remove all fields in implementation classes * - Remove all fields in implementation classes
*/ */
private def preTransform(tree: Tree): Tree = { private def preTransform(tree: Tree): Tree = {
val sym = tree.symbol val sym = tree.symbol
tree match { tree match {
case Template(parents, self, body) => case Template(parents, self, body) =>
localTyper = erasure.newTyper(rootContext.make(tree, currentOwner)) localTyper = erasure.newTyper(rootContext.make(tree, currentOwner))
atPhase(phase.next)(currentOwner.owner.info)//todo: needed? atPhase(phase.next)(currentOwner.owner.info)//todo: needed?
if (!currentOwner.isTrait) addMixedinMembers(currentOwner,unit)
else if (currentOwner hasFlag lateINTERFACE) addLateInterfaceMembers(currentOwner) if (!currentOwner.isTrait && !isValueClass(currentOwner))
addMixedinMembers(currentOwner, unit)
else if (currentOwner hasFlag lateINTERFACE)
addLateInterfaceMembers(currentOwner)
tree tree
case DefDef(mods, name, tparams, List(vparams), tpt, rhs) => case DefDef(mods, name, tparams, List(vparams), tpt, rhs) =>
if (currentOwner.isImplClass) { if (currentOwner.isImplClass) {

View File

@ -192,7 +192,8 @@ abstract class TailCalls extends Transform {
* Position is unchanged (by default, the method definition.) * Position is unchanged (by default, the method definition.)
*/ */
def fail(reason: String) = { def fail(reason: String) = {
log("Cannot rewrite recursive call at: " + fun.pos + " because: " + reason) if (settings.debug.value)
log("Cannot rewrite recursive call at: " + fun.pos + " because: " + reason)
ctx.failReason = reason ctx.failReason = reason
treeCopy.Apply(tree, target, transformArgs) treeCopy.Apply(tree, target, transformArgs)

View File

@ -790,6 +790,14 @@ trait Namers { self: Analyzer =>
classAndNamerOfModule(module) = (cdef, templateNamer) classAndNamerOfModule(module) = (cdef, templateNamer)
} }
if (opt.verbose) {
log(
"ClassInfoType(\n%s,\n%s,\n%s)".format(
" " + (parents map (_.typeSymbol) mkString ", "),
if (global.opt.debug) decls.toList map (">> " + _) mkString("\n", "\n", "") else " <decls>",
" " + clazz)
)
}
ClassInfoType(parents, decls, clazz) ClassInfoType(parents, decls, clazz)
} }
@ -1376,7 +1384,7 @@ trait Namers { self: Analyzer =>
* Finds the companion module of a class symbol. Calling .companionModule * Finds the companion module of a class symbol. Calling .companionModule
* does not work for classes defined inside methods. * does not work for classes defined inside methods.
*/ */
def companionModuleOf(clazz: Symbol, context: Context) = def companionModuleOf(clazz: Symbol, context: Context): Symbol = {
try { try {
var res = clazz.companionModule var res = clazz.companionModule
if (res == NoSymbol) if (res == NoSymbol)
@ -1388,8 +1396,9 @@ trait Namers { self: Analyzer =>
context.error(clazz.pos, e.getMessage) context.error(clazz.pos, e.getMessage)
NoSymbol NoSymbol
} }
}
def companionClassOf(module: Symbol, context: Context) = def companionClassOf(module: Symbol, context: Context): Symbol = {
try { try {
var res = module.companionClass var res = module.companionClass
if (res == NoSymbol) if (res == NoSymbol)
@ -1400,6 +1409,7 @@ trait Namers { self: Analyzer =>
context.error(module.pos, e.getMessage) context.error(module.pos, e.getMessage)
NoSymbol NoSymbol
} }
}
def companionSymbolOf(sym: Symbol, context: Context) = def companionSymbolOf(sym: Symbol, context: Context) =
if (sym.isTerm) companionClassOf(sym, context) if (sym.isTerm) companionClassOf(sym, context)

View File

@ -1148,10 +1148,11 @@ trait Typers extends Modes {
error(parent.pos, "illegal inheritance from final "+psym) error(parent.pos, "illegal inheritance from final "+psym)
} }
if (psym.isSealed && !phase.erasedTypes) { if (psym.isSealed && !phase.erasedTypes) {
if (context.unit.source.file != psym.sourceFile) // AnyVal is sealed, but we have to let the value classes through manually
error(parent.pos, "illegal inheritance from sealed "+psym) if (context.unit.source.file == psym.sourceFile || isValueClass(context.owner))
else
psym addChild context.owner psym addChild context.owner
else
error(parent.pos, "illegal inheritance from sealed "+psym)
} }
if (!(selfType <:< parent.tpe.typeOfThis) && if (!(selfType <:< parent.tpe.typeOfThis) &&
!phase.erasedTypes && !phase.erasedTypes &&
@ -1294,8 +1295,9 @@ trait Typers extends Modes {
val getter = if (isDeferred) value else value.getter(value.owner) val getter = if (isDeferred) value else value.getter(value.owner)
assert(getter != NoSymbol, stat) assert(getter != NoSymbol, stat)
if (getter.isOverloaded) if (getter.isOverloaded)
error(getter.pos, getter+" is defined twice") error(getter.pos, getter+" is defined twice")
getter.setAnnotations(memberAnnots(allAnnots, GetterTargetClass)) getter.setAnnotations(memberAnnots(allAnnots, GetterTargetClass))
if (value.isLazy) List(stat) if (value.isLazy) List(stat)
@ -2072,9 +2074,9 @@ trait Typers extends Modes {
(e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe))) (e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe)))
// default getters are defined twice when multiple overloads have defaults. an // default getters are defined twice when multiple overloads have defaults. an
// error for this is issued in RefChecks.checkDefaultsInOverloaded // error for this is issued in RefChecks.checkDefaultsInOverloaded
if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasDefaultFlag) { if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasDefaultFlag) {
error(e.sym.pos, e1.sym+" is defined twice"+ error(e.sym.pos, e1.sym+" is defined twice"+
{if(!settings.debug.value) "" else " in "+unit.toString}) {if(!settings.debug.value) "" else " in "+unit.toString})
scope.unlink(e1) // need to unlink to avoid later problems with lub; see #2779 scope.unlink(e1) // need to unlink to avoid later problems with lub; see #2779
} }
e1 = scope.lookupNextEntry(e1) e1 = scope.lookupNextEntry(e1)
@ -3432,6 +3434,8 @@ trait Typers extends Modes {
* @return ... * @return ...
*/ */
def typedSelect(qual: Tree, name: Name): Tree = { def typedSelect(qual: Tree, name: Name): Tree = {
val sym = val sym =
if (tree.symbol != NoSymbol) { if (tree.symbol != NoSymbol) {
if (phase.erasedTypes && qual.isInstanceOf[Super]) if (phase.erasedTypes && qual.isInstanceOf[Super])
@ -3473,7 +3477,7 @@ trait Typers extends Modes {
if (qual1 ne qual) return typed(treeCopy.Select(tree, qual1, name), mode, pt) if (qual1 ne qual) return typed(treeCopy.Select(tree, qual1, name), mode, pt)
} }
if (!reallyExists(sym)) { if (!reallyExists(sym)) {
if (context.owner.toplevelClass.isJavaDefined && name.isTypeName) { if (context.owner.toplevelClass.isJavaDefined && name.isTypeName) {
val tree1 = atPos(tree.pos) { gen.convertToSelectFromType(qual, name) } val tree1 = atPos(tree.pos) { gen.convertToSelectFromType(qual, name) }
if (tree1 != EmptyTree) return typed1(tree1, mode, pt) if (tree1 != EmptyTree) return typed1(tree1, mode, pt)

View File

@ -47,6 +47,11 @@ class Exceptional(val ex: Throwable)(implicit prefs: ScalaPrefs) {
def causes = Exceptional.causes(ex) def causes = Exceptional.causes(ex)
def summary = unwrapped.toString + "\n at " + apply(0).shortNameString def summary = unwrapped.toString + "\n at " + apply(0).shortNameString
private def println(msg: Any) = {
Console println msg
Console.flush()
}
def show(): Unit = println(context()) def show(): Unit = println(context())
def show(num: Int): Unit = println(context(num)) def show(num: Int): Unit = println(context(num))
@ -66,6 +71,7 @@ object Exceptional {
/** Some handy functions. */ /** Some handy functions. */
def stack() = JavaStackFrame frames ((new Throwable).getStackTrace dropWhile isLocal) def stack() = JavaStackFrame frames ((new Throwable).getStackTrace dropWhile isLocal)
def showme() = apply(new Throwable).show() def showme() = apply(new Throwable).show()
def showstack() = apply(new Throwable).showTable()
/** A frame formatter with more refined aesthetics than the default. /** A frame formatter with more refined aesthetics than the default.
* Come, let us be civilized. * Come, let us be civilized.

11
src/library/scala/AnyVal.scala Executable file
View File

@ -0,0 +1,11 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala
sealed trait AnyVal

View File

@ -0,0 +1,21 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala
/** A common supertype for companion classes of primitive types.
*
* A common trait for /companion/ objects of primitive types comes handy
* when parameterizing code on types. For instance, the specialized
* annotation is passed a sequence of types on which to specialize:
* {{{
* class Tuple1[@specialized(Unit, Int, Double) T]
* }}}
*
*/
private[scala] trait AnyValCompanion { }

34
src/library/scala/Boolean.scala Executable file
View File

@ -0,0 +1,34 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Boolean extends AnyVal {
def unary_! : Boolean = sys.error("stub")
def ==(x: Boolean): Boolean = sys.error("stub")
def !=(x: Boolean): Boolean = sys.error("stub")
def ||(x: Boolean): Boolean = sys.error("stub")
def &&(x: Boolean): Boolean = sys.error("stub")
// 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 = sys.error("stub")
def &(x: Boolean): Boolean = sys.error("stub")
def ^(x: Boolean): Boolean = sys.error("stub")
}
object Boolean extends AnyValCompanion {
override def toString = "object scala.Boolean"
def box(x: Boolean): jl.Boolean = jl.Boolean.valueOf(x)
def unbox(x: jl.Object): Boolean = x.asInstanceOf[jl.Boolean].booleanValue()
}

View File

@ -0,0 +1,154 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Byte 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")
def unary_+ : Int = sys.error("stub")
def unary_- : Int = sys.error("stub")
def unary_~ : Int = sys.error("stub")
def +(x: String): String = sys.error("stub")
def <<(x: Int): Int = sys.error("stub")
def <<(x: Long): Int = sys.error("stub")
def >>>(x: Int): Int = sys.error("stub")
def >>>(x: Long): Int = sys.error("stub")
def >>(x: Int): Int = sys.error("stub")
def >>(x: Long): Int = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def |(x: Byte): Int = sys.error("stub")
def |(x: Short): Int = sys.error("stub")
def |(x: Char): Int = sys.error("stub")
def |(x: Int): Int = sys.error("stub")
def |(x: Long): Long = sys.error("stub")
def &(x: Byte): Int = sys.error("stub")
def &(x: Short): Int = sys.error("stub")
def &(x: Char): Int = sys.error("stub")
def &(x: Int): Int = sys.error("stub")
def &(x: Long): Long = sys.error("stub")
def ^(x: Byte): Int = sys.error("stub")
def ^(x: Short): Int = sys.error("stub")
def ^(x: Char): Int = sys.error("stub")
def ^(x: Int): Int = sys.error("stub")
def ^(x: Long): Long = sys.error("stub")
def +(x: Byte): Int = sys.error("stub")
def +(x: Short): Int = sys.error("stub")
def +(x: Char): Int = sys.error("stub")
def +(x: Int): Int = sys.error("stub")
def +(x: Long): Long = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Int = sys.error("stub")
def -(x: Short): Int = sys.error("stub")
def -(x: Char): Int = sys.error("stub")
def -(x: Int): Int = sys.error("stub")
def -(x: Long): Long = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Int = sys.error("stub")
def *(x: Short): Int = sys.error("stub")
def *(x: Char): Int = sys.error("stub")
def *(x: Int): Int = sys.error("stub")
def *(x: Long): Long = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Int = sys.error("stub")
def /(x: Short): Int = sys.error("stub")
def /(x: Char): Int = sys.error("stub")
def /(x: Int): Int = sys.error("stub")
def /(x: Long): Long = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Int = sys.error("stub")
def %(x: Short): Int = sys.error("stub")
def %(x: Char): Int = sys.error("stub")
def %(x: Int): Int = sys.error("stub")
def %(x: Long): Long = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Byte extends AnyValCompanion {
final val MinValue = jl.Byte.MIN_VALUE
final val MaxValue = jl.Byte.MAX_VALUE
def box(x: Byte): jl.Byte = jl.Byte.valueOf(x)
def unbox(x: jl.Object): Byte = x.asInstanceOf[jl.Byte].byteValue()
override def toString = "object scala.Byte"
}

View File

@ -0,0 +1,154 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Char 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")
def unary_+ : Int = sys.error("stub")
def unary_- : Int = sys.error("stub")
def unary_~ : Int = sys.error("stub")
def +(x: String): String = sys.error("stub")
def <<(x: Int): Int = sys.error("stub")
def <<(x: Long): Int = sys.error("stub")
def >>>(x: Int): Int = sys.error("stub")
def >>>(x: Long): Int = sys.error("stub")
def >>(x: Int): Int = sys.error("stub")
def >>(x: Long): Int = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def |(x: Byte): Int = sys.error("stub")
def |(x: Short): Int = sys.error("stub")
def |(x: Char): Int = sys.error("stub")
def |(x: Int): Int = sys.error("stub")
def |(x: Long): Long = sys.error("stub")
def &(x: Byte): Int = sys.error("stub")
def &(x: Short): Int = sys.error("stub")
def &(x: Char): Int = sys.error("stub")
def &(x: Int): Int = sys.error("stub")
def &(x: Long): Long = sys.error("stub")
def ^(x: Byte): Int = sys.error("stub")
def ^(x: Short): Int = sys.error("stub")
def ^(x: Char): Int = sys.error("stub")
def ^(x: Int): Int = sys.error("stub")
def ^(x: Long): Long = sys.error("stub")
def +(x: Byte): Int = sys.error("stub")
def +(x: Short): Int = sys.error("stub")
def +(x: Char): Int = sys.error("stub")
def +(x: Int): Int = sys.error("stub")
def +(x: Long): Long = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Int = sys.error("stub")
def -(x: Short): Int = sys.error("stub")
def -(x: Char): Int = sys.error("stub")
def -(x: Int): Int = sys.error("stub")
def -(x: Long): Long = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Int = sys.error("stub")
def *(x: Short): Int = sys.error("stub")
def *(x: Char): Int = sys.error("stub")
def *(x: Int): Int = sys.error("stub")
def *(x: Long): Long = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Int = sys.error("stub")
def /(x: Short): Int = sys.error("stub")
def /(x: Char): Int = sys.error("stub")
def /(x: Int): Int = sys.error("stub")
def /(x: Long): Long = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Int = sys.error("stub")
def %(x: Short): Int = sys.error("stub")
def %(x: Char): Int = sys.error("stub")
def %(x: Int): Int = sys.error("stub")
def %(x: Long): Long = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Char extends AnyValCompanion {
final val MinValue = jl.Character.MIN_VALUE
final val MaxValue = jl.Character.MAX_VALUE
def box(x: Char): jl.Character = jl.Character.valueOf(x)
def unbox(x: jl.Object): Char = x.asInstanceOf[jl.Character].charValue()
override def toString = "object scala.Char"
}

View File

@ -0,0 +1,137 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Double 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")
def unary_+ : Double = sys.error("stub")
def unary_- : Double = sys.error("stub")
def +(x: String): String = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def +(x: Byte): Double = sys.error("stub")
def +(x: Short): Double = sys.error("stub")
def +(x: Char): Double = sys.error("stub")
def +(x: Int): Double = sys.error("stub")
def +(x: Long): Double = sys.error("stub")
def +(x: Float): Double = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Double = sys.error("stub")
def -(x: Short): Double = sys.error("stub")
def -(x: Char): Double = sys.error("stub")
def -(x: Int): Double = sys.error("stub")
def -(x: Long): Double = sys.error("stub")
def -(x: Float): Double = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Double = sys.error("stub")
def *(x: Short): Double = sys.error("stub")
def *(x: Char): Double = sys.error("stub")
def *(x: Int): Double = sys.error("stub")
def *(x: Long): Double = sys.error("stub")
def *(x: Float): Double = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Double = sys.error("stub")
def /(x: Short): Double = sys.error("stub")
def /(x: Char): Double = sys.error("stub")
def /(x: Int): Double = sys.error("stub")
def /(x: Long): Double = sys.error("stub")
def /(x: Float): Double = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Double = sys.error("stub")
def %(x: Short): Double = sys.error("stub")
def %(x: Char): Double = sys.error("stub")
def %(x: Int): Double = sys.error("stub")
def %(x: Long): Double = sys.error("stub")
def %(x: Float): Double = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Double extends AnyValCompanion {
final val MinPositiveValue = jl.Double.MIN_VALUE
final val MinNegativeValue = -jl.Double.MAX_VALUE
final val NaN = jl.Double.NaN
final val PositiveInfinity = jl.Double.POSITIVE_INFINITY
final val NegativeInfinity = jl.Double.NEGATIVE_INFINITY
@deprecated("use Double.MinPositiveValue instead")
final val Epsilon = MinPositiveValue
@deprecated("use Double.MinNegativeValue instead")
final val MinValue = MinNegativeValue
final val MaxValue = jl.Double.MAX_VALUE
def box(x: Double): jl.Double = jl.Double.valueOf(x)
def unbox(x: jl.Object): Double = x.asInstanceOf[jl.Double].doubleValue()
override def toString = "object scala.Double"
}

View File

@ -0,0 +1,137 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Float 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")
def unary_+ : Float = sys.error("stub")
def unary_- : Float = sys.error("stub")
def +(x: String): String = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def +(x: Byte): Float = sys.error("stub")
def +(x: Short): Float = sys.error("stub")
def +(x: Char): Float = sys.error("stub")
def +(x: Int): Float = sys.error("stub")
def +(x: Long): Float = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Float = sys.error("stub")
def -(x: Short): Float = sys.error("stub")
def -(x: Char): Float = sys.error("stub")
def -(x: Int): Float = sys.error("stub")
def -(x: Long): Float = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Float = sys.error("stub")
def *(x: Short): Float = sys.error("stub")
def *(x: Char): Float = sys.error("stub")
def *(x: Int): Float = sys.error("stub")
def *(x: Long): Float = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Float = sys.error("stub")
def /(x: Short): Float = sys.error("stub")
def /(x: Char): Float = sys.error("stub")
def /(x: Int): Float = sys.error("stub")
def /(x: Long): Float = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Float = sys.error("stub")
def %(x: Short): Float = sys.error("stub")
def %(x: Char): Float = sys.error("stub")
def %(x: Int): Float = sys.error("stub")
def %(x: Long): Float = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Float extends AnyValCompanion {
final val MinPositiveValue = jl.Float.MIN_VALUE
final val MinNegativeValue = -jl.Float.MAX_VALUE
final val NaN = jl.Float.NaN
final val PositiveInfinity = jl.Float.POSITIVE_INFINITY
final val NegativeInfinity = jl.Float.NEGATIVE_INFINITY
@deprecated("use Float.MinPositiveValue instead")
final val Epsilon = MinPositiveValue
@deprecated("use Float.MinNegativeValue instead")
final val MinValue = MinNegativeValue
final val MaxValue = jl.Float.MAX_VALUE
def box(x: Float): jl.Float = jl.Float.valueOf(x)
def unbox(x: jl.Object): Float = x.asInstanceOf[jl.Float].floatValue()
override def toString = "object scala.Float"
}

154
src/library/scala/Int.scala Normal file
View File

@ -0,0 +1,154 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Int 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")
def unary_+ : Int = sys.error("stub")
def unary_- : Int = sys.error("stub")
def unary_~ : Int = sys.error("stub")
def +(x: String): String = sys.error("stub")
def <<(x: Int): Int = sys.error("stub")
def <<(x: Long): Int = sys.error("stub")
def >>>(x: Int): Int = sys.error("stub")
def >>>(x: Long): Int = sys.error("stub")
def >>(x: Int): Int = sys.error("stub")
def >>(x: Long): Int = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def |(x: Byte): Int = sys.error("stub")
def |(x: Short): Int = sys.error("stub")
def |(x: Char): Int = sys.error("stub")
def |(x: Int): Int = sys.error("stub")
def |(x: Long): Long = sys.error("stub")
def &(x: Byte): Int = sys.error("stub")
def &(x: Short): Int = sys.error("stub")
def &(x: Char): Int = sys.error("stub")
def &(x: Int): Int = sys.error("stub")
def &(x: Long): Long = sys.error("stub")
def ^(x: Byte): Int = sys.error("stub")
def ^(x: Short): Int = sys.error("stub")
def ^(x: Char): Int = sys.error("stub")
def ^(x: Int): Int = sys.error("stub")
def ^(x: Long): Long = sys.error("stub")
def +(x: Byte): Int = sys.error("stub")
def +(x: Short): Int = sys.error("stub")
def +(x: Char): Int = sys.error("stub")
def +(x: Int): Int = sys.error("stub")
def +(x: Long): Long = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Int = sys.error("stub")
def -(x: Short): Int = sys.error("stub")
def -(x: Char): Int = sys.error("stub")
def -(x: Int): Int = sys.error("stub")
def -(x: Long): Long = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Int = sys.error("stub")
def *(x: Short): Int = sys.error("stub")
def *(x: Char): Int = sys.error("stub")
def *(x: Int): Int = sys.error("stub")
def *(x: Long): Long = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Int = sys.error("stub")
def /(x: Short): Int = sys.error("stub")
def /(x: Char): Int = sys.error("stub")
def /(x: Int): Int = sys.error("stub")
def /(x: Long): Long = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Int = sys.error("stub")
def %(x: Short): Int = sys.error("stub")
def %(x: Char): Int = sys.error("stub")
def %(x: Int): Int = sys.error("stub")
def %(x: Long): Long = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Int extends AnyValCompanion {
final val MinValue = jl.Integer.MIN_VALUE
final val MaxValue = jl.Integer.MAX_VALUE
def box(x: Int): jl.Integer = jl.Integer.valueOf(x)
def unbox(x: jl.Object): Int = x.asInstanceOf[jl.Integer].intValue()
override def toString = "object scala.Int"
}

View File

@ -0,0 +1,154 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Long 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")
def unary_+ : Long = sys.error("stub")
def unary_- : Long = sys.error("stub")
def unary_~ : Long = sys.error("stub")
def +(x: String): String = sys.error("stub")
def <<(x: Int): Long = sys.error("stub")
def <<(x: Long): Long = sys.error("stub")
def >>>(x: Int): Long = sys.error("stub")
def >>>(x: Long): Long = sys.error("stub")
def >>(x: Int): Long = sys.error("stub")
def >>(x: Long): Long = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def |(x: Byte): Long = sys.error("stub")
def |(x: Short): Long = sys.error("stub")
def |(x: Char): Long = sys.error("stub")
def |(x: Int): Long = sys.error("stub")
def |(x: Long): Long = sys.error("stub")
def &(x: Byte): Long = sys.error("stub")
def &(x: Short): Long = sys.error("stub")
def &(x: Char): Long = sys.error("stub")
def &(x: Int): Long = sys.error("stub")
def &(x: Long): Long = sys.error("stub")
def ^(x: Byte): Long = sys.error("stub")
def ^(x: Short): Long = sys.error("stub")
def ^(x: Char): Long = sys.error("stub")
def ^(x: Int): Long = sys.error("stub")
def ^(x: Long): Long = sys.error("stub")
def +(x: Byte): Long = sys.error("stub")
def +(x: Short): Long = sys.error("stub")
def +(x: Char): Long = sys.error("stub")
def +(x: Int): Long = sys.error("stub")
def +(x: Long): Long = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Long = sys.error("stub")
def -(x: Short): Long = sys.error("stub")
def -(x: Char): Long = sys.error("stub")
def -(x: Int): Long = sys.error("stub")
def -(x: Long): Long = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Long = sys.error("stub")
def *(x: Short): Long = sys.error("stub")
def *(x: Char): Long = sys.error("stub")
def *(x: Int): Long = sys.error("stub")
def *(x: Long): Long = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Long = sys.error("stub")
def /(x: Short): Long = sys.error("stub")
def /(x: Char): Long = sys.error("stub")
def /(x: Int): Long = sys.error("stub")
def /(x: Long): Long = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Long = sys.error("stub")
def %(x: Short): Long = sys.error("stub")
def %(x: Char): Long = sys.error("stub")
def %(x: Int): Long = sys.error("stub")
def %(x: Long): Long = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Long extends AnyValCompanion {
final val MinValue = jl.Long.MIN_VALUE
final val MaxValue = jl.Long.MAX_VALUE
def box(x: Long): jl.Long = jl.Long.valueOf(x)
def unbox(x: jl.Object): Long = x.asInstanceOf[jl.Long].longValue()
override def toString = "object scala.Long"
}

View File

@ -0,0 +1,154 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
final class Short 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")
def unary_+ : Int = sys.error("stub")
def unary_- : Int = sys.error("stub")
def unary_~ : Int = sys.error("stub")
def +(x: String): String = sys.error("stub")
def <<(x: Int): Int = sys.error("stub")
def <<(x: Long): Int = sys.error("stub")
def >>>(x: Int): Int = sys.error("stub")
def >>>(x: Long): Int = sys.error("stub")
def >>(x: Int): Int = sys.error("stub")
def >>(x: Long): Int = sys.error("stub")
def ==(x: Byte): Boolean = sys.error("stub")
def ==(x: Short): Boolean = sys.error("stub")
def ==(x: Char): Boolean = sys.error("stub")
def ==(x: Int): Boolean = sys.error("stub")
def ==(x: Long): Boolean = sys.error("stub")
def ==(x: Float): Boolean = sys.error("stub")
def ==(x: Double): Boolean = sys.error("stub")
def !=(x: Byte): Boolean = sys.error("stub")
def !=(x: Short): Boolean = sys.error("stub")
def !=(x: Char): Boolean = sys.error("stub")
def !=(x: Int): Boolean = sys.error("stub")
def !=(x: Long): Boolean = sys.error("stub")
def !=(x: Float): Boolean = sys.error("stub")
def !=(x: Double): Boolean = sys.error("stub")
def <(x: Byte): Boolean = sys.error("stub")
def <(x: Short): Boolean = sys.error("stub")
def <(x: Char): Boolean = sys.error("stub")
def <(x: Int): Boolean = sys.error("stub")
def <(x: Long): Boolean = sys.error("stub")
def <(x: Float): Boolean = sys.error("stub")
def <(x: Double): Boolean = sys.error("stub")
def <=(x: Byte): Boolean = sys.error("stub")
def <=(x: Short): Boolean = sys.error("stub")
def <=(x: Char): Boolean = sys.error("stub")
def <=(x: Int): Boolean = sys.error("stub")
def <=(x: Long): Boolean = sys.error("stub")
def <=(x: Float): Boolean = sys.error("stub")
def <=(x: Double): Boolean = sys.error("stub")
def >(x: Byte): Boolean = sys.error("stub")
def >(x: Short): Boolean = sys.error("stub")
def >(x: Char): Boolean = sys.error("stub")
def >(x: Int): Boolean = sys.error("stub")
def >(x: Long): Boolean = sys.error("stub")
def >(x: Float): Boolean = sys.error("stub")
def >(x: Double): Boolean = sys.error("stub")
def >=(x: Byte): Boolean = sys.error("stub")
def >=(x: Short): Boolean = sys.error("stub")
def >=(x: Char): Boolean = sys.error("stub")
def >=(x: Int): Boolean = sys.error("stub")
def >=(x: Long): Boolean = sys.error("stub")
def >=(x: Float): Boolean = sys.error("stub")
def >=(x: Double): Boolean = sys.error("stub")
def |(x: Byte): Int = sys.error("stub")
def |(x: Short): Int = sys.error("stub")
def |(x: Char): Int = sys.error("stub")
def |(x: Int): Int = sys.error("stub")
def |(x: Long): Long = sys.error("stub")
def &(x: Byte): Int = sys.error("stub")
def &(x: Short): Int = sys.error("stub")
def &(x: Char): Int = sys.error("stub")
def &(x: Int): Int = sys.error("stub")
def &(x: Long): Long = sys.error("stub")
def ^(x: Byte): Int = sys.error("stub")
def ^(x: Short): Int = sys.error("stub")
def ^(x: Char): Int = sys.error("stub")
def ^(x: Int): Int = sys.error("stub")
def ^(x: Long): Long = sys.error("stub")
def +(x: Byte): Int = sys.error("stub")
def +(x: Short): Int = sys.error("stub")
def +(x: Char): Int = sys.error("stub")
def +(x: Int): Int = sys.error("stub")
def +(x: Long): Long = sys.error("stub")
def +(x: Float): Float = sys.error("stub")
def +(x: Double): Double = sys.error("stub")
def -(x: Byte): Int = sys.error("stub")
def -(x: Short): Int = sys.error("stub")
def -(x: Char): Int = sys.error("stub")
def -(x: Int): Int = sys.error("stub")
def -(x: Long): Long = sys.error("stub")
def -(x: Float): Float = sys.error("stub")
def -(x: Double): Double = sys.error("stub")
def *(x: Byte): Int = sys.error("stub")
def *(x: Short): Int = sys.error("stub")
def *(x: Char): Int = sys.error("stub")
def *(x: Int): Int = sys.error("stub")
def *(x: Long): Long = sys.error("stub")
def *(x: Float): Float = sys.error("stub")
def *(x: Double): Double = sys.error("stub")
def /(x: Byte): Int = sys.error("stub")
def /(x: Short): Int = sys.error("stub")
def /(x: Char): Int = sys.error("stub")
def /(x: Int): Int = sys.error("stub")
def /(x: Long): Long = sys.error("stub")
def /(x: Float): Float = sys.error("stub")
def /(x: Double): Double = sys.error("stub")
def %(x: Byte): Int = sys.error("stub")
def %(x: Short): Int = sys.error("stub")
def %(x: Char): Int = sys.error("stub")
def %(x: Int): Int = sys.error("stub")
def %(x: Long): Long = sys.error("stub")
def %(x: Float): Float = sys.error("stub")
def %(x: Double): Double = sys.error("stub")
}
object Short extends AnyValCompanion {
final val MinValue = jl.Short.MIN_VALUE
final val MaxValue = jl.Short.MAX_VALUE
def box(x: Short): jl.Short = jl.Short.valueOf(x)
def unbox(x: jl.Object): Short = x.asInstanceOf[jl.Short].shortValue()
override def toString = "object scala.Short"
}

23
src/library/scala/Unit.scala Executable file
View File

@ -0,0 +1,23 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// generated on Sun Jan 23 21:13:38 PST 2011
package scala
import java.{ lang => jl }
import runtime.BoxedUnit
final class Unit extends AnyVal { }
object Unit extends AnyValCompanion {
override def toString = "object scala.Unit"
def box(x: Unit): BoxedUnit = BoxedUnit.UNIT
def unbox(x: jl.Object): Unit = ()
}

View File

@ -6,81 +6,9 @@
** |/ ** ** |/ **
\* */ \* */
package scala.runtime package scala.runtime
/** A common supertype for companion classes of primitive types. /** See scala.AnyValCompanion.
*
* A common trait for /companion/ objects of primitive types comes handy
* when parameterizing code on types. For instance, the specialized
* annotation is passed a sequence of types on which to specialize:
* {{{
* class Tuple1[@specialized(Unit, Int, Double) T]
* }}}
*
*/ */
sealed trait AnyValCompanion @deprecated("Use scala.AnyValCompanion instead")
private[scala] trait AnyValCompanion extends scala.AnyValCompanion { }
/** A object representing `object scala.Unit`. It should never be used
* directly.
*/
object Unit extends AnyValCompanion {
override def toString = "object scala.Unit"
}
/** A object representing `object scala.Boolean`. It should never be used
* directly.
*/
object Boolean extends AnyValCompanion {
override def toString = "object scala.Boolean"
}
/** A object representing `object scala.Byte`. It should never be used
* directly.
*/
object Byte extends AnyValCompanion {
override def toString = "object scala.Byte"
}
/** A object representing `object scala.Short`. It should never be used
* directly.
*/
object Short extends AnyValCompanion {
override def toString = "object scala.Short"
}
/** A object representing `object scala.Char`. It should never be used
* directly.
*/
object Char extends AnyValCompanion {
override def toString = "object scala.Char"
}
/** A object representing `object scala.Int`. It should never be used
* directly.
*/
object Int extends AnyValCompanion {
override def toString = "object scala.Int"
}
/** A object representing `object scala.Long`. It should never be used
* directly.
*/
object Long extends AnyValCompanion {
override def toString = "object scala.Long"
}
/** A object representing `object scala.Float`. It should never be used
* directly.
*/
object Float extends AnyValCompanion {
override def toString = "object scala.Float"
}
/** A object representing `object scala.Double`. It should never be used
* directly.
*/
object Double extends AnyValCompanion {
override def toString = "object scala.Double"
}

View File

@ -0,0 +1,13 @@
package scala
package object runtime {
@deprecated("Use `scala.Unit` instead.") val Unit = scala.Unit
@deprecated("Use `scala.Boolean` instead.") val Boolean = scala.Boolean
@deprecated("Use `scala.Byte` instead.") val Byte = scala.Byte
@deprecated("Use `scala.Short` instead.") val Short = scala.Short
@deprecated("Use `scala.Char` instead.") val Char = scala.Char
@deprecated("Use `scala.Int` instead.") val Int = scala.Int
@deprecated("Use `scala.Long` instead.") val Long = scala.Long
@deprecated("Use `scala.Float` instead.") val Float = scala.Float
@deprecated("Use `scala.Double` instead.") val Double = scala.Double
}

View File

@ -25,7 +25,7 @@ package scala
* *
* @since 2.8 * @since 2.8
*/ */
class specialized(types: runtime.AnyValCompanion*) extends annotation.StaticAnnotation { class specialized(types: AnyValCompanion*) extends annotation.StaticAnnotation {
def this() { def this() {
this(Unit, Boolean, Byte, Short, Char, Int, Long, Float, Double) this(Unit, Boolean, Byte, Short, Char, Int, Long, Float, Double)
} }

View File

@ -1,12 +1,12 @@
overload-msg.scala:3: error: overloaded method value + with alternatives: overload-msg.scala:3: error: overloaded method value + with alternatives:
(Double)Double <and> (x: Double)Double <and>
(Float)Float <and> (x: Float)Float <and>
(Long)Long <and> (x: Long)Long <and>
(scala.Int)scala.Int <and> (x: scala.Int)scala.Int <and>
(Char)scala.Int <and> (x: Char)scala.Int <and>
(Short)scala.Int <and> (x: Short)scala.Int <and>
(Byte)scala.Int <and> (x: Byte)scala.Int <and>
(java.lang.String)java.lang.String (x: String)String
cannot be applied to (Int(in method f)) cannot be applied to (Int(in method f))
def f[Int](y: Int) = x + y def f[Int](y: Int) = x + y
^ ^