diff options
author | Martin Odersky <odersky@gmail.com> | 2012-02-06 14:31:45 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-02-06 14:31:45 +0100 |
commit | 6a6cd3ac2986c6036e64cb38b9e22f9416409f48 (patch) | |
tree | 6283db1827b3fcca6eeecd2443f96d39a62d99dc /src | |
parent | 4407cdb4df86de2422c242210a96b11c2d14ac31 (diff) | |
download | scala-6a6cd3ac2986c6036e64cb38b9e22f9416409f48.tar.gz scala-6a6cd3ac2986c6036e64cb38b9e22f9416409f48.tar.bz2 scala-6a6cd3ac2986c6036e64cb38b9e22f9416409f48.zip |
Removing AnyVal as a source class. Removing automatic addition of ScalaObject. Undoing wrong fix in ExtensionMethods.
Diffstat (limited to 'src')
7 files changed, 27 insertions, 65 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 67f6bf838e..8e07c3e109 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -235,7 +235,7 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal orElse { // println("new anyval") oldValueScheme = false - val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, anyparam, 0L) + val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, anyparam, ABSTRACT) val av_constr = anyval.newClassConstructor(NoPosition) anyval.info.decls enter av_constr anyval @@ -1063,9 +1063,9 @@ trait Definitions extends reflect.api.StandardDefinitions { setParents(AnyValClass, List(NotNullClass.tpe, AnyClass.tpe)) } else { AnyVal_getClass // force it! - } - ScalaValueClasses foreach { sym => - setParents(sym, anyvalparam) + ScalaValueClasses foreach { sym => + setParents(sym, anyvalparam) + } } isInitialized = true diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index fb827b0658..e182bb6fdb 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -41,7 +41,7 @@ abstract class SymbolTable extends api.Universe /** Override with final implementation for inlining. */ def debuglog(msg: => String): Unit = if (settings.debug.value) log(msg) def debugwarn(msg: => String): Unit = if (settings.debug.value) Console.err.println(msg) - + /** Overridden when we know more about what was happening during a failure. */ def supplementErrorMessage(msg: String): String = msg @@ -276,7 +276,7 @@ abstract class SymbolTable extends api.Universe /** The phase which has given index as identifier. */ val phaseWithId: Array[Phase] - + /** Is this symbol table part of reflexive mirror? In this case * operations need to be made thread safe. */ diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala index 46d890c5d1..e0b9a1e3bb 100644 --- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala +++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala @@ -49,15 +49,15 @@ trait ToolBoxes extends { self: Universe => typer.atOwner(tree, owner).typed(tree, analyzer.EXPRmode, pt) } - + def defOwner(tree: Tree): Symbol = tree find (_.isDef) map (_.symbol) match { case Some(sym) if sym != null && sym != NoSymbol => sym.owner case _ => NoSymbol } - + def wrapInObject(expr: Tree, fvs: List[Symbol]): ModuleDef = { val obj = EmptyPackageClass.newModule(nextWrapperModuleName()) - val minfo = ClassInfoType(List(ObjectClass.tpe, ScalaObjectClass.tpe), newScope, obj.moduleClass) + val minfo = ClassInfoType(List(ObjectClass.tpe), newScope, obj.moduleClass) obj.moduleClass setInfo minfo obj setInfo obj.moduleClass.tpe val meth = obj.moduleClass.newMethod(newTermName(wrapperMethodName)) @@ -104,13 +104,13 @@ trait ToolBoxes extends { self: Universe => def runExpr(expr: Tree): Any = { val etpe = expr.tpe val fvs = (expr filter isFree map (_.symbol)).distinct - + reporter.reset() val className = compileExpr(expr, fvs) if (reporter.hasErrors) { throw new Error("reflective compilation has failed") } - + if (settings.debug.value) println("generated: "+className) val jclazz = jClass.forName(moduleFileName(className), true, classLoader) val jmeth = jclazz.getDeclaredMethods.find(_.getName == wrapperMethodName).get @@ -167,7 +167,7 @@ trait ToolBoxes extends { self: Universe => lazy val exporter = importer.reverse lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, defaultReflectiveClassLoader) - + private def importAndTypeCheck(tree: rm.Tree, expectedType: rm.Type): compiler.Tree = { // need to establish a run an phase because otherwise we run into an assertion in TypeHistory // that states that the period must be different from NoPeriod @@ -189,7 +189,7 @@ trait ToolBoxes extends { self: Universe => def typeCheck(tree: rm.Tree): rm.Tree = typeCheck(tree, WildcardType.asInstanceOf[rm.Type]) - def showAttributed(tree: rm.Tree): String = + def showAttributed(tree: rm.Tree): String = compiler.showAttributed(importer.importTree(tree.asInstanceOf[Tree])) def runExpr(tree: rm.Tree, expectedType: rm.Type): Any = { diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index c308a3633e..4db05f46d3 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -87,8 +87,8 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { val thisParam = extensionMeth.newValueParameter(nme.SELF, extensionMeth.pos) setInfo thisParamType def transform(clonedType: Type): Type = clonedType match { case MethodType(params, restpe) => - // I assume it was a bug that this was dropping params... - MethodType(thisParam :: params, clonedType) + // I assume it was a bug that this was dropping params... [Martin]: No, it wasn't; it's curried. + MethodType(List(thisParam), clonedType) case NullaryMethodType(restpe) => MethodType(List(thisParam), restpe) } @@ -121,12 +121,13 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { extensionMeth setInfo newInfo log("Inline class %s spawns extension method.\n Old: %s\n New: %s".format( currentOwner, - origMeth.defString, + origMeth.defString, extensionMeth.defString)) // extensionMeth.defStringSeenAs(origInfo def thisParamRef = gen.mkAttributedIdent(extensionMeth.info.params.head setPos extensionMeth.pos) val GenPolyType(extensionTpeParams, extensionMono) = extensionMeth.info val origTpeParams = origMeth.typeParams ::: currentOwner.typeParams + println("expanding "+tree+"/"+allParams(extensionMono)+"/"+extensionMeth.info) val extensionBody = rhs .substTreeSyms(origTpeParams, extensionTpeParams) .substTreeSyms(vparamss.flatten map (_.symbol), allParams(extensionMono).tail) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 5f156b98e8..7bb9ab2fc9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -705,13 +705,6 @@ trait Namers extends MethodSynthesis { if (needsCycleCheck && !typer.checkNonCyclic(tree.pos, tp)) sym setInfo ErrorType } - tree match { - case cdef: ClassDef => - if (!treeInfo.isInterface(sym, cdef.impl.body) && sym != ArrayClass && - (sym.info.parents forall (_.typeSymbol != AnyValClass))) - ensureParent(sym, ScalaObjectClass) - case _ => - } } def moduleClassTypeCompleter(tree: Tree) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index f7a6815905..2a581b33bb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -150,7 +150,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } // Override checking ------------------------------------------------------------ - + def isJavaVarargsAncestor(clazz: Symbol) = ( clazz.isClass && clazz.isJavaDefined @@ -167,14 +167,14 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R log("Found java varargs ancestor in " + clazz.fullLocationString + ".") val self = clazz.thisType val bridges = new ListBuffer[Tree] - + def varargBridge(member: Symbol, bridgetpe: Type): Tree = { log("Generating varargs bridge for " + member.fullLocationString + " of type " + bridgetpe) - + val bridge = member.cloneSymbolImpl(clazz, member.flags | VBRIDGE) setPos clazz.pos bridge.setInfo(bridgetpe.cloneInfo(bridge)) clazz.info.decls enter bridge - + val params = bridge.paramss.head val elemtp = params.last.tpe.typeArgs.head val idents = params map Ident @@ -183,7 +183,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R localTyper typed DefDef(bridge, body) } - + // For all concrete non-private members that have a (Scala) repeated parameter: // compute the corresponding method type `jtpe` with a Java repeated parameter // if a method with type `jtpe` exists and that method is not a varargs bridge @@ -203,7 +203,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } } } - + bridges.toList } else Nil @@ -334,7 +334,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R def deferredCheck = member.isDeferred || !other.isDeferred def subOther(s: Symbol) = s isSubClass other.owner def subMember(s: Symbol) = s isSubClass member.owner - + if (subOther(member.owner) && deferredCheck) { //Console.println(infoString(member) + " shadows1 " + infoString(other) " in " + clazz);//DEBUG return @@ -420,12 +420,12 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R if( !(sameLength(member.typeParams, other.typeParams) && (memberTp.substSym(member.typeParams, other.typeParams) =:= otherTp)) ) // (1.6) overrideTypeError(); - } + } else if (other.isAbstractType) { //if (!member.typeParams.isEmpty) // (1.7) @MAT // overrideError("may not be parameterized"); val otherTp = self.memberInfo(other) - + if (!(otherTp.bounds containsType memberTp)) { // (1.7.1) overrideTypeError(); // todo: do an explaintypes with bounds here explainTypes(_.bounds containsType _, otherTp, memberTp) @@ -1527,7 +1527,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R ) case _ => () } - + // verify classes extending AnyVal meet the requirements // (whatever those are to be, but at least: @inline annotation) private def checkAnyValSubclass(clazz: Symbol) = { diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala deleted file mode 100644 index ed32fb7302..0000000000 --- a/src/library/scala/AnyVal.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -/** `AnyVal` is the root class of all ''value types'', which describe values - * not implemented as objects in the underlying host system. The value classes - * are specified in SLS 12.2. - * - * The standard implementation includes nine `AnyVal` subtypes: - * - * [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]], - * [[scala.Short]], and [[scala.Byte]] are the ''numeric value types''. - * - * [[scala.Unit]] and [[scala.Boolean]] are the ''non-numeric value types''. - * - * Other groupings: - * - * The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]]. - * The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]]. - * The ''floating point types'' are [[scala.Float]] and [[scala.Double]]. - */ -trait AnyVal extends 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] = ??? -} |