diff options
Diffstat (limited to 'src')
9 files changed, 45 insertions, 34 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 8bbf11650c..486a43614b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -42,10 +42,14 @@ trait BasicBlocks { private final class SuccessorList() { private var successors: List[BasicBlock] = Nil + /** This method is very hot! Handle with care. */ private def updateConserve() { - var lb: ListBuffer[BasicBlock] = null - var matches = 0 - var remaining = successors + var lb: ListBuffer[BasicBlock] = null + var matches = 0 + var remaining = successors + val direct = directSuccessors + var scratchHandlers: List[ExceptionHandler] = method.exh + var scratchBlocks: List[BasicBlock] = direct def addBlock(bb: BasicBlock) { if (matches < 0) @@ -60,25 +64,27 @@ trait BasicBlocks { } } - // exceptionSuccessors - method.exh foreach { handler => - if (handler covers outer) - addBlock(handler.startBlock) + while (scratchBlocks ne Nil) { + addBlock(scratchBlocks.head) + scratchBlocks = scratchBlocks.tail } - // directSuccessors - val direct = directSuccessors - direct foreach addBlock - /** Return a list of successors for 'b' that come from exception handlers * covering b's (non-exceptional) successors. These exception handlers * might not cover 'b' itself. This situation corresponds to an * exception being thrown as the first thing of one of b's successors. */ - method.exh foreach { handler => - direct foreach { block => - if (handler covers block) + while (scratchHandlers ne Nil) { + val handler = scratchHandlers.head + if (handler covers outer) + addBlock(handler.startBlock) + + scratchBlocks = direct + while (scratchBlocks ne Nil) { + if (handler covers scratchBlocks.head) addBlock(handler.startBlock) + scratchBlocks = scratchBlocks.tail } + scratchHandlers = scratchHandlers.tail } // Blocks did not align: create a new list. if (matches < 0) @@ -101,7 +107,7 @@ trait BasicBlocks { } /** Flags of this basic block. */ - private var flags: Int = 0 + private[this] var flags: Int = 0 /** Does this block have the given flag? */ def hasFlag(flag: Int): Boolean = (flags & flag) != 0 diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 1f68781777..24a26b2ad3 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -49,7 +49,11 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if(top === self) {{ var url = '{ val p = templateToPath(tpl); "../" * (p.size - 1) + "index.html" }'; var hash = '{ val p = templateToPath(tpl); (p.tail.reverse ::: List(p.head.replace(".html", ""))).mkString(".") }'; - window.location.href = url + '#' + hash; + var anchor = window.location.hash; + var anchor_opt = ''; + if (anchor.length { scala.xml.Unparsed(">=") /* unless we use Unparsed, it gets escaped and crashes the script */ } 1) + anchor_opt = '@' + anchor.substring(1); + window.location.href = url + '#' + hash + anchor_opt; }} </script> </xml:group> diff --git a/src/compiler/scala/tools/nsc/transform/LazyVals.scala b/src/compiler/scala/tools/nsc/transform/LazyVals.scala index e8387c80f5..12e2433e0d 100644 --- a/src/compiler/scala/tools/nsc/transform/LazyVals.scala +++ b/src/compiler/scala/tools/nsc/transform/LazyVals.scala @@ -111,7 +111,7 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD var added = false val stats = for (stat <- body1) yield stat match { - case Block(_, _) | Apply(_, _) | If(_, _, _) if !added => + case Block(_, _) | Apply(_, _) | If(_, _, _) | Try(_, _, _) if !added => // Avoid adding bitmaps when they are fully overshadowed by those // that are added inside loops if (LocalLazyValFinder.find(stat)) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index dbafd01ebc..01e773e528 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -588,7 +588,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { val nullaryArgsEmptyParams = exprArgs.isEmpty && macroDef.paramss == ListOfNil if (argcDoesntMatch && !nullaryArgsEmptyParams) { typer.TyperErrorGen.MacroPartialApplicationError(expandee) } - var argss: List[List[Any]] = exprArgs.toList + val argss: List[List[Any]] = exprArgs.toList macroTraceVerbose("context: ")(context) macroTraceVerbose("argss: ")(argss) @@ -597,9 +597,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { if (fastTrack(macroDef) validate context) argss else typer.TyperErrorGen.MacroPartialApplicationError(expandee) } else { - val binding = loadMacroImplBinding(macroDef) - macroTraceVerbose("binding: ")(binding) - // if paramss have typetag context bounds, add an arglist to argss if necessary and instantiate the corresponding evidences // consider the following example: // @@ -616,6 +613,8 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { // then T and U need to be inferred from the lexical scope of the call using `asSeenFrom` // whereas V won't be resolved by asSeenFrom and need to be loaded directly from `expandee` which needs to contain a TypeApply node // also, macro implementation reference may contain a regular type as a type argument, then we pass it verbatim + val binding = loadMacroImplBinding(macroDef) + macroTraceVerbose("binding: ")(binding) val tags = binding.signature filter (_ != -1) map (paramPos => { val targ = binding.targs(paramPos).tpe.typeSymbol val tpe = if (targ.isTypeParameterOrSkolem) { @@ -633,14 +632,13 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { targ.tpe if (tpe.isConcrete) context.TypeTag(tpe) else context.AbsTypeTag(tpe) }) - val hasImplicitParams = macroDef.paramss.flatten.lastOption exists (_.isImplicit) - argss = if (hasImplicitParams) argss.dropRight(1) :+ (tags ++ argss.last) else argss :+ tags + macroTraceVerbose("tags: ")(tags) // transforms argss taking into account varargness of paramss // note that typetag context bounds are only declared on macroImpls // so this optional arglist might not match macroDef's paramlist // nb! varargs can apply to any parameter section, not necessarily to the last one - mapWithIndex(argss)((as, i) => { + mapWithIndex(argss :+ tags)((as, i) => { val mapsToParamss = macroDef.paramss.indices contains i if (mapsToParamss) { val ps = macroDef.paramss(i) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 9201981635..166bb2d18c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1618,6 +1618,8 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R if ((clazz isSubClass AnyValClass) && !isPrimitiveValueClass(clazz)) { if (clazz.isTrait) unit.error(clazz.pos, "Only classes (not traits) are allowed to extend AnyVal") + else if ((clazz != AnyValClass) && clazz.hasFlag(ABSTRACT)) + unit.error(clazz.pos, "`abstract' modifier cannot be used with value classes") } } diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index ad882390c8..c9876c4d74 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -202,7 +202,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), Has def groupByKey[Repr](cbf: () => Combiner[V, Repr]): ParHashMap[K, Repr] = { val bucks = buckets.filter(_ != null).map(_.headPtr) val root = new Array[HashMap[K, AnyRef]](bucks.length) - + combinerTaskSupport.executeAndWaitResult(new CreateGroupedTrie(cbf, bucks, root, 0, bucks.length)) var bitmap = 0 @@ -306,8 +306,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), Has unrolled = unrolled.next } - evaluateCombiners(trie) - trie.asInstanceOf[HashMap[K, Repr]] + evaluateCombiners(trie).asInstanceOf[HashMap[K, Repr]] } private def evaluateCombiners(trie: HashMap[K, Combiner[V, Repr]]): HashMap[K, Repr] = trie match { case hm1: HashMap.HashMap1[_, _] => diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 7b6df6e31c..5255c44f10 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -64,6 +64,7 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial } object ClassTag { + private val NothingTYPE = classOf[scala.runtime.Nothing$] private val NullTYPE = classOf[scala.runtime.Null$] private val ObjectTYPE = classOf[java.lang.Object] @@ -80,13 +81,7 @@ object ClassTag { val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object } val AnyVal : ClassTag[scala.AnyVal] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyVal]] val AnyRef : ClassTag[scala.AnyRef] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyRef]] - val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ - def runtimeClass = throw new Exception("Nothing is a bottom type, therefore its erasure does not return a value") - private def readResolve() = ClassTag.Nothing - override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && (x.asInstanceOf[AnyRef] eq ClassTag.Nothing) - override def hashCode = System.identityHashCode(this) - override def toString = "ClassTag[Nothing]" - } + val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } def apply[T](runtimeClass1: jClass[_]): ClassTag[T] = diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index 9e7b3c9712..0c4f143d57 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -59,6 +59,9 @@ trait Symbols extends base.Symbols { self: Universe => */ def typeSignature: Type + /** Returns all symbols overriden by this symbol. */ + def allOverriddenSymbols: List[Symbol] + /******************* tests *******************/ /** Does this symbol represent a synthetic (i.e. a compiler-generated) entity? diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index ebaedd7ac3..bdcaadfbda 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -66,6 +66,10 @@ trait Types extends base.Types { self: Universe => /** Does this type conform to given type argument `that`? */ def <:< (that: Type): Boolean + /** Is this type a weak subtype of that type? True also for numeric types, i.e. Int weak_<:< Long. + */ + def weak_<:<(that: Type): Boolean + /** Is this type equivalent to given type argument `that`? */ def =:= (that: Type): Boolean |