diff options
Diffstat (limited to 'src')
154 files changed, 957 insertions, 681 deletions
diff --git a/src/compiler/scala/reflect/internal/AnnotationInfos.scala b/src/compiler/scala/reflect/internal/AnnotationInfos.scala index 085537fc9f..5bdd04e544 100644 --- a/src/compiler/scala/reflect/internal/AnnotationInfos.scala +++ b/src/compiler/scala/reflect/internal/AnnotationInfos.scala @@ -18,8 +18,6 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable => // the Symbol's field directly. For Type, a new AnnotatedType is // created which wraps the original type. trait Annotatable[Self] { - self: Self => - /** The annotations on this type. */ def annotations: List[AnnotationInfo] // Annotations on this type. def setAnnotations(annots: List[AnnotationInfo]): Self // Replace annotations with argument list. diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 1c3e11b040..0612dcdfd4 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -896,6 +896,7 @@ trait Definitions extends reflect.api.StandardDefinitions { // boxed classes lazy val ObjectRefClass = requiredClass[scala.runtime.ObjectRef[_]] lazy val VolatileObjectRefClass = requiredClass[scala.runtime.VolatileObjectRef[_]] + lazy val RuntimeStaticsModule = getRequiredModule("scala.runtime.Statics") lazy val BoxesRunTimeModule = getRequiredModule("scala.runtime.BoxesRunTime") lazy val BoxesRunTimeClass = BoxesRunTimeModule.moduleClass lazy val BoxedNumberClass = getClass(sn.BoxedNumber) @@ -1206,7 +1207,7 @@ trait Definitions extends reflect.api.StandardDefinitions { def isPrimitiveValueClass(sym: Symbol) = ScalaValueClasses contains sym def isNonUnitValueClass(sym: Symbol) = isPrimitiveValueClass(sym) && (sym != UnitClass) def isSpecializableClass(sym: Symbol) = isPrimitiveValueClass(sym) || (sym == AnyRefClass) - def isScalaValueType(tp: Type) = ScalaValueClasses contains tp.typeSymbol + def isPrimitiveValueType(tp: Type) = isPrimitiveValueClass(tp.typeSymbol) /** Is symbol a boxed value class, e.g. java.lang.Integer? */ def isBoxedValueClass(sym: Symbol) = boxedValueClassesSet(sym) diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 0cdf65bd8f..bd4d9a9f34 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -766,7 +766,6 @@ trait StdNames { object fulltpnme extends TypeNames { val RuntimeNothing: NameType = "scala.runtime.Nothing$" val RuntimeNull: NameType = "scala.runtime.Null$" - val JavaLangEnum: NameType = "java.lang.Enum" } /** Java binary names, like scala/runtime/Nothing$. diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 2a5b759f94..240dedc658 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -2088,7 +2088,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** String representation of symbol's definition key word */ final def keyString: String = if (isJavaInterface) "interface" - else if (isTrait) "trait" + else if (isTrait && !isImplClass) "trait" else if (isClass) "class" else if (isType && !isParameter) "type" else if (isVariable) "var" @@ -2116,6 +2116,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => else if (isSetter) ("setter", if (isSourceMethod) "method" else "value", "SET") else if (isTerm && isLazy) ("lazy value", "lazy value", "LAZ") else if (isVariable) ("field", "variable", "VAR") + else if (isImplClass) ("implementation class", "class", "IMPL") else if (isTrait) ("trait", "trait", "TRT") else if (isClass) ("class", "class", "CLS") else if (isType) ("type", "type", "TPE") @@ -2232,7 +2233,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => } def infosString = infos.toString - def debugLocationString = fullLocationString + " " + debugFlagString + def debugLocationString = fullLocationString + " (flags: " + debugFlagString + ")" private def defStringCompose(infoString: String) = compose( flagString, @@ -3053,7 +3054,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def originalEnclosingMethod = this override def owner: Symbol = - abort("no-symbol does not have an owner (this is a bug: scala " + scala.util.Properties.versionString + ")") + abort("no-symbol does not have an owner") override def typeConstructor: Type = abort("no-symbol does not have a type constructor (this may indicate scalac cannot find fundamental classes)") } diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala index 2251310f35..1528061adb 100644 --- a/src/compiler/scala/reflect/internal/TreeInfo.scala +++ b/src/compiler/scala/reflect/internal/TreeInfo.scala @@ -221,9 +221,29 @@ abstract class TreeInfo { case _ => false } + /** + * Named arguments can transform a constructor call into a block, e.g. + * <init>(b = foo, a = bar) + * is transformed to + * { val x$1 = foo + * val x$2 = bar + * <init>(x$2, x$1) + * } + */ + def stripNamedApplyBlock(tree: Tree) = tree match { + case Block(stats, expr) if stats.forall(_.isInstanceOf[ValDef]) => + expr + case _ => + tree + } + /** Is tree a self or super constructor call? */ - def isSelfOrSuperConstrCall(tree: Tree) = - isSelfConstrCall(tree) || isSuperConstrCall(tree) + def isSelfOrSuperConstrCall(tree: Tree) = { + // stripNamedApply for SI-3584: adaptToImplicitMethod in Typers creates a special context + // for implicit search in constructor calls, adaptToImplicitMethod(isSelfOrConstrCall) + val tree1 = stripNamedApplyBlock(tree) + isSelfConstrCall(tree1) || isSuperConstrCall(tree1) + } /** Is tree a variable pattern? */ def isVarPattern(pat: Tree): Boolean = pat match { diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index e2d9310424..3e7f23800c 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -145,11 +145,12 @@ trait Trees extends api.Trees { self: SymbolTable => */ def summaryString: String = tree match { case Literal(const) => "Literal(" + const + ")" - case Select(qual, name) => qual.summaryString + "." + name.decode + case Ident(name) => "Ident(%s)".format(name.decode) + case Select(qual, name) => "Select(%s, %s)".format(qual.summaryString, name.decode) case t: NameTree => t.name.longString case t => t.shortClass + ( - if (t.symbol != null && t.symbol != NoSymbol) " " + t.symbol + if (t.symbol != null && t.symbol != NoSymbol) "(" + t.symbol + ")" else "" ) } diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 09e7303b90..808198598b 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -2663,6 +2663,10 @@ trait Types extends api.Types { self: SymbolTable => override def kind = "OverloadedType" } + def overloadedType(pre: Type, alternatives: List[Symbol]): Type = + if (alternatives.tail.isEmpty) pre memberType alternatives.head + else OverloadedType(pre, alternatives) + /** A class remembering a type instantiation for some a set of overloaded * polymorphic symbols. * Not used after phase `typer`. @@ -3064,7 +3068,8 @@ trait Types extends api.Types { self: SymbolTable => } def registerTypeEquality(tp: Type, typeVarLHS: Boolean): Boolean = { - //println("regTypeEq: "+(safeToString, debugString(tp), typeVarLHS)) //@MDEBUG +// println("regTypeEq: "+(safeToString, debugString(tp), tp.getClass, if (typeVarLHS) "in LHS" else "in RHS", if (suspended) "ZZ" else if (constr.instValid) "IV" else "")) //@MDEBUG +// println("constr: "+ constr) def checkIsSameType(tp: Type) = if(typeVarLHS) constr.inst =:= tp else tp =:= constr.inst @@ -3123,7 +3128,7 @@ trait Types extends api.Types { self: SymbolTable => } def originName = { val name = origin.typeSymbolDirect.decodedName - if (name contains "_$") origin.typeSymbolDirect.decodedName else name + if (name contains "_$") origin.typeSymbolDirect.decodedName else name // wait, what? - what? } def originLocation = { val sym = origin.typeSymbolDirect @@ -3142,7 +3147,7 @@ trait Types extends api.Types { self: SymbolTable => protected def typeVarString = originName override def safeToString = ( if ((constr eq null) || (constr.inst eq null)) "TVar<" + originName + "=null>" - else if (constr.inst ne NoType) "" + constr.inst + else if (constr.inst ne NoType) "=?" + constr.inst else (if(untouchable) "!?" else "?") + levelString + originName ) override def kind = "TypeVar" @@ -4921,7 +4926,23 @@ trait Types extends api.Types { self: SymbolTable => override def hashCode = tp1.hashCode * 41 + tp2.hashCode override def equals(other: Any) = other match { case stp: SubTypePair => - (tp1 =:= stp.tp1) && (tp2 =:= stp.tp2) + // suspend TypeVars in types compared by =:=, + // since we don't want to mutate them simply to check whether a subtype test is pending + // in addition to making subtyping "more correct" for type vars, + // it should avoid the stackoverflow that's been plaguing us (https://groups.google.com/d/topic/scala-internals/2gHzNjtB4xA/discussion) + // this method is only called when subtyping hits a recursion threshold (subsametypeRecursions >= LogPendingSubTypesThreshold) + @inline def suspend(tp: Type) = + if (tp.isGround) null else suspendTypeVarsInType(tp) + @inline def revive(suspension: List[TypeVar]) = + if (suspension ne null) suspension foreach (_.suspended = false) + + val suspensions = Array(tp1, stp.tp1, tp2, stp.tp2) map suspend + + val sameTypes = (tp1 =:= stp.tp1) && (tp2 =:= stp.tp2) + + suspensions foreach revive + + sameTypes case _ => false } diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/compiler/scala/reflect/internal/transform/Erasure.scala index 1b323f839b..5beec70d62 100644 --- a/src/compiler/scala/reflect/internal/transform/Erasure.scala +++ b/src/compiler/scala/reflect/internal/transform/Erasure.scala @@ -17,7 +17,14 @@ trait Erasure { * with primitive as well as class types)?. */ private def genericCore(tp: Type): Type = tp.normalize match { - case TypeRef(_, sym, _) if sym.isAbstractType && !sym.owner.isJavaDefined => + /* A Java Array<T> is erased to Array[Object] (T can only be a reference type), where as a Scala Array[T] is + * erased to Object. However, there is only symbol for the Array class. So to make the distinction between + * a Java and a Scala array, we check if the owner of T comes from a Java class. + * This however caused issue SI-5654. The additional test for EXSITENTIAL fixes it, see the ticket comments. + * In short, members of an existential type (e.g. `T` in `forSome { type T }`) can have pretty arbitrary + * owners (e.g. when computing lubs, <root> is used). All packageClass symbols have `isJavaDefined == true`. + */ + case TypeRef(_, sym, _) if sym.isAbstractType && (!sym.owner.isJavaDefined || sym.hasFlag(Flags.EXISTENTIAL)) => tp case ExistentialType(tparams, restp) => genericCore(restp) diff --git a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala index eb384f9a85..1424226042 100644 --- a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -7,7 +7,7 @@ trait TraceSymbolActivity { val global: SymbolTable import global._ - if (traceSymbolActivity) + if (traceSymbolActivity && !global.inReflexiveMirror) scala.sys addShutdownHook showAllSymbols() private type Set[T] = scala.collection.immutable.Set[T] diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 599936f6f8..85bb5f2056 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -9,10 +9,19 @@ ############################################################################## findScalaHome () { - # see #2092 + # see SI-2092 local SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done - ( cd -P "$( dirname "$SOURCE" )"/.. && pwd ) + local bindir="$( dirname "$SOURCE" )" + if [[ -d "$bindir"/.. ]]; then + ( cd -P "$bindir"/.. && pwd ) + else + # See SI-5792 + local dir=$(dirname "${BASH_SOURCE[0]}") + local link=$(dirname "$(readlink "${BASH_SOURCE[0]}")") + local path="$dir/$link/.." + ( cd "$path" && pwd ) + fi } execCommand () { [[ -n $SCALA_RUNNER_DEBUG ]] && echo "" && for arg in "$@@"; do echo "$arg"; done && echo ""; diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index d3564017f9..49a644ba3a 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -130,7 +130,28 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb object nodePrinters extends { val global: Global.this.type = Global.this } with NodePrinters { + var lastPrintedPhase: Phase = NoPhase + var lastPrintedSource: String = "" infolevel = InfoLevel.Verbose + + def showUnit(unit: CompilationUnit) { + print(" // " + unit.source) + if (unit.body == null) println(": tree is null") + else { + val source = util.stringFromWriter(w => newTreePrinter(w) print unit.body) + + // treePrinter show unit.body + if (lastPrintedSource == source) + println(": tree is unchanged since " + lastPrintedPhase) + else { + lastPrintedPhase = phase.prev // since we're running inside "afterPhase" + lastPrintedSource = source + println("") + println(source) + println("") + } + } + } } def withInfoLevel[T](infolevel: nodePrinters.InfoLevel.Value)(op: => T) = { @@ -162,7 +183,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb /** Register new context; called for every created context */ - def registerContext(c: analyzer.Context) {} + def registerContext(c: analyzer.Context) { + lastSeenContext = c + } /** Register top level class (called on entering the class) */ @@ -894,6 +917,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb curRun = null } + object typeDeconstruct extends { + val global: Global.this.type = Global.this + } with interpreter.StructuredTypeStrings + /** There are common error conditions where when the exception hits * here, currentRun.currentUnit is null. This robs us of the knowledge * of what file was being compiled when it broke. Since I really @@ -901,6 +928,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb */ private var lastSeenSourceFile: SourceFile = NoSourceFile + /** Let's share a lot more about why we crash all over the place. + * People will be very grateful. + */ + private var lastSeenContext: analyzer.Context = null + /** The currently active run */ def currentRun: Run = curRun @@ -929,25 +961,64 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb @inline final def beforeTyper[T](op: => T): T = beforePhase(currentRun.typerPhase)(op) @inline final def beforeUncurry[T](op: => T): T = beforePhase(currentRun.uncurryPhase)(op) + def explainContext(c: analyzer.Context): String = ( + if (c == null) "" else ( + """| context owners: %s + | + |Enclosing block or template: + |%s""".format( + c.owner.ownerChain.takeWhile(!_.isPackageClass).mkString(" -> "), + nodePrinters.nodeToString(c.enclClassOrMethod.tree) + ) + ) + ) + // Owners up to and including the first package class. + private def ownerChainString(sym: Symbol): String = ( + if (sym == null) "" + else sym.ownerChain.span(!_.isPackageClass) match { + case (xs, pkg :: _) => (xs :+ pkg) mkString " -> " + case _ => sym.ownerChain mkString " -> " // unlikely + } + ) + private def formatExplain(pairs: (String, Any)*): String = ( + pairs.toList collect { case (k, v) if v != null => "%20s: %s".format(k, v) } mkString "\n" + ) + + def explainTree(t: Tree): String = formatExplain( + ) + /** Don't want to introduce new errors trying to report errors, * so swallow exceptions. */ override def supplementErrorMessage(errorMessage: String): String = try { - """| - | while compiling: %s - | current phase: %s - | library version: %s - | compiler version: %s - | reconstructed args: %s - | - |%s""".stripMargin.format( - currentSource.path, - phase, - scala.util.Properties.versionString, - Properties.versionString, - settings.recreateArgs.mkString(" "), - if (opt.debug) "Current unit body:\n" + currentUnit.body + "\n" + errorMessage else errorMessage + val tree = analyzer.lastTreeToTyper + val sym = tree.symbol + val tpe = tree.tpe + val enclosing = lastSeenContext.enclClassOrMethod.tree + + val info1 = formatExplain( + "while compiling" -> currentSource.path, + "during phase" -> phase, + "library version" -> scala.util.Properties.versionString, + "compiler version" -> Properties.versionString, + "reconstructed args" -> settings.recreateArgs.mkString(" ") + ) + val info2 = formatExplain( + "last tree to typer" -> tree.summaryString, + "symbol" -> Option(sym).fold("null")(_.debugLocationString), + "symbol definition" -> Option(sym).fold("null")(_.defString), + "tpe" -> tpe, + "symbol owners" -> ownerChainString(sym), + "context owners" -> ownerChainString(lastSeenContext.owner) + ) + val info3: List[String] = ( + ( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) ) + ++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) ) + ++ ( if (!opt.debug) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) ) + ++ ( List(errorMessage) ) ) + + ("\n" + info1) :: info2 :: info3 mkString "\n\n" } catch { case x: Exception => errorMessage } @@ -1538,8 +1609,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb } // class Run def printAllUnits() { - print("[[syntax trees at end of " + phase + "]]") - afterPhase(phase) { currentRun.units foreach (treePrinter.print(_)) } + print("[[syntax trees at end of %25s]]".format(phase)) + afterPhase(phase)(currentRun.units foreach { unit => + nodePrinters showUnit unit + }) } /** We resolve the class/object ambiguity by passing a type/term name. diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index a93d9efded..23fcffd657 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -236,7 +236,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { mkMethodCall( PredefModule, wrapArrayMethodName(elemtp), - if (isScalaValueType(elemtp)) Nil else List(elemtp), + if (isPrimitiveValueType(elemtp)) Nil else List(elemtp), List(tree) ) } @@ -261,7 +261,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { * elem type elemtp to expected type pt. */ def mkCastArray(tree: Tree, elemtp: Type, pt: Type) = - if (elemtp.typeSymbol == AnyClass && isScalaValueType(tree.tpe.typeArgs.head)) + if (elemtp.typeSymbol == AnyClass && isPrimitiveValueType(tree.tpe.typeArgs.head)) mkCast(mkRuntimeCall(nme.toObjectArray, List(tree)), pt) else mkCast(tree, pt) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 4aeb537f9b..f7541a4739 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1208,7 +1208,7 @@ abstract class GenICode extends SubComponent { if (!tree.symbol.isPackageClass) tree.symbol else tree.symbol.info.member(nme.PACKAGE) match { case NoSymbol => assert(false, "Cannot use package as value: " + tree) ; NoSymbol - case s => Console.err.println("Bug: found package class where package object expected. Converting.") ; s.moduleClass + case s => debugwarn("Bug: found package class where package object expected. Converting.") ; s.moduleClass } ) debuglog("LOAD_MODULE from %s: %s".format(tree.shortClass, sym)) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index aa8f469513..225afaf0fb 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -274,8 +274,10 @@ abstract class GenASM extends SubComponent with BytecodeWriters { // we can exclude lateFINAL. Such symbols are eligible for inlining, but to
// avoid breaking proxy software which depends on subclassing, we do not
// emit ACC_FINAL.
+ // Nested objects won't receive ACC_FINAL in order to allow for their overloading.
+
val finalFlag = (
- ((sym.rawflags & (Flags.FINAL | Flags.MODULE)) != 0)
+ (sym.hasFlag(Flags.FINAL) || isTopLevelModule(sym))
&& !sym.enclClass.isInterface
&& !sym.isClassConstructor
&& !sym.isMutable // lazy vals and vars both
@@ -649,8 +651,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { val INNER_CLASSES_FLAGS =
(asm.Opcodes.ACC_PUBLIC | asm.Opcodes.ACC_PRIVATE | asm.Opcodes.ACC_PROTECTED |
- asm.Opcodes.ACC_STATIC | asm.Opcodes.ACC_FINAL |
- asm.Opcodes.ACC_INTERFACE | asm.Opcodes.ACC_ABSTRACT)
+ asm.Opcodes.ACC_STATIC | asm.Opcodes.ACC_INTERFACE | asm.Opcodes.ACC_ABSTRACT)
val PublicStatic = asm.Opcodes.ACC_PUBLIC | asm.Opcodes.ACC_STATIC
val PublicStaticFinal = asm.Opcodes.ACC_PUBLIC | asm.Opcodes.ACC_STATIC | asm.Opcodes.ACC_FINAL
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 042e739abe..b5ce7588f6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -191,7 +191,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val MIN_SWITCH_DENSITY = 0.7 val INNER_CLASSES_FLAGS = - (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT) + (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_INTERFACE | ACC_ABSTRACT) val PublicStatic = ACC_PUBLIC | ACC_STATIC val PublicStaticFinal = ACC_PUBLIC | ACC_STATIC | ACC_FINAL @@ -1159,6 +1159,27 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with */ def generateMirrorClass(clasz: Symbol, sourceFile: SourceFile) { import JAccessFlags._ + /* We need to save inner classes buffer and create a new one to make sure + * that we do confuse inner classes of the class we mirror with inner + * classes of the class we are mirroring. These two sets can be different + * as seen in this case: + * + * class A { + * class B + * def b: B = new B + * } + * object C extends A + * + * Here mirror class of C has a static forwarder for (inherited) method `b` + * therefore it refers to class `B` and needs InnerClasses entry. However, + * the real class for `C` (named `C$`) is empty and does not refer to `B` + * thus does not need InnerClasses entry it. + * + * NOTE: This logic has been refactored in GenASM and everything is + * implemented in a much cleaner way by having two separate buffers. + */ + val savedInnerClasses = innerClassBuffer + innerClassBuffer = mutable.LinkedHashSet[Symbol]() val moduleName = javaName(clasz) // + "$" val mirrorName = moduleName.substring(0, moduleName.length() - 1) val mirrorClass = fjbgContext.JClass(ACC_SUPER | ACC_PUBLIC | ACC_FINAL, @@ -1172,6 +1193,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val ssa = scalaSignatureAddingMarker(mirrorClass, clasz.companionSymbol) addAnnotations(mirrorClass, clasz.annotations ++ ssa) emitClass(mirrorClass, clasz) + innerClassBuffer = savedInnerClasses } var linearization: List[BasicBlock] = Nil @@ -1954,8 +1976,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with // we can exclude lateFINAL. Such symbols are eligible for inlining, but to // avoid breaking proxy software which depends on subclassing, we do not // emit ACC_FINAL. + // Nested objects won't receive ACC_FINAL in order to allow for their overloading. + val finalFlag = ( - ((sym.rawflags & (Flags.FINAL | Flags.MODULE)) != 0) + (sym.hasFlag(Flags.FINAL) || isTopLevelModule(sym)) && !sym.enclClass.isInterface && !sym.isClassConstructor && !sym.isMutable // lazy vals and vars both diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index 61f3670f5f..c3525037cd 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -179,7 +179,7 @@ trait ModelFactoryImplicitSupport { hardcoded.arraySkipConversions.contains(conv.conversionQualifiedName)) // Filter out non-sensical conversions from value types - if (isScalaValueType(sym.tpe)) + if (isPrimitiveValueType(sym.tpe)) conversions = conversions.filter((ic: ImplicitConversion) => hardcoded.valueClassFilter(sym.nameString, ic.conversionQualifiedName)) diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index ec73af4dca..edf0108e58 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -352,6 +352,10 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") case item: WorkItem => Some(item.raiseMissing()) case _ => Some(()) } + + // don't forget to service interrupt requests + val iqs = scheduler.dequeueAllInterrupts(_.execute()) + debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size)) debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)" .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size)) @@ -926,7 +930,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") val implicitlyAdded = viaView != NoSymbol members.add(sym, pre, implicitlyAdded) { (s, st) => new TypeMember(s, st, - context.isAccessible(s, pre, superAccess && !implicitlyAdded), + context.isAccessible(if (s.hasGetter) s.getter(s.owner) else s, pre, superAccess && !implicitlyAdded), inherited, viaView) } diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala index 72e5ee42ed..49ba9d0aeb 100644 --- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala @@ -269,7 +269,8 @@ self: scala.tools.nsc.Global => protected def isEligible(t: Tree) = !t.pos.isTransparent override def traverse(t: Tree) { t match { - case tt : TypeTree if tt.original != null => traverse(tt.original) + case tt : TypeTree if tt.original != null && (tt.pos includes tt.original.pos) => + traverse(tt.original) case _ => if (t.pos includes pos) { if (isEligible(t)) last = t diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/FindOccurrences.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/FindOccurrences.scala deleted file mode 100644 index e2a5a3e3ee..0000000000 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/FindOccurrences.scala +++ /dev/null @@ -1,28 +0,0 @@ -package scala.tools.nsc -package interactive -package tests.core - -import scala.tools.nsc.util.Position -import scala.tools.nsc.util.SourceFile - -/** Find occurrences of `text` in the passed `sources`. */ -private[core] object FindOccurrences { - - def apply(sources: Seq[SourceFile])(text: String): Map[SourceFile, Seq[Position]] = - allPositionsOf(sources, text) - - /** All positions of the given string in all source files. */ - private def allPositionsOf(sources: Seq[SourceFile], str: String): Map[SourceFile, Seq[Position]] = - (for (s <- sources; p <- positionsOf(s, str)) yield p).groupBy(_.source) - - /** Return all positions of the given str in the given source file. */ - private def positionsOf(source: SourceFile, str: String): Seq[Position] = { - val buf = new collection.mutable.ListBuffer[Position] - var pos = source.content.indexOfSlice(str) - while (pos >= 0) { - buf += source.position(pos - 1) // we need the position before the first character of this marker - pos = source.content.indexOfSlice(str, pos + 1) - } - buf.toList - } -}
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala index c274e13976..d2baaf32c6 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala @@ -16,7 +16,7 @@ trait PresentationCompilerRequestsWorkingMode extends TestResources { * ask the type at all positions marked with `TypeMarker.marker` and println the result. */ private def askAllSourcesAsync[T](marker: TestMarker)(askAt: Position => Response[T])(f: (Position, T) => Unit) { - val positions = allPositionsOf(marker.marker).valuesIterator.toList.flatten + val positions = allPositionsOf(str = marker.marker) val responses = for (pos <- positions) yield askAt(pos) for ((pos, r) <- positions zip responses) withResponse(pos, r)(f) @@ -26,13 +26,25 @@ trait PresentationCompilerRequestsWorkingMode extends TestResources { * response before going to the next one. */ private def askAllSourcesSync[T](marker: TestMarker)(askAt: Position => Response[T])(f: (Position, T) => Unit) { - val positions = allPositionsOf(marker.marker).valuesIterator.toList.flatten + val positions = allPositionsOf(str = marker.marker) for (pos <- positions) withResponse(pos, askAt(pos))(f) } - private def allPositionsOf: String => Map[SourceFile, Seq[Position]] = - FindOccurrences(sourceFiles) _ - + /** All positions of the given string in all source files. */ + private def allPositionsOf(srcs: Seq[SourceFile] = sourceFiles, str: String): Seq[Position] = + for (s <- srcs; p <- positionsOf(s, str)) yield p + + /** Return all positions of the given str in the given source file. */ + private def positionsOf(source: SourceFile, str: String): Seq[Position] = { + val buf = new collection.mutable.ListBuffer[Position] + var pos = source.content.indexOfSlice(str) + while (pos >= 0) { + buf += source.position(pos - 1) // we need the position before the first character of this marker + pos = source.content.indexOfSlice(str, pos + 1) + } + buf.toList + } + private def withResponse[T](pos: Position, response: Response[T])(f: (Position, T) => Unit) { /** Return the filename:line:col version of this position. */ def showPos(pos: Position): String = diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala index 518cb7bd76..21e90fe57f 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala @@ -13,7 +13,7 @@ private[tests] object SourcesCollector { * */ def apply(base: Path, filter: SourceFilter): Array[SourceFile] = { assert(base.isDirectory) - base.walk.filter(filter).map(source).toArray + base.walk.filter(filter).map(source).toList.toArray.sortBy(_.file.name) } private def source(file: Path): SourceFile = source(AbstractFile.getFile(file.toFile)) diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 5c413243e8..f71e067366 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -872,7 +872,10 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { skipAhead() accept(RBRACE) } - ValDef(Modifiers(Flags.JAVA | Flags.STATIC), name, enumType, blankExpr) + // The STABLE flag is to signal to namer that this was read from a + // java enum, and so should be given a Constant type (thereby making + // it usable in annotations.) + ValDef(Modifiers(Flags.STABLE | Flags.JAVA | Flags.STATIC), name, enumType, blankExpr) } } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 9e7e4b3f4f..3de287e58c 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -480,16 +480,22 @@ abstract class Erasure extends AddInterfaces // TODO: should we do this for user-defined unapplies as well? // does the first argument list have exactly one argument -- for user-defined unapplies we can't be sure def maybeWrap(bridgingCall: Tree): Tree = { - val canReturnNone = ( // can't statically know which member is going to be selected, so don't let this depend on member.isSynthetic + val guardExtractor = ( // can't statically know which member is going to be selected, so don't let this depend on member.isSynthetic (member.name == nme.unapply || member.name == nme.unapplySeq) && !afterErasure((member.tpe <:< other.tpe))) // no static guarantees (TODO: is the subtype test ever true?) - if (canReturnNone) { - import CODE._ + import CODE._ + val _false = FALSE_typed + val pt = member.tpe.resultType + lazy val zero = + if (_false.tpe <:< pt) _false + else if (NoneModule.tpe <:< pt) REF(NoneModule) + else EmptyTree + + if (guardExtractor && (zero ne EmptyTree)) { val typeTest = gen.mkIsInstanceOf(REF(bridge.firstParam), member.tpe.params.head.tpe) - IF (typeTest) THEN bridgingCall ELSE REF(NoneModule) - } - else bridgingCall + IF (typeTest) THEN bridgingCall ELSE zero + } else bridgingCall } val rhs = member.tpe match { case MethodType(Nil, ConstantType(c)) => Literal(c) @@ -619,7 +625,7 @@ abstract class Erasure extends AddInterfaces tree.duplicate setType pt } else if (tree.tpe != null && tree.tpe.typeSymbol == ArrayClass && pt.typeSymbol == ArrayClass) { // See SI-2386 for one example of when this might be necessary. - val needsExtraCast = isScalaValueType(tree.tpe.typeArgs.head) && !isScalaValueType(pt.typeArgs.head) + val needsExtraCast = isPrimitiveValueType(tree.tpe.typeArgs.head) && !isPrimitiveValueType(pt.typeArgs.head) val tree1 = if (needsExtraCast) gen.mkRuntimeCall(nme.toObjectArray, List(tree)) else tree gen.mkAttributedCast(tree1, pt) } else gen.mkAttributedCast(tree, pt) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 4ce5985af8..79b9317f20 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -903,14 +903,14 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { if (sym.isLazy && !isEmpty && !clazz.isImplClass) { assert(fieldOffset contains sym, sym) - deriveDefDef(stat)(rhs => - if (isUnit) - mkLazyDef(clazz, sym, List(rhs), UNIT, fieldOffset(sym)) - else { - val Block(stats, res) = rhs + deriveDefDef(stat) { + case t if isUnit => mkLazyDef(clazz, sym, List(t), UNIT, fieldOffset(sym)) + + case Block(stats, res) => mkLazyDef(clazz, sym, stats, Select(This(clazz), res.symbol), fieldOffset(sym)) - } - ) + + case t => t // pass specialized lazy vals through + } } else if (needsInitFlag(sym) && !isEmpty && !clazz.hasFlag(IMPLCLASS | TRAIT)) { assert(fieldOffset contains sym, sym) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index e0f34b47c8..07a10ecb1f 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -67,7 +67,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { import definitions.{ RootClass, BooleanClass, UnitClass, ArrayClass, - ScalaValueClasses, isPrimitiveValueClass, isScalaValueType, + ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType, SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule, GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass } @@ -145,7 +145,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { def includes(t1: TypeEnv, t2: TypeEnv) = t1 forall { case (sym, tpe) => t2 get sym exists { t2tp => - (tpe == t2tp) || !(isScalaValueType(tpe) || isScalaValueType(t2tp)) // u.t.b. (t2tp <:< AnyRefClass.tpe) + (tpe == t2tp) || !(isPrimitiveValueType(tpe) || isPrimitiveValueType(t2tp)) // u.t.b. (t2tp <:< AnyRefClass.tpe) } } @@ -266,7 +266,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { * specialized type. */ def survivingArgs(sym: Symbol, args: List[Type]): List[Type] = - for ((tvar, tpe) <- sym.info.typeParams.zip(args) if !tvar.isSpecialized || !isScalaValueType(tpe)) + for ((tvar, tpe) <- sym.info.typeParams.zip(args) if !tvar.isSpecialized || !isPrimitiveValueType(tpe)) yield tpe val specializedType = new TypeMap { @@ -448,7 +448,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Type parameters that survive when specializing in the specified environment. */ def survivingParams(params: List[Symbol], env: TypeEnv) = - params.filter(p => !p.isSpecialized || !isScalaValueType(env(p))) + params.filter(p => !p.isSpecialized || !isPrimitiveValueType(env(p))) /** Produces the symbols from type parameters `syms` of the original owner, * in the given type environment `env`. The new owner is `nowner`. @@ -666,16 +666,19 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { // log("other concrete " + m) forwardToOverload(m) - } else if (m.isValue && !m.isMethod) { // concrete value definition + } else if (m.isMethod && m.hasFlag(LAZY)) { + forwardToOverload(m) + + } else if (m.isValue && !m.isMethod && !m.hasFlag(LAZY)) { // concrete value definition def mkAccessor(field: Symbol, name: Name) = { - val newFlags = (SPECIALIZED | m.getter(clazz).flags) & ~(LOCAL | CASEACCESSOR | PARAMACCESSOR | LAZY) + val newFlags = (SPECIALIZED | m.getter(clazz).flags) & ~(LOCAL | CASEACCESSOR | PARAMACCESSOR) // we rely on the super class to initialize param accessors val sym = sClass.newMethod(name, field.pos, newFlags) info(sym) = SpecializedAccessor(field) sym } def overrideIn(clazz: Symbol, sym: Symbol) = { - val newFlags = (sym.flags | OVERRIDE | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | PARAMACCESSOR | LAZY) + val newFlags = (sym.flags | OVERRIDE | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | PARAMACCESSOR) val sym1 = sym.cloneSymbol(clazz, newFlags) sym1 modifyInfo (_ asSeenFrom (clazz.tpe, sym1.owner)) } @@ -881,7 +884,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Return the specialized overload of `m`, in the given environment. */ private def specializedOverload(owner: Symbol, sym: Symbol, env: TypeEnv): Symbol = { - val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | ACCESSOR | LAZY) + val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR) // this method properly duplicates the symbol's info ( sym.cloneSymbol(owner, newFlags, specializedName(sym, env)) modifyInfo (info => subst(env, info.asSeenFrom(owner.thisType, sym.owner))) @@ -1322,7 +1325,15 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { else None } else None } - + + def reportError[T](body: =>T)(handler: TypeError => T): T = + try body + catch { + case te: TypeError => + reporter.error(tree.pos, te.msg) + handler(te) + } + curTree = tree tree match { case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) => @@ -1331,11 +1342,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { if (found.typeSymbol ne tpt.tpe.typeSymbol) { // the ctor can be specialized debuglog("** instantiated specialized type: " + found) - try localTyper.typedPos(tree.pos)(New(found, transformTrees(args): _*)) - catch { - case te: TypeError => - reporter.error(tree.pos, te.msg) - super.transform(tree) + reportError { + localTyper.typedPos(tree.pos)(New(found, transformTrees(args): _*)) + } { + _ => super.transform(tree) } } else super.transform(tree) @@ -1493,13 +1503,21 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { }) debuglog("created special overload tree " + t) debuglog("created " + t) - localTyper.typed(t) + reportError { + localTyper.typed(t) + } { + _ => super.transform(tree) + } case fwd @ Forward(_) => debuglog("forward: " + fwd + ", " + ddef) val rhs1 = forwardCall(tree.pos, gen.mkAttributedRef(symbol.owner.thisType, fwd.target), vparamss) debuglog("-->d completed forwarder to specialized overload: " + fwd.target + ": " + rhs1) - localTyper.typed(deriveDefDef(tree)(_ => rhs1)) + reportError { + localTyper.typed(deriveDefDef(tree)(_ => rhs1)) + } { + _ => super.transform(tree) + } case SpecializedAccessor(target) => val rhs1 = if (symbol.isGetter) @@ -1573,7 +1591,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { // val (_, origtparams) = splitParams(source.typeParams) val env = typeEnv(symbol) val boundTvars = env.keySet - val origtparams = source.typeParams.filter(tparam => !boundTvars(tparam) || !isScalaValueType(env(tparam))) + val origtparams = source.typeParams.filter(tparam => !boundTvars(tparam) || !isPrimitiveValueType(env(tparam))) if (origtparams.nonEmpty || symbol.typeParams.nonEmpty) debuglog("substituting " + origtparams + " for " + symbol.typeParams) diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index ef98935f9c..7f220992a3 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -473,7 +473,15 @@ abstract class UnCurry extends InfoTransform arg.pos.source.path + ":" + arg.pos.line, fun.fullName, if (fun.isPrivate) "private" else "") ) - newFunction0(arg) + + arg match { + // don't add a thunk for by-name argument if argument already is an application of + // a Function0. We can then remove the application and use the existing Function0. + case Apply(Select(recv, nme.apply), Nil) if recv.tpe.typeSymbol isSubClass FunctionClass(0) => + recv + case _ => + newFunction0(arg) + } } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 722440349a..793b85da18 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1133,16 +1133,27 @@ trait Implicits { * An EmptyTree is returned if materialization fails. */ private def tagOfType(pre: Type, tp: Type, tagClass: Symbol): SearchResult = { - def success(arg: Tree) = + def success(arg: Tree) = { + def isMacroException(msg: String): Boolean = + // [Eugene] very unreliable, ask Hubert about a better way + msg contains "exception during macro expansion" + + def processMacroExpansionError(pos: Position, msg: String): SearchResult = { + // giving up and reporting all macro exceptions regardless of their source + // this might lead to an avalanche of errors if one of your implicit macros misbehaves + if (isMacroException(msg)) context.error(pos, msg) + failure(arg, "failed to typecheck the materialized tag: %n%s".format(msg), pos) + } + try { val tree1 = typed(atPos(pos.focus)(arg)) - def isErroneous = tree exists (_.isErroneous) - if (context.hasErrors) failure(tp, "failed to typecheck the materialized typetag: %n%s".format(context.errBuffer.head.errMsg), context.errBuffer.head.errPos) + if (context.hasErrors) processMacroExpansionError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg) else new SearchResult(tree1, EmptyTreeTypeSubstituter) } catch { case ex: TypeError => - failure(arg, "failed to typecheck the materialized typetag: %n%s".format(ex.msg), ex.pos) + processMacroExpansionError(ex.pos, ex.msg) } + } val prefix = ( // ClassTags only exist for scala.reflect.mirror, so their materializer diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index fb0616c890..5534cd179c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -499,7 +499,8 @@ trait Infer { else Some( if (targ.typeSymbol == RepeatedParamClass) targ.baseType(SeqClass) else if (targ.typeSymbol == JavaRepeatedParamClass) targ.baseType(ArrayClass) - else if ((opt.experimental || opt.virtPatmat) && tvar.constr.avoidWiden) targ + // this infers Foo.type instead of "object Foo" (see also widenIfNecessary) + else if (targ.typeSymbol.isModuleClass || ((opt.experimental || opt.virtPatmat) && tvar.constr.avoidWiden)) targ else targ.widen ) )) diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 353514c397..c10901cdce 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -641,143 +641,181 @@ trait Macros extends Traces { */ private type MacroRuntime = List[Any] => Any private val macroRuntimesCache = perRunCaches.newWeakMap[Symbol, Option[MacroRuntime]] - private def macroRuntime(macroDef: Symbol): Option[MacroRuntime] = - macroRuntimesCache.getOrElseUpdate(macroDef, { - val runtime = { - macroTraceVerbose("looking for macro implementation: ")(macroDef) - macroTraceVerbose("macroDef is annotated with: ")(macroDef.annotations) - - val ann = macroDef.getAnnotation(MacroImplAnnotation) - if (ann == None) { - macroTraceVerbose("@macroImpl annotation is missing (this means that macro definition failed to typecheck)")(macroDef) - return None - } + private lazy val fastTrack: Map[Symbol, MacroRuntime] = { + import scala.reflect.api.Universe + import scala.reflect.makro.internal._ + Map( // challenge: how can we factor out the common code? Does not seem to be easy. + MacroInternal_materializeArrayTag -> (args => { + assert(args.length == 3, args) + val c = args(0).asInstanceOf[MacroContext] + materializeArrayTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]]) + }), + MacroInternal_materializeErasureTag -> (args => { + assert(args.length == 3, args) + val c = args(0).asInstanceOf[MacroContext] + materializeErasureTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]]) + }), + MacroInternal_materializeClassTag -> (args => { + assert(args.length == 3, args) + val c = args(0).asInstanceOf[MacroContext] + materializeClassTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]]) + }), + MacroInternal_materializeTypeTag -> (args => { + assert(args.length == 3, args) + val c = args(0).asInstanceOf[MacroContext] + materializeTypeTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]]) + }), + MacroInternal_materializeConcreteTypeTag -> (args => { + assert(args.length == 3, args) + val c = args(0).asInstanceOf[MacroContext] + materializeConcreteTypeTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]]) + }) + ) + } + private def macroRuntime(macroDef: Symbol): Option[MacroRuntime] = { + macroTraceVerbose("looking for macro implementation: ")(macroDef) + if (fastTrack contains macroDef) { + macroLogVerbose("macro expansion serviced by a fast track") + Some(fastTrack(macroDef)) + } else { + macroRuntimesCache.getOrElseUpdate(macroDef, { + val runtime = { + macroTraceVerbose("looking for macro implementation: ")(macroDef) + macroTraceVerbose("macroDef is annotated with: ")(macroDef.annotations) - val macroImpl = ann.get.args(0).symbol - if (macroImpl == NoSymbol) { - macroTraceVerbose("@macroImpl annotation is malformed (this means that macro definition failed to typecheck)")(macroDef) - return None - } + val ann = macroDef.getAnnotation(MacroImplAnnotation) + if (ann == None) { + macroTraceVerbose("@macroImpl annotation is missing (this means that macro definition failed to typecheck)")(macroDef) + return None + } - macroLogVerbose("resolved implementation %s at %s".format(macroImpl, macroImpl.pos)) - if (macroImpl.isErroneous) { - macroTraceVerbose("macro implementation is erroneous (this means that either macro body or macro implementation signature failed to typecheck)")(macroDef) - return None - } + val macroImpl = ann.get.args(0).symbol + if (macroImpl == NoSymbol) { + macroTraceVerbose("@macroImpl annotation is malformed (this means that macro definition failed to typecheck)")(macroDef) + return None + } - def loadMacroImpl(macroMirror: Mirror): Option[(Object, macroMirror.Symbol)] = { - try { - // this logic relies on the assumptions that were valid for the old macro prototype - // namely that macro implementations can only be defined in top-level classes and modules - // with the new prototype that materialized in a SIP, macros need to be statically accessible, which is different - // for example, a macro def could be defined in a trait that is implemented by an object - // there are some more clever cases when seemingly non-static method ends up being statically accessible - // however, the code below doesn't account for these guys, because it'd take a look of time to get it right - // for now I leave it as a todo and move along to more the important stuff - - macroTraceVerbose("loading implementation class from %s: ".format(macroMirror))(macroImpl.owner.fullName) - macroTraceVerbose("classloader is: ")("%s of type %s".format(macroMirror.classLoader, if (macroMirror.classLoader != null) macroMirror.classLoader.getClass.toString else "primordial classloader")) - def inferClasspath(cl: ClassLoader) = cl match { - case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]" - case null => "[" + scala.tools.util.PathResolver.Environment.javaBootClassPath + "]" - case _ => "<unknown>" - } - macroTraceVerbose("classpath is: ")(inferClasspath(macroMirror.classLoader)) - - // [Eugene] relies on the fact that macro implementations can only be defined in static classes - // [Martin to Eugene] There's similar logic buried in Symbol#flatname. Maybe we can refactor? - def classfile(sym: Symbol): String = { - def recur(sym: Symbol): String = sym match { - case sym if sym.owner.isPackageClass => - val suffix = if (sym.isModuleClass) "$" else "" - sym.fullName + suffix - case sym => - val separator = if (sym.owner.isModuleClass) "" else "$" - recur(sym.owner) + separator + sym.javaSimpleName.toString + macroLogVerbose("resolved implementation %s at %s".format(macroImpl, macroImpl.pos)) + if (macroImpl.isErroneous) { + macroTraceVerbose("macro implementation is erroneous (this means that either macro body or macro implementation signature failed to typecheck)")(macroDef) + return None + } + + def loadMacroImpl(macroMirror: Mirror): Option[(Object, macroMirror.Symbol)] = { + try { + // this logic relies on the assumptions that were valid for the old macro prototype + // namely that macro implementations can only be defined in top-level classes and modules + // with the new prototype that materialized in a SIP, macros need to be statically accessible, which is different + // for example, a macro def could be defined in a trait that is implemented by an object + // there are some more clever cases when seemingly non-static method ends up being statically accessible + // however, the code below doesn't account for these guys, because it'd take a look of time to get it right + // for now I leave it as a todo and move along to more the important stuff + + macroTraceVerbose("loading implementation class from %s: ".format(macroMirror))(macroImpl.owner.fullName) + macroTraceVerbose("classloader is: ")("%s of type %s".format(macroMirror.classLoader, if (macroMirror.classLoader != null) macroMirror.classLoader.getClass.toString else "primordial classloader")) + def inferClasspath(cl: ClassLoader) = cl match { + case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]" + case null => "[" + scala.tools.util.PathResolver.Environment.javaBootClassPath + "]" + case _ => "<unknown>" } + macroTraceVerbose("classpath is: ")(inferClasspath(macroMirror.classLoader)) + + // [Eugene] relies on the fact that macro implementations can only be defined in static classes + // [Martin to Eugene] There's similar logic buried in Symbol#flatname. Maybe we can refactor? + def classfile(sym: Symbol): String = { + def recur(sym: Symbol): String = sym match { + case sym if sym.owner.isPackageClass => + val suffix = if (sym.isModuleClass) "$" else "" + sym.fullName + suffix + case sym => + val separator = if (sym.owner.isModuleClass) "" else "$" + recur(sym.owner) + separator + sym.javaSimpleName.toString + } - if (sym.isClass || sym.isModule) recur(sym) - else recur(sym.enclClass) - } + if (sym.isClass || sym.isModule) recur(sym) + else recur(sym.enclClass) + } - // [Eugene] this doesn't work for inner classes - // neither does macroImpl.owner.javaClassName, so I had to roll my own implementation - //val receiverName = macroImpl.owner.fullName - val implClassName = classfile(macroImpl.owner) - val implClassSymbol: macroMirror.Symbol = macroMirror.symbolForName(implClassName) + // [Eugene] this doesn't work for inner classes + // neither does macroImpl.owner.javaClassName, so I had to roll my own implementation + //val receiverName = macroImpl.owner.fullName + val implClassName = classfile(macroImpl.owner) + val implClassSymbol: macroMirror.Symbol = macroMirror.symbolForName(implClassName) - if (macroDebugVerbose) { - println("implClassSymbol is: " + implClassSymbol.fullNameString) + if (macroDebugVerbose) { + println("implClassSymbol is: " + implClassSymbol.fullNameString) - if (implClassSymbol != macroMirror.NoSymbol) { - val implClass = macroMirror.classToJava(implClassSymbol) - val implSource = implClass.getProtectionDomain.getCodeSource - println("implClass is %s from %s".format(implClass, implSource)) - println("implClassLoader is %s with classpath %s".format(implClass.getClassLoader, inferClasspath(implClass.getClassLoader))) + if (implClassSymbol != macroMirror.NoSymbol) { + val implClass = macroMirror.classToJava(implClassSymbol) + val implSource = implClass.getProtectionDomain.getCodeSource + println("implClass is %s from %s".format(implClass, implSource)) + println("implClassLoader is %s with classpath %s".format(implClass.getClassLoader, inferClasspath(implClass.getClassLoader))) + } } - } - val implObjSymbol = implClassSymbol.companionModule - macroTraceVerbose("implObjSymbol is: ")(implObjSymbol.fullNameString) + val implObjSymbol = implClassSymbol.companionModule + macroTraceVerbose("implObjSymbol is: ")(implObjSymbol.fullNameString) - if (implObjSymbol == macroMirror.NoSymbol) None - else { - // yet another reflection method that doesn't work for inner classes - //val receiver = macroMirror.companionInstance(receiverClass) - val implObj = try { - val implObjClass = java.lang.Class.forName(implClassName, true, macroMirror.classLoader) - implObjClass getField "MODULE$" get null - } catch { - case ex: NoSuchFieldException => macroTraceVerbose("exception when loading implObj: ")(ex); null - case ex: NoClassDefFoundError => macroTraceVerbose("exception when loading implObj: ")(ex); null - case ex: ClassNotFoundException => macroTraceVerbose("exception when loading implObj: ")(ex); null - } - - if (implObj == null) None + if (implObjSymbol == macroMirror.NoSymbol) None else { - val implMethSymbol = implObjSymbol.info.member(macroMirror.newTermName(macroImpl.name.toString)) - macroLogVerbose("implMethSymbol is: " + implMethSymbol.fullNameString) - macroLogVerbose("jimplMethSymbol is: " + macroMirror.methodToJava(implMethSymbol)) + // yet another reflection method that doesn't work for inner classes + //val receiver = macroMirror.companionInstance(receiverClass) + val implObj = try { + val implObjClass = java.lang.Class.forName(implClassName, true, macroMirror.classLoader) + implObjClass getField "MODULE$" get null + } catch { + case ex: NoSuchFieldException => macroTraceVerbose("exception when loading implObj: ")(ex); null + case ex: NoClassDefFoundError => macroTraceVerbose("exception when loading implObj: ")(ex); null + case ex: ClassNotFoundException => macroTraceVerbose("exception when loading implObj: ")(ex); null + } - if (implMethSymbol == macroMirror.NoSymbol) None + if (implObj == null) None else { - macroLogVerbose("successfully loaded macro impl as (%s, %s)".format(implObj, implMethSymbol)) - Some((implObj, implMethSymbol)) + val implMethSymbol = implObjSymbol.info.member(macroMirror.newTermName(macroImpl.name.toString)) + macroLogVerbose("implMethSymbol is: " + implMethSymbol.fullNameString) + macroLogVerbose("jimplMethSymbol is: " + macroMirror.methodToJava(implMethSymbol)) + + if (implMethSymbol == macroMirror.NoSymbol) None + else { + macroLogVerbose("successfully loaded macro impl as (%s, %s)".format(implObj, implMethSymbol)) + Some((implObj, implMethSymbol)) + } } } + } catch { + case ex: ClassNotFoundException => + macroTraceVerbose("implementation class failed to load: ")(ex.toString) + None } - } catch { - case ex: ClassNotFoundException => - macroTraceVerbose("implementation class failed to load: ")(ex.toString) - None } - } - val primary = loadMacroImpl(primaryMirror) - primary match { - case Some((implObj, implMethSymbol)) => - def runtime(args: List[Any]) = primaryMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any] - Some(runtime _) - case None => - if (settings.XmacroFallbackClasspath.value != "") { - macroLogVerbose("trying to load macro implementation from the fallback mirror: %s".format(settings.XmacroFallbackClasspath.value)) - val fallback = loadMacroImpl(fallbackMirror) - fallback match { - case Some((implObj, implMethSymbol)) => - def runtime(args: List[Any]) = fallbackMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any] - Some(runtime _) - case None => - None + val primary = loadMacroImpl(primaryMirror) + primary match { + case Some((implObj, implMethSymbol)) => + def runtime(args: List[Any]) = primaryMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any] + Some(runtime _) + case None => + if (settings.XmacroFallbackClasspath.value != "") { + macroLogVerbose("trying to load macro implementation from the fallback mirror: %s".format(settings.XmacroFallbackClasspath.value)) + val fallback = loadMacroImpl(fallbackMirror) + fallback match { + case Some((implObj, implMethSymbol)) => + def runtime(args: List[Any]) = fallbackMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any] + Some(runtime _) + case None => + None + } + } else { + None } - } else { - None - } + } } - } - if (runtime == None) macroDef setFlag IS_ERROR - runtime - }) + if (runtime == None) macroDef setFlag IS_ERROR + runtime + }) + } + } /** Should become private again once we're done with migrating typetag generation from implicits */ def macroContext(typer: Typer, prefixTree: Tree, expandeeTree: Tree): MacroContext { val mirror: global.type } = @@ -1203,8 +1241,10 @@ trait Macros extends Traces { if (relevancyThreshold == -1) None else { var relevantElements = realex.getStackTrace().take(relevancyThreshold + 1) - var framesTillReflectiveInvocationOfMacroImpl = relevantElements.reverse.indexWhere(_.isNativeMethod) + 1 - relevantElements = relevantElements dropRight framesTillReflectiveInvocationOfMacroImpl + def isMacroInvoker(este: StackTraceElement) = este.isNativeMethod || (este.getClassName != null && (este.getClassName contains "fastTrack")) + var threshold = relevantElements.reverse.indexWhere(isMacroInvoker) + 1 + while (threshold != relevantElements.length && isMacroInvoker(relevantElements(relevantElements.length - threshold - 1))) threshold += 1 + relevantElements = relevantElements dropRight threshold realex.setStackTrace(relevantElements) val message = new java.io.StringWriter() diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 6620ef7347..e4b744dffc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -567,7 +567,15 @@ trait Namers extends MethodSynthesis { assignAndEnterFinishedSymbol(tree) else enterGetterSetter(tree) + + // When java enums are read from bytecode, they are known to have + // constant types by the jvm flag and assigned accordingly. When + // they are read from source, the java parser marks them with the + // STABLE flag, and now we receive that signal. + if (tree.symbol hasAllFlags STABLE | JAVA) + tree.symbol setInfo ConstantType(Constant(tree.symbol)) } + def enterLazyVal(tree: ValDef, lazyAccessor: Symbol): TermSymbol = { // If the owner is not a class, this is a lazy val from a method, // with no associated field. It has an accessor with $lzy appended to its name and @@ -765,7 +773,10 @@ trait Namers extends MethodSynthesis { val tpe1 = dropRepeatedParamType(tpe.deconst) val tpe2 = tpe1.widen - if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) + // This infers Foo.type instead of "object Foo" + // See Infer#adjustTypeArgs for the polymorphic case. + if (tpe.typeSymbolDirect.isModuleClass) tpe1 + else if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) if (tpe2 <:< pt) tpe2 else tpe1 else if (isHidden(tpe)) tpe2 // In an attempt to make pattern matches involving method local vals @@ -784,8 +795,8 @@ trait Namers extends MethodSynthesis { val typedBody = if (tree.symbol.isTermMacro) defnTyper.computeMacroDefType(tree, pt) else defnTyper.computeType(tree.rhs, pt) - val sym = if (owner.isMethod) owner else tree.symbol - val typedDefn = widenIfNecessary(sym, typedBody, pt) + + val typedDefn = widenIfNecessary(tree.symbol, typedBody, pt) assignTypeToTree(tree, typedDefn) } diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 90e388c30a..bef6f13bc3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -338,7 +338,7 @@ trait NamesDefaults { self: Analyzer => // cannot call blockTyper.typedBlock here, because the method expr might be partially applied only val res = blockTyper.doTypedApply(tree, expr, refArgs, mode, pt) res.setPos(res.pos.makeTransparent) - val block = Block(stats ::: valDefs, res).setType(res.tpe).setPos(tree.pos) + val block = Block(stats ::: valDefs, res).setType(res.tpe).setPos(tree.pos.makeTransparent) context.namedApplyBlockInfo = Some((block, NamedApplyInfo(qual, targs, vargss :+ refArgs, blockTyper))) block diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index e60cda6af7..4e578e3f0d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -386,8 +386,9 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R overrideError("cannot be used here - classes can only override abstract types"); } else if (other.isEffectivelyFinal) { // (1.2) overrideError("cannot override final member"); - // synthetic exclusion needed for (at least) default getters. - } else if (!other.isDeferred && !member.isAnyOverride && !member.isSynthetic) { + } else if (!other.isDeferred && !member.isAnyOverride && !member.isSynthetic) { // (*) + // (*) Synthetic exclusion for (at least) default getters, fixes SI-5178. We cannot assign the OVERRIDE flag to + // the default getter: one default getter might sometimes override, sometimes not. Example in comment on ticket. if (isNeitherInClass && !(other.owner isSubClass member.owner)) emitOverrideError( clazz + " inherits conflicting members:\n " @@ -1278,6 +1279,15 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } def transformStat(tree: Tree, index: Int): List[Tree] = tree match { + case t if treeInfo.isSelfConstrCall(t) => + assert(index == 0, index) + val t = transform(tree) + if (currentLevel.maxindex > 0) { + // An implementation restriction to avoid VerifyErrors and lazyvals mishaps; see SI-4717 + debuglog("refsym = " + currentLevel.refsym) + unit.error(currentLevel.refpos, "forward reference not allowed from self constructor invocation") + } + List(t) case ModuleDef(_, _, _) => eliminateModuleDefs(tree) case ValDef(_, _, _, _) => val tree1 @ ValDef(_, _, _, rhs) = transform(tree) // important to do before forward reference check @@ -1478,8 +1488,23 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R private def transformCaseApply(tree: Tree, ifNot: => Unit) = { val sym = tree.symbol - - if (sym.isSourceMethod && sym.isCase && sym.name == nme.apply) + + def isClassTypeAccessible(tree: Tree): Boolean = tree match { + case TypeApply(fun, targs) => + isClassTypeAccessible(fun) + case Select(module, apply) => + // Fixes SI-5626. Classes in refinement types cannot be constructed with `new`. In this case, + // the companion class is actually not a ClassSymbol, but a reference to an abstract type. + module.symbol.companionClass.isClass + } + + val doTransform = + sym.isSourceMethod && + sym.isCase && + sym.name == nme.apply && + isClassTypeAccessible(tree) + + if (doTransform) toConstructor(tree.pos, tree.tpe) else { ifNot diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 57e82ed706..6faa9a3cb7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -89,6 +89,11 @@ trait SyntheticMethods extends ast.TreeDSL { def forwardToRuntime(method: Symbol): Tree = forwardMethod(method, getMember(ScalaRunTimeModule, method.name prepend "_"))(mkThis :: _) + def callStaticsMethod(name: String)(args: Tree*): Tree = { + val method = termMember(RuntimeStaticsModule, name) + Apply(gen.mkAttributedRef(method), args.toList) + } + // Any member, including private def hasConcreteImpl(name: Name) = clazz.info.member(name).alternatives exists (m => !m.isDeferred && !m.isSynthetic) @@ -222,13 +227,47 @@ trait SyntheticMethods extends ast.TreeDSL { ) } + def hashcodeImplementation(sym: Symbol): Tree = { + sym.tpe.finalResultType.typeSymbol match { + case UnitClass | NullClass => Literal(Constant(0)) + case BooleanClass => If(Ident(sym), Literal(Constant(1231)), Literal(Constant(1237))) + case IntClass | ShortClass | ByteClass | CharClass => Ident(sym) + case LongClass => callStaticsMethod("longHash")(Ident(sym)) + case DoubleClass => callStaticsMethod("doubleHash")(Ident(sym)) + case FloatClass => callStaticsMethod("floatHash")(Ident(sym)) + case _ => callStaticsMethod("anyHash")(Ident(sym)) + } + } + + def specializedHashcode = { + createMethod(nme.hashCode_, Nil, IntClass.tpe) { m => + val accumulator = m.newVariable(newTermName("acc"), m.pos, SYNTHETIC) setInfo IntClass.tpe + val valdef = ValDef(accumulator, Literal(Constant(0xcafebabe))) + val mixes = accessors map (acc => + Assign( + Ident(accumulator), + callStaticsMethod("mix")(Ident(accumulator), hashcodeImplementation(acc)) + ) + ) + val finish = callStaticsMethod("finalizeHash")(Ident(accumulator), Literal(Constant(arity))) + + Block(valdef :: mixes, finish) + } + } + def chooseHashcode = { + if (accessors exists (x => isPrimitiveValueType(x.tpe.finalResultType))) + specializedHashcode + else + forwardToRuntime(Object_hashCode) + } + def valueClassMethods = List( Any_hashCode -> (() => hashCodeDerivedValueClassMethod), Any_equals -> (() => equalsDerivedValueClassMethod) ) def caseClassMethods = productMethods ++ productNMethods ++ Seq( - Object_hashCode -> (() => forwardToRuntime(Object_hashCode)), + Object_hashCode -> (() => chooseHashcode), Object_toString -> (() => forwardToRuntime(Object_toString)), Object_equals -> (() => equalsCaseClassMethod) ) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8c2eae1c86..b5e58efaff 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -31,7 +31,6 @@ trait Typers extends Modes with Adaptations with Taggings { import global._ import definitions._ - import patmat.DefaultOverrideMatchAttachment final def forArgMode(fun: Tree, mode: Int) = @@ -85,6 +84,12 @@ trait Typers extends Modes with Adaptations with Taggings { private def isPastTyper = phase.id > currentRun.typerPhase.id + // To enable decent error messages when the typer crashes. + // TODO - this only catches trees which go through def typed, + // but there are all kinds of back ways - typedClassDef, etc. etc. + // Funnel everything through one doorway. + var lastTreeToTyper: Tree = EmptyTree + // when true: // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction @@ -921,7 +926,7 @@ trait Typers extends Modes with Adaptations with Taggings { KindArityMismatchError(tree, pt) } else tree match { // (6) case TypeTree() => tree - case _ => TypeTree(tree.tpe) setOriginal (tree) setPos (tree.pos) + case _ => TypeTree(tree.tpe) setOriginal tree } } @@ -953,9 +958,14 @@ trait Typers extends Modes with Adaptations with Taggings { * see test/files/../t5189*.scala */ def adaptConstrPattern(): Tree = { // (5) - val extractor = tree.symbol.filter(sym => reallyExists(unapplyMember(sym.tpe))) + def isExtractor(sym: Symbol) = reallyExists(unapplyMember(sym.tpe)) + val extractor = tree.symbol filter isExtractor if (extractor != NoSymbol) { tree setSymbol extractor + tree.tpe match { + case OverloadedType(pre, alts) => tree.tpe = overloadedType(pre, alts filter isExtractor) + case _ => + } val unapply = unapplyMember(extractor.tpe) val clazz = unapplyParameterType(unapply) @@ -2297,7 +2307,7 @@ trait Typers extends Modes with Adaptations with Taggings { import CODE._ // need to duplicate the cases before typing them to generate the apply method, or the symbols will be all messed up - val casesTrue = if (isPartial) cases map (c => deriveCaseDef(c)(x => TRUE_typed).duplicate) else Nil + val casesTrue = if (isPartial) cases map (c => deriveCaseDef(c)(x => atPos(x.pos.focus)(TRUE_typed)).duplicate) else Nil // println("casesTrue "+ casesTrue) def parentsPartial(targs: List[Type]) = addSerializable(appliedType(AbstractPartialFunctionClass.typeConstructor, targs)) @@ -2372,7 +2382,7 @@ trait Typers extends Modes with Adaptations with Taggings { } def isDefinedAtMethod = { - val methodSym = anonClass.newMethod(nme.isDefinedAt, tree.pos, FINAL) + val methodSym = anonClass.newMethod(nme.isDefinedAt, tree.pos.makeTransparent, FINAL) val paramSyms = mkParams(methodSym) val selector = mkSel(paramSyms) @@ -2398,7 +2408,7 @@ trait Typers extends Modes with Adaptations with Taggings { def translated = if (members.head eq EmptyTree) setError(tree) - else typed(Block(List(ClassDef(anonClass, NoMods, List(List()), List(List()), members, tree.pos)), New(anonClass.tpe)), mode, pt) + else typed(atPos(tree.pos)(Block(List(ClassDef(anonClass, NoMods, List(List()), List(List()), members, tree.pos.focus)), atPos(tree.pos.focus)(New(anonClass.tpe)))), mode, pt) } // Function(params, Match(sel, cases)) ==> new <Partial>Function { def apply<OrElse>(params) = `translateMatch('sel match { cases }')` } @@ -3230,7 +3240,7 @@ trait Typers extends Modes with Adaptations with Taggings { } if (hasError) annotationError - else AnnotationInfo(annType, List(), nvPairs map {p => (p._1, p._2.get)}).setOriginal(Apply(typedFun, args)).setPos(ann.pos) + else AnnotationInfo(annType, List(), nvPairs map {p => (p._1.asInstanceOf[Name], p._2.get)}).setOriginal(Apply(typedFun, args).setPos(ann.pos)) // [Eugene+] why do we need this cast? } } else if (requireJava) { reportAnnotationError(NestedAnnotationError(ann, annType)) @@ -4972,6 +4982,7 @@ trait Typers extends Modes with Adaptations with Taggings { * @return ... */ def typed(tree: Tree, mode: Int, pt: Type): Tree = { + lastTreeToTyper = tree indentTyping() var alreadyTyped = false diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 1ebcea4a07..3d9453d8cd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -210,13 +210,25 @@ trait Unapplies extends ast.TreeDSL // and re-added in ``finishWith'' in the namer. def paramWithDefault(vd: ValDef) = treeCopy.ValDef(vd, vd.mods | DEFAULTPARAM, vd.name, atPos(vd.pos.focus)(TypeTree() setOriginal vd.tpt), toIdent(vd)) - - val paramss = mmap(cparamss)(paramWithDefault) - val classTpe = classType(cdef, tparams) + + val (copyParamss, funParamss) = cparamss match { + case Nil => (Nil, Nil) + case ps :: pss => + (List(ps.map(paramWithDefault)), mmap(pss)(p => copyUntyped[ValDef](p).copy(rhs = EmptyTree))) + } + + val classTpe = classType(cdef, tparams) + val bodyTpe = funParamss.foldRight(classTpe)((params, restp) => gen.scalaFunctionConstr(params.map(_.tpt), restp)) + + val argss = copyParamss match { + case Nil => Nil + case ps :: Nil => mmap(ps :: funParamss)(toIdent) + } + val body = funParamss.foldRight(New(classTpe, argss): Tree)(Function) Some(atPos(cdef.pos.focus)( - DefDef(Modifiers(SYNTHETIC), nme.copy, tparams, paramss, classTpe, - New(classTpe, mmap(paramss)(toIdent))) + DefDef(Modifiers(SYNTHETIC), nme.copy, tparams, copyParamss, bodyTpe, + body) )) } } diff --git a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala index 2534e1192d..8c037cbda5 100644 --- a/src/compiler/scala/tools/nsc/util/WorkScheduler.scala +++ b/src/compiler/scala/tools/nsc/util/WorkScheduler.scala @@ -30,6 +30,10 @@ class WorkScheduler { todo.dequeueAll(a => f(a).isDefined).map(a => f(a).get) } + def dequeueAllInterrupts(f: InterruptReq => Unit): Unit = synchronized { + interruptReqs.dequeueAll { iq => f(iq); true } + } + /** Called from server: return optional exception posted by client * Reset to no exception. */ diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 36e95b303d..cf72973b7c 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -362,8 +362,8 @@ object Array extends FallbackArrayBuilding { /** Returns an array containing a sequence of increasing integers in a range. * - * @param from the start value of the array - * @param end the end value of the array, exclusive (in other words, this is the first value '''not''' returned) + * @param start the start value of the array + * @param end the end value of the array, exclusive (in other words, this is the first value '''not''' returned) * @return the array with values in range `start, start + 1, ..., end - 1` * up to, but excluding, `end`. */ diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index 5e62df6c71..50e6626700 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -186,7 +186,6 @@ object Console { * } * }}} * - * @param in the new input stream. * @param thunk the code to execute with * the new input stream active * diff --git a/src/library/scala/Either.scala b/src/library/scala/Either.scala index 20451600a9..b35d8a7c8a 100644 --- a/src/library/scala/Either.scala +++ b/src/library/scala/Either.scala @@ -297,7 +297,7 @@ object Either { * Left(12).left.foreach(x => println(x)) // prints "12" * Right(12).left.foreach(x => println(x)) // doesn't print * }}} - * @param e The side-effecting function to execute. + * @param f The side-effecting function to execute. */ def foreach[U](f: A => U) = e match { case Left(a) => f(a) @@ -358,7 +358,7 @@ object Either { * Left(12).left.flatMap(x => Left("scala")) // Left("scala") * Right(12).left.flatMap(x => Left("scala") // Right(12) * }}} - * @param The function to bind across `Left`. + * @param f The function to bind across `Left`. */ def flatMap[BB >: B, X](f: A => Either[X, BB]) = e match { case Left(a) => f(a) @@ -462,7 +462,7 @@ object Either { * Right(12).right.foreach(x => println(x)) // prints "12" * Left(12).right.foreach(x => println(x)) // doesn't print * }}} - * @param e The side-effecting function to execute. + * @param f The side-effecting function to execute. */ def foreach[U](f: B => U) = e match { case Left(_) => {} @@ -516,7 +516,7 @@ object Either { /** * Binds the given function across `Right`. * - * @param The function to bind across `Right`. + * @param f The function to bind across `Right`. */ def flatMap[AA >: A, Y](f: B => Either[AA, Y]) = e match { case Left(a) => Left(a) diff --git a/src/library/scala/Function.scala b/src/library/scala/Function.scala index 9fa56a332f..9ad2bc49ea 100644 --- a/src/library/scala/Function.scala +++ b/src/library/scala/Function.scala @@ -20,7 +20,6 @@ object Function { * function `f,,1,, andThen ... andThen f,,n,,`. * * @param fs The given sequence of functions - * @return ... */ def chain[a](fs: Seq[a => a]): a => a = { x => (x /: fs) ((x, f) => f(x)) } @@ -72,9 +71,6 @@ object Function { * * @note These functions are slotted for deprecation, but it is on * hold pending superior type inference for tupling anonymous functions. - * - * @param f ... - * @return ... */ // @deprecated("Use `f.tupled` instead") def tupled[a1, a2, b](f: (a1, a2) => b): Tuple2[a1, a2] => b = { diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 44c8fba45f..c461b413d6 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -146,7 +146,7 @@ sealed abstract class Option[+A] extends Product with Serializable { /** Returns the result of applying $f to this $option's * value if the $option is nonempty. Otherwise, evaluates - * expression $ifEmpty. + * expression `ifEmpty`. * * @note This is equivalent to `$option map f getOrElse ifEmpty`. * diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 500ee87c46..30ad703c4a 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -160,7 +160,7 @@ object Predef extends LowPriorityImplicits { * is at least `ASSERTION`. * * @see elidable - * @param p the expression to test + * @param assertion the expression to test */ @elidable(ASSERTION) def assert(assertion: Boolean) { @@ -173,8 +173,8 @@ object Predef extends LowPriorityImplicits { * is at least `ASSERTION`. * * @see elidable - * @param p the expression to test - * @param msg a String to include in the failure message + * @param assertion the expression to test + * @param message a String to include in the failure message */ @elidable(ASSERTION) @inline final def assert(assertion: Boolean, message: => Any) { @@ -189,7 +189,7 @@ object Predef extends LowPriorityImplicits { * will not be generated if `-Xelide-below` is at least `ASSERTION`. * * @see elidable - * @param p the expression to test + * @param assumption the expression to test */ @elidable(ASSERTION) def assume(assumption: Boolean) { @@ -204,8 +204,8 @@ object Predef extends LowPriorityImplicits { * will not be generated if `-Xelide-below` is at least `ASSERTION`. * * @see elidable - * @param p the expression to test - * @param msg a String to include in the failure message + * @param assumption the expression to test + * @param message a String to include in the failure message */ @elidable(ASSERTION) @inline final def assume(assumption: Boolean, message: => Any) { @@ -217,7 +217,7 @@ object Predef extends LowPriorityImplicits { * This method is similar to `assert`, but blames the caller of the method * for violating the condition. * - * @param p the expression to test + * @param requirement the expression to test */ def require(requirement: Boolean) { if (!requirement) @@ -228,8 +228,8 @@ object Predef extends LowPriorityImplicits { * This method is similar to `assert`, but blames the caller of the method * for violating the condition. * - * @param p the expression to test - * @param msg a String to include in the failure message + * @param requirement the expression to test + * @param message a String to include in the failure message */ @inline final def require(requirement: Boolean, message: => Any) { if (!requirement) diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala index 1459ab9ea5..8c42c60d98 100644 --- a/src/library/scala/Product.scala +++ b/src/library/scala/Product.scala @@ -19,7 +19,7 @@ package scala */ trait Product extends Any with Equals { /** The n^th^ element of this product, 0-based. In other words, for a - * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),, where `0 < n < k`. + * product `A(x,,1,,, ..., x,,k,,)`, returns `x,,(n+1),,` where `0 < n < k`. * * @param n the index of the element to return * @throws `IndexOutOfBoundsException` diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index 189d75a4ae..04c69bc330 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -21,9 +21,6 @@ package scala object Responder { /** Creates a responder that answer continuations with the constant `a`. - * - * @param x ... - * @return ... */ def constant[A](x: A) = new Responder[A] { def respond(k: A => Unit) = k(x) @@ -31,9 +28,6 @@ object Responder { /** Executes `x` and returns `'''true'''`, useful as syntactic * convenience in for comprehensions. - * - * @param x ... - * @return ... */ def exec[A](x: => Unit): Boolean = { x; true } diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index be9e0c290a..f400f18dab 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -132,7 +132,7 @@ object StringContext { * escape: `\\`, `\"`, `\'` * octal: `\d` `\dd` `\ddd` where `d` is an octal digit between `0` and `7`. * - * @param A string that may contain escape sequences + * @param str A string that may contain escape sequences * @return The string with all escape sequences expanded. */ def treatEscapes(str: String): String = { diff --git a/src/library/scala/annotation/elidable.scala b/src/library/scala/annotation/elidable.scala index 880b645daa..18be2450f5 100644 --- a/src/library/scala/annotation/elidable.scala +++ b/src/library/scala/annotation/elidable.scala @@ -18,18 +18,22 @@ import java.util.logging.Level * be omitted from generated code if the priority given the annotation * is lower than that given on the command line. * + * {{{ * @elidable(123) // annotation priority * scalac -Xelide-below 456 // command line priority - * + * }}} + * * The method call will be replaced with an expression which depends on * the type of the elided expression. In decreasing order of precedence: * + * {{{ * Unit () * Boolean false * T <: AnyVal 0 * T >: Null null * T >: Nothing Predef.??? - * + * }}} + * * Complete example: {{{ import annotation._, elidable._ diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index c0aaa9f28e..00cd63eb70 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -137,7 +137,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe /** Computes the intersection between this bitset and another bitset by performing * a bitwise "and". - * @param that the bitset to intersect with. + * @param other the bitset to intersect with. * @return a new bitset consisting of all elements that are both in this * bitset and in the given bitset `other`. */ @@ -152,7 +152,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe /** Computes the difference of this bitset and another bitset by performing * a bitwise "and-not". * - * @param that the set of bits to exclude. + * @param other the set of bits to exclude. * @return a bitset containing those bits of this * bitset that are not also contained in the given bitset `other`. */ @@ -167,7 +167,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe /** Computes the symmetric difference of this bitset and another bitset by performing * a bitwise "exclusive-or". * - * @param that the other bitset to take part in the symmetric difference. + * @param other the other bitset to take part in the symmetric difference. * @return a bitset containing those bits of this * bitset or the other bitset that are not contained in both bitsets. */ @@ -184,7 +184,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe /** Tests whether this bitset is a subset of another bitset. * - * @param that the bitset to test. + * @param other the bitset to test. * @return `true` if this bitset is a subset of `other`, i.e. if * every bit of this set is also an element in `other`. */ diff --git a/src/library/scala/collection/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala index 290a3b26b5..0fd9bac379 100644 --- a/src/library/scala/collection/GenIterableLike.scala +++ b/src/library/scala/collection/GenIterableLike.scala @@ -41,7 +41,7 @@ trait GenIterableLike[+A, +Repr] extends Any with GenTraversableLike[A, Repr] { /** Checks if the other iterable collection contains the same elements in the same order as this $coll. * * @param that the collection to compare with. - * @tparam B the type of the elements of collection `that`. + * @tparam A1 the type of the elements of collection `that`. * @return `true`, if both collections contain the same elements in the same order, `false` otherwise. * * @usecase def sameElements(that: GenIterable[A]): Boolean @@ -87,13 +87,13 @@ trait GenIterableLike[+A, +Repr] extends Any with GenTraversableLike[A, Repr] { * @tparam A1 the type of the first half of the returned pairs (this is always a supertype * of the collection's element type `A`). * @tparam That the class of the returned collection. Where possible, `That` is - * the same class as the current collection class `Repr`, but this - * depends on the element type `(A1, Int)` being admissible for that class, - * which means that an implicit instance of type `CanBuildFrom[Repr, (A1, Int), That]`. - * is found. - * @tparam bf an implicit value of class `CanBuildFrom` which determines the - * result class `That` from the current representation type `Repr` - * and the new element type `(A1, Int)`. + * the same class as the current collection class `Repr`, but this + * depends on the element type `(A1, Int)` being admissible for that class, + * which means that an implicit instance of type `CanBuildFrom[Repr, (A1, Int), That]`. + * is found. + * @param bf an implicit value of class `CanBuildFrom` which determines the + * result class `That` from the current representation type `Repr` + * and the new element type `(A1, Int)`. * @return A new collection of type `That` containing pairs consisting of all elements of this * $coll paired with their index. Indices start at `0`. * diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala index d611eaea43..4dd2a4fe37 100644 --- a/src/library/scala/collection/GenMapLike.scala +++ b/src/library/scala/collection/GenMapLike.scala @@ -42,7 +42,6 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals * otherwise the result of the `default` computation. * @usecase def getOrElse(key: A, default: => B): B * @inheritdoc - * @tparam B the result type of the default computation. */ def getOrElse[B1 >: B](key: A, default: => B1): B1 diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala index fd7892c9f9..cfa0ca101e 100644 --- a/src/library/scala/collection/GenSeqLike.scala +++ b/src/library/scala/collection/GenSeqLike.scala @@ -413,8 +413,6 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal * * @param that the sequence of elements to remove * @tparam B the element type of the returned $coll. - * @tparam That $thatinfo - * @param bf $bfinfo * @return a new collection of type `That` which contains all elements of this $coll * except some of occurrences of elements that also appear in `that`. * If an element value `x` appears @@ -438,8 +436,6 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal * * @param that the sequence of elements to intersect with. * @tparam B the element type of the returned $coll. - * @tparam That $thatinfo - * @param bf $bfinfo * @return a new collection of type `That` which contains all elements of this $coll * which also appear in `that`. * If an element value `x` appears diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index df652f99d9..0d51230623 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -289,7 +289,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Selects all elements of this $coll which satisfy a predicate. * - * @param p the predicate used to test elements. + * @param pred the predicate used to test elements. * @return a new $coll consisting of all elements of this $coll that satisfy the given * predicate `p`. Their order may not be preserved. */ @@ -297,7 +297,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Selects all elements of this $coll which do not satisfy a predicate. * - * @param p the predicate used to test elements. + * @param pred the predicate used to test elements. * @return a new $coll consisting of all elements of this $coll that do not satisfy the given * predicate `p`. Their order may not be preserved. */ @@ -305,11 +305,11 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Partitions this $coll in two ${coll}s according to a predicate. * - * @param p the predicate on which to partition. - * @return a pair of ${coll}s: the first $coll consists of all elements that - * satisfy the predicate `p` and the second $coll consists of all elements - * that don't. The relative order of the elements in the resulting ${coll}s - * may not be preserved. + * @param pred the predicate on which to partition. + * @return a pair of ${coll}s: the first $coll consists of all elements that + * satisfy the predicate `p` and the second $coll consists of all elements + * that don't. The relative order of the elements in the resulting ${coll}s + * may not be preserved. */ def partition(pred: A => Boolean): (Repr, Repr) @@ -354,8 +354,8 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with * }}} * $orderDependent * - * @param from the lowest index to include from this $coll. - * @param until the lowest index to EXCLUDE from this $coll. + * @param unc_from the lowest index to include from this $coll. + * @param unc_until the lowest index to EXCLUDE from this $coll. * @return a $coll containing the elements greater than or equal to * index `from` extending up to (but not including) index `until` * of this $coll. @@ -375,7 +375,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Takes longest prefix of elements that satisfy a predicate. * $orderDependent - * @param p The predicate used to test elements. + * @param pred The predicate used to test elements. * @return the longest prefix of this $coll whose elements all satisfy * the predicate `p`. */ @@ -388,7 +388,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with * predicate `p` does not cause any side-effects. * $orderDependent * - * @param p the test predicate + * @param pred the test predicate * @return a pair consisting of the longest prefix of this $coll whose * elements all satisfy `p`, and the rest of this $coll. */ @@ -396,7 +396,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with /** Drops longest prefix of elements that satisfy a predicate. * $orderDependent - * @param p The predicate used to test elements. + * @param pred The predicate used to test elements. * @return the longest suffix of this $coll whose first element * does not satisfy the predicate `p`. */ diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index f4e3848d98..eab6b84ea8 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -312,7 +312,7 @@ trait GenTraversableOnce[+A] extends Any { * * @param num an implicit parameter defining a set of numeric operations * which includes the `+` operator to be used in forming the sum. - * @tparam B the result type of the `+` operator. + * @tparam A1 the result type of the `+` operator. * @return the sum of all elements of this $coll with respect to the `+` operator in `num`. * * @usecase def sum: A @@ -330,7 +330,7 @@ trait GenTraversableOnce[+A] extends Any { * * @param num an implicit parameter defining a set of numeric operations * which includes the `*` operator to be used in forming the product. - * @tparam B the result type of the `*` operator. + * @tparam A1 the result type of the `*` operator. * @return the product of all elements of this $coll with respect to the `*` operator in `num`. * * @usecase def product: A @@ -345,8 +345,8 @@ trait GenTraversableOnce[+A] extends Any { /** Finds the smallest element. * - * @param cmp An ordering to be used for comparing elements. - * @tparam B The type over which the ordering is defined. + * @param ord An ordering to be used for comparing elements. + * @tparam A1 The type over which the ordering is defined. * @return the smallest element of this $coll with respect to the ordering `cmp`. * * @usecase def min: A @@ -358,8 +358,8 @@ trait GenTraversableOnce[+A] extends Any { /** Finds the largest element. * - * @param cmp An ordering to be used for comparing elements. - * @tparam B The type over which the ordering is defined. + * @param ord An ordering to be used for comparing elements. + * @tparam A1 The type over which the ordering is defined. * @return the largest element of this $coll with respect to the ordering `cmp`. * * @usecase def max: A @@ -382,9 +382,9 @@ trait GenTraversableOnce[+A] extends Any { * $mayNotTerminateInf * $orderDependent * - * @param p the predicate used to test elements. - * @return an option value containing the first element in the $coll - * that satisfies `p`, or `None` if none exists. + * @param pred the predicate used to test elements. + * @return an option value containing the first element in the $coll + * that satisfies `p`, or `None` if none exists. */ def find(pred: A => Boolean): Option[A] @@ -459,9 +459,9 @@ trait GenTraversableOnce[+A] extends Any { /** Converts this $coll to an array. * - * @tparam B the type of the elements of the array. An `ArrayTag` for - * this type must be available. - * @return an array containing all elements of this $coll. + * @tparam A1 the type of the elements of the array. An `ArrayTag` for + * this type must be available. + * @return an array containing all elements of this $coll. * * @usecase def toArray: Array[A] * @inheritdoc diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index f4397f2167..0a5d9fc23c 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -166,13 +166,23 @@ self => * @see Iterator#sliding * * @param size the number of elements per group + * @return An iterator producing ${coll}s of size `size`, except the + * last and the only element will be truncated if there are + * fewer elements than size. + */ + def sliding(size: Int): Iterator[Repr] = sliding(size, 1) + + /** Groups elements in fixed size blocks by passing a "sliding window" + * over them (as opposed to partitioning them, as is done in grouped.) + * @see Iterator#sliding + * + * @param size the number of elements per group * @param step the distance between the first elements of successive * groups (defaults to 1) * @return An iterator producing ${coll}s of size `size`, except the * last and the only element will be truncated if there are * fewer elements than size. */ - def sliding(size: Int): Iterator[Repr] = sliding(size, 1) def sliding(size: Int, step: Int): Iterator[Repr] = for (xs <- iterator.sliding(size, step)) yield { val b = newBuilder diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index e9a7906527..7d5cd9989c 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1079,11 +1079,12 @@ trait Iterator[+A] extends TraversableOnce[A] { if (i < from) origElems.hasNext else patchElems.hasNext || origElems.hasNext def next(): B = { + // We have to do this *first* just in case from = 0. + if (i == from) origElems = origElems drop replaced val result: B = if (i < from || !patchElems.hasNext) origElems.next() else patchElems.next() i += 1 - if (i == from) origElems = origElems drop replaced result } } diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index b2b687e75a..b9b8f62574 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -280,14 +280,14 @@ self => * * @usecase def + (kvs: (A, B)*): Map[A, B] * @inheritdoc - * @param the key/value pairs + * @param kvs the key/value pairs */ def + [B1 >: B] (kv1: (A, B1), kv2: (A, B1), kvs: (A, B1) *): Map[A, B1] = this + kv1 + kv2 ++ kvs /** Adds all key/value pairs in a traversable collection to this map, returning a new map. * - * @param kvs the collection containing the added key/value pairs + * @param xs the collection containing the added key/value pairs * @tparam B1 the type of the added values * @return a new map with the given bindings added to this map * diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 044bd624ae..f64e1d780c 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -413,8 +413,6 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * * @param that the sequence of elements to remove * @tparam B the element type of the returned $coll. - * @tparam That $thatinfo - * @param bf $bfinfo * @return a new collection of type `That` which contains all elements of this $coll * except some of occurrences of elements that also appear in `that`. * If an element value `x` appears @@ -444,8 +442,6 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * * @param that the sequence of elements to intersect with. * @tparam B the element type of the returned $coll. - * @tparam That $thatinfo - * @param bf $bfinfo * @return a new collection of type `That` which contains all elements of this $coll * which also appear in `that`. * If an element value `x` appears diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 639610a30c..d42c037dee 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -16,8 +16,6 @@ import language.{implicitConversions, higherKinds} * or one or more times. * $traversableonceinfo * - * @tparam A the element type of the collection - * * @author Martin Odersky * @author Paul Phillips * @version 2.8 diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 5ca038fd2e..eb2091a5f3 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -162,6 +162,8 @@ trait TraversableViewLike[+A, // if (b.isInstanceOf[NoBuilder[_]]) newFlatMapped(f).asInstanceOf[That] // else super.flatMap[B, That](f)(bf) } + override def flatten[B](implicit asTraversable: A => /*<:<!!!*/ GenTraversableOnce[B]) = + newFlatMapped(asTraversable) private[this] implicit def asThis(xs: Transformed[A]): This = xs.asInstanceOf[This] /** Boilerplate method, to override in each subclass diff --git a/src/library/scala/collection/convert/DecorateAsScala.scala b/src/library/scala/collection/convert/DecorateAsScala.scala index b170d8d139..539584b148 100644 --- a/src/library/scala/collection/convert/DecorateAsScala.scala +++ b/src/library/scala/collection/convert/DecorateAsScala.scala @@ -186,9 +186,9 @@ trait DecorateAsScala { * any side-effects of using it via the Scala interface will be visible via * the Java interface and vice versa. * - * @param m The `Dictionary` to be converted. - * @return An object with an `asScala` method that returns a Scala mutable - * `Map[String, String]` view of the argument. + * @param p The `Dictionary` to be converted. + * @return An object with an `asScala` method that returns a Scala mutable + * `Map[String, String]` view of the argument. */ implicit def dictionaryAsScalaMapConverter[A, B](p: ju.Dictionary[A, B]): AsScala[mutable.Map[A, B]] = new AsScala(dictionaryAsScalaMap(p)) @@ -200,9 +200,9 @@ trait DecorateAsScala { * any side-effects of using it via the Scala interface will be visible via * the Java interface and vice versa. * - * @param m The `Properties` to be converted. - * @return An object with an `asScala` method that returns a Scala mutable - * `Map[String, String]` view of the argument. + * @param p The `Properties` to be converted. + * @return An object with an `asScala` method that returns a Scala mutable + * `Map[String, String]` view of the argument. */ implicit def propertiesAsScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] = new AsScala(propertiesAsScalaMap(p)) diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala index ecf91deb3a..fcfe402a68 100644 --- a/src/library/scala/collection/convert/WrapAsJava.scala +++ b/src/library/scala/collection/convert/WrapAsJava.scala @@ -24,8 +24,8 @@ trait WrapAsJava { * explicit call of `asIterator(java.util.Iterator)` then the original * Java Iterator will be returned. * - * @param i The Iterator to be converted. - * @return A Java Iterator view of the argument. + * @param it The Iterator to be converted. + * @return A Java Iterator view of the argument. */ implicit def asJavaIterator[A](it: Iterator[A]): ju.Iterator[A] = it match { case JIteratorWrapper(wrapped) => wrapped.asInstanceOf[ju.Iterator[A]] @@ -42,8 +42,8 @@ trait WrapAsJava { * explicit call of `asIterator(java.util.Enumeration)` then the * original Java Enumeration will be returned. * - * @param i The Iterator to be converted. - * @return A Java Enumeration view of the argument. + * @param it The Iterator to be converted. + * @return A Java Enumeration view of the argument. */ implicit def asJavaEnumeration[A](it: Iterator[A]): ju.Enumeration[A] = it match { case JEnumerationWrapper(wrapped) => wrapped.asInstanceOf[ju.Enumeration[A]] @@ -76,8 +76,8 @@ trait WrapAsJava { * explicit call of `asSizedIterable(java.util.Collection)` then the original * Java Collection will be returned. * - * @param i The SizedIterable to be converted. - * @return A Java Collection view of the argument. + * @param it The SizedIterable to be converted. + * @return A Java Collection view of the argument. */ implicit def asJavaCollection[A](it: Iterable[A]): ju.Collection[A] = it match { case JCollectionWrapper(wrapped) => wrapped.asInstanceOf[ju.Collection[A]] @@ -112,8 +112,8 @@ trait WrapAsJava { * explicit call of `asSeq(java.util.List)` then the original * Java List will be returned. * - * @param b The Seq to be converted. - * @return A Java List view of the argument. + * @param seq The Seq to be converted. + * @return A Java List view of the argument. */ implicit def mutableSeqAsJavaList[A](seq: mutable.Seq[A]): ju.List[A] = seq match { case JListWrapper(wrapped) => wrapped @@ -130,8 +130,8 @@ trait WrapAsJava { * explicit call of `asSeq(java.util.List)` then the original * Java List will be returned. * - * @param b The Seq to be converted. - * @return A Java List view of the argument. + * @param seq The Seq to be converted. + * @return A Java List view of the argument. */ implicit def seqAsJavaList[A](seq: Seq[A]): ju.List[A] = seq match { case JListWrapper(wrapped) => wrapped.asInstanceOf[ju.List[A]] diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala index 14c64695ff..49f4d7cd99 100644 --- a/src/library/scala/collection/convert/WrapAsScala.scala +++ b/src/library/scala/collection/convert/WrapAsScala.scala @@ -25,8 +25,8 @@ trait WrapAsScala { * explicit call of `asIterator(scala.collection.Iterator)` then the * original Scala `Iterator` will be returned. * - * @param i The `Iterator` to be converted. - * @return A Scala `Iterator` view of the argument. + * @param it The `Iterator` to be converted. + * @return A Scala `Iterator` view of the argument. */ implicit def asScalaIterator[A](it: ju.Iterator[A]): Iterator[A] = it match { case IteratorWrapper(wrapped) => wrapped @@ -187,8 +187,8 @@ trait WrapAsScala { * `Dictionary` and any side-effects of using it via the Scala interface * will be visible via the Java interface and vice versa. * - * @param m The Dictionary to be converted. - * @return A Scala mutable Map[String, String] view of the argument. + * @param p The Dictionary to be converted. + * @return A Scala mutable Map[String, String] view of the argument. */ implicit def dictionaryAsScalaMap[A, B](p: ju.Dictionary[A, B]): mutable.Map[A, B] = p match { case DictionaryWrapper(wrapped) => wrapped @@ -202,8 +202,8 @@ trait WrapAsScala { * `Properties` and any side-effects of using it via the Scala interface * will be visible via the Java interface and vice versa. * - * @param m The Properties to be converted. - * @return A Scala mutable Map[String, String] view of the argument. + * @param p The Properties to be converted. + * @return A Scala mutable Map[String, String] view of the argument. */ implicit def propertiesAsScalaMap(p: ju.Properties): mutable.Map[String, String] = p match { case _ => new JPropertiesWrapper(p) diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 94def7ab5d..2aaf93de05 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -201,8 +201,8 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav /** Produces a $coll containing a sequence of increasing of integers. * - * @param from the first element of the $coll - * @param end the end value of the $coll (the first value NOT contained) + * @param start the first element of the $coll + * @param end the end value of the $coll (the first value NOT contained) * @return a $coll with values `start, start + 1, ..., end - 1` */ def range[T: Integral](start: T, end: T): CC[T] = range(start, end, implicitly[Integral[T]].one) diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 69eab43150..7cb0e812d8 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -73,8 +73,8 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew /** Converts this $coll of pairs into two collections of the first and second * half of each pair. * - * @param A1 the type of the first half of the element pairs - * @param A2 the type of the second half of the element pairs + * @tparam A1 the type of the first half of the element pairs + * @tparam A2 the type of the second half of the element pairs * @param asPair an implicit conversion which asserts that the element type * of this $coll is a pair. * @return a pair ${coll}s, containing the first, respectively second @@ -94,9 +94,9 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew /** Converts this $coll of triples into three collections of the first, second, * and third element of each triple. * - * @param A1 the type of the first member of the element triples - * @param A2 the type of the second member of the element triples - * @param A3 the type of the third member of the element triples + * @tparam A1 the type of the first member of the element triples + * @tparam A2 the type of the second member of the element triples + * @tparam A3 the type of the third member of the element triples * @param asTriple an implicit conversion which asserts that the element type * of this $coll is a triple. * @return a triple ${coll}s, containing the first, second, respectively diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala index d6a263af2f..730cb18733 100644 --- a/src/library/scala/collection/generic/Growable.scala +++ b/src/library/scala/collection/generic/Growable.scala @@ -42,7 +42,7 @@ trait Growable[-A] extends Clearable { /** ${Add}s all elements produced by a TraversableOnce to this $coll. * - * @param iter the TraversableOnce producing the elements to $add. + * @param xs the TraversableOnce producing the elements to $add. * @return the $coll itself. */ def ++=(xs: TraversableOnce[A]): this.type = { xs.seq foreach += ; this } diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala index 0c9dafefb1..593cd0f58e 100644 --- a/src/library/scala/collection/generic/Shrinkable.scala +++ b/src/library/scala/collection/generic/Shrinkable.scala @@ -43,7 +43,7 @@ trait Shrinkable[-A] { /** Removes all elements produced by an iterator from this $coll. * - * @param iter the iterator producing the elements to remove. + * @param xs the iterator producing the elements to remove. * @return the $coll itself */ def --=(xs: TraversableOnce[A]): this.type = { xs.seq foreach -= ; this } diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala index ed9e11fd30..42eca72806 100644 --- a/src/library/scala/collection/generic/Sorted.scala +++ b/src/library/scala/collection/generic/Sorted.scala @@ -62,8 +62,6 @@ trait Sorted[K, +This <: Sorted[K, This]] { * and an upper-bound. * * @param from The upper-bound (exclusive) of the ranged projection. - * @param until ... - * @return ... */ def range(from: K, until: K): This = rangeImpl(Some(from), Some(until)) diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala index cda71c0291..aed4f4f7da 100644 --- a/src/library/scala/collection/generic/Subtractable.scala +++ b/src/library/scala/collection/generic/Subtractable.scala @@ -52,7 +52,7 @@ trait Subtractable[A, +Repr <: Subtractable[A, Repr]] { self => /** Creates a new $coll from this $coll by removing all elements of another * collection. * - * @param elems the collection containing the removed elements. + * @param xs the collection containing the removed elements. * @return a new $coll that contains all elements of the current $coll * except one less occurrence of each of the elements of `elems`. */ diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index b4c22c3b6c..6fd8d143ee 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -511,7 +511,7 @@ object List extends SeqFactory[List] { /** Transforms an Iterable of Eithers into a pair of lists. * - * @param xs the iterable of Eithers to separate + * @param es the iterable of Eithers to separate * @return a pair of lists. */ @deprecated("use `(for (Left(x) <- es) yield x, for (Right(x) <- es) yield x)` instead", "2.8.0") @@ -582,7 +582,7 @@ object List extends SeqFactory[List] { /** Tests whether the given predicate `p` holds * for all corresponding elements of the argument lists. * - * @param p function to apply to each pair of elements. + * @param f function to apply to each pair of elements. * @return `(p(a<sub>0</sub>,b<sub>0</sub>) && * ... && p(a<sub>n</sub>,b<sub>n</sub>))]` * if the lists are `[a<sub>0</sub>, ..., a<sub>k</sub>]`; @@ -604,7 +604,7 @@ object List extends SeqFactory[List] { /** Tests whether the given predicate `p` holds * for some corresponding elements of the argument lists. * - * @param p function to apply to each pair of elements. + * @param f function to apply to each pair of elements. * @return `n != 0 && (p(a<sub>0</sub>,b<sub>0</sub>) || * ... || p(a<sub>n</sub>,b<sub>n</sub>))]` if the lists are * `[a<sub>0</sub>, ..., a<sub>k</sub>]`, diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index 9289b35632..091443f909 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -152,7 +152,7 @@ extends AbstractMap[A, B] * method throws an exception if there is no mapping from the given * key to a value. * - * @param key the key + * @param k the key * @return the value associated with the given key. */ override def apply(k: A): B1 = apply0(this, k) @@ -162,7 +162,7 @@ extends AbstractMap[A, B] /** Checks if this map maps `key` to a value and return the * value if it exists. * - * @param key the key of the mapping of interest + * @param k the key of the mapping of interest * @return the value of the mapping, if it exists */ override def get(k: A): Option[B1] = get0(this, k) @@ -174,9 +174,6 @@ extends AbstractMap[A, B] /** This method allows one to create a new map with an additional mapping * from `key` to `value`. If the map contains already a mapping for `key`, * it will be overridden by this function. - * - * @param k ... - * @param v ... */ override def updated [B2 >: B1](k: A, v: B2): ListMap[A, B2] = { val m = if (contains(k)) this - k else this @@ -186,9 +183,6 @@ extends AbstractMap[A, B] /** Creates a new mapping without the given `key`. * If the map does not contain a mapping for the given key, the * method returns the same map. - * - * @param k ... - * @return ... */ override def - (k: A): ListMap[A, B1] = { // This definition used to result in stack overflows diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index 0331e01f35..ce3abaacb7 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -157,7 +157,7 @@ class ListSet[A] extends AbstractSet[A] /** Checks if this set contains element `elem`. * - * @param elem the element to check for membership. + * @param e the element to check for membership. * @return `'''true'''`, iff `elem` is contained in this set. */ override def contains(e: A) = containsInternal(this, e) diff --git a/src/library/scala/collection/immutable/MapLike.scala b/src/library/scala/collection/immutable/MapLike.scala index 84c87b4eae..6ae2d78188 100644 --- a/src/library/scala/collection/immutable/MapLike.scala +++ b/src/library/scala/collection/immutable/MapLike.scala @@ -35,9 +35,9 @@ import parallel.immutable.ParMap * It is also good idea to override methods `foreach` and * `size` for efficiency. * - * @param A the type of the keys contained in this collection. - * @param B the type of the values associated with the keys. - * @param This The type of the actual map implementation. + * @tparam A the type of the keys contained in this collection. + * @tparam B the type of the values associated with the keys. + * @tparam This The type of the actual map implementation. * * @author Martin Odersky * @version 2.8 diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala index c63c1ce232..473ac6b0b0 100644 --- a/src/library/scala/collection/immutable/Stack.scala +++ b/src/library/scala/collection/immutable/Stack.scala @@ -84,7 +84,7 @@ class Stack[+A] protected (protected val elems: List[A]) * the stack. The last element returned by the traversable object * will be on top of the new stack. * - * @param elems the iterator object. + * @param xs the iterator object. * @return the stack with the new elements on top. */ def pushAll[B >: A](xs: TraversableOnce[B]): Stack[B] = diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index f3e7214c5f..9f5f98ddf4 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -716,8 +716,8 @@ self => /** A substream starting at index `from` and extending up to (but not including) * index `until`. This returns a `Stream` that is lazily evaluated. * - * @param start The index of the first element of the returned subsequence - * @param end The index of the element following the returned subsequence + * @param from The index of the first element of the returned subsequence + * @param until The index of the element following the returned subsequence * @return A new string containing the elements requested from `start` until * `end`. * diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index d1605bf637..e41b17a5e8 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -274,7 +274,7 @@ self => * `scala.BigDecimal`) are unwrapped to pass a type which `Formatter` * understands. * - * @param locale an instance of `java.util.Locale` + * @param l an instance of `java.util.Locale` * @param args the arguments used to instantiating the pattern. * @throws `java.lang.IllegalArgumentException` */ diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 57e81fdb9c..0807721f7d 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -61,7 +61,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza * into a single array. * * @tparam U Type of row elements. - * @param asArray A function that converts elements of this array to rows - arrays of type `U`. + * @param asTrav A function that converts elements of this array to rows - arrays of type `U`. * @return An array obtained by concatenating rows of this array. */ def flatten[U, To](implicit asTrav: T => collection.Traversable[U], m: ArrayTag[U]): Array[U] = { diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index 04a318d0c3..ed5f39f21b 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -152,7 +152,7 @@ extends AbstractSeq[T] /** Pushes all the provided elements in the traversable object onto the stack. * - * @param x The source of elements to push. + * @param xs The source of elements to push. * @return A reference to this stack. */ override def ++=(xs: TraversableOnce[T]): this.type = { xs.seq foreach += ; this } diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala index aa1b20d240..db3b039461 100644 --- a/src/library/scala/collection/mutable/BufferProxy.scala +++ b/src/library/scala/collection/mutable/BufferProxy.scala @@ -77,7 +77,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy { /** Prepend an element to this list. * - * @param elem the element to prepend. + * @param elems the elements to prepend. */ override def prepend(elems: A*) { self.prependAll(elems) } diff --git a/src/library/scala/collection/mutable/IndexedSeqLike.scala b/src/library/scala/collection/mutable/IndexedSeqLike.scala index 4bd5ea1e89..2ff7ac8272 100644 --- a/src/library/scala/collection/mutable/IndexedSeqLike.scala +++ b/src/library/scala/collection/mutable/IndexedSeqLike.scala @@ -43,7 +43,7 @@ trait IndexedSeqLike[A, +Repr] extends scala.collection.IndexedSeqLike[A, Repr] /** Replaces element at given index with a new value. * - * @param n the index of the element to replace. + * @param idx the index of the element to replace. * @param elem the new value. * @throws IndexOutOfBoundsException if the index is not valid. */ diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 5c580f9c09..cd743999bc 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -208,7 +208,7 @@ final class ListBuffer[A] * one. Instead, it will insert a new element at index `n`. * * @param n the index where a new element will be inserted. - * @param iter the iterable object providing all elements to insert. + * @param seq the iterable object providing all elements to insert. * @throws Predef.IndexOutOfBoundsException if `n` is out of bounds. */ def insertAll(n: Int, seq: Traversable[A]) { @@ -338,8 +338,8 @@ final class ListBuffer[A] /** Remove a single element from this buffer. May take time linear in the * buffer size. * - * @param x the element to remove. - * @return this $coll. + * @param elem the element to remove. + * @return this $coll. */ override def -= (elem: A): this.type = { if (exported) copy() diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala index df86545a70..fb76fa609f 100644 --- a/src/library/scala/collection/mutable/QueueProxy.scala +++ b/src/library/scala/collection/mutable/QueueProxy.scala @@ -49,7 +49,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy { /** Adds all elements provided by an iterator at the end of the queue. The * elements are prepended in the order they are given out by the iterator. * - * @param iter an iterator + * @param it an iterator */ override def ++=(it: TraversableOnce[A]): this.type = { self ++= it diff --git a/src/library/scala/collection/mutable/SeqLike.scala b/src/library/scala/collection/mutable/SeqLike.scala index 7194f15bc2..3a77558e94 100644 --- a/src/library/scala/collection/mutable/SeqLike.scala +++ b/src/library/scala/collection/mutable/SeqLike.scala @@ -28,8 +28,8 @@ trait SeqLike[A, +This <: SeqLike[A, This] with Seq[A]] /** Replaces element at given index with a new value. * - * @param n the index of the element to replace. - * @param lem the new value. + * @param idx the index of the element to replace. + * @param elem the new value. * @throws IndexOutOfBoundsException if the index is not valid. */ def update(idx: Int, elem: A) diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala index a14605d60a..1c34046e88 100644 --- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala +++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala @@ -61,7 +61,7 @@ trait SynchronizedBuffer[A] extends Buffer[A] { /** Appends a number of elements provided by a traversable object * via its `foreach` method. * - * @param iter the iterable object. + * @param xs the iterable object. */ override def ++=(xs: TraversableOnce[A]): this.type = synchronized[this.type] { super.++=(xs) @@ -102,7 +102,7 @@ trait SynchronizedBuffer[A] extends Buffer[A] { /** Prepend an element to this list. * - * @param elem the element to prepend. + * @param elems the elements to prepend. */ override def prepend(elems: A*): Unit = prependAll(elems) diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 4cb229fc0f..321f259f5d 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -491,8 +491,8 @@ self: ParIterableLike[T, Repr, Sequential] => * * $abortsignalling * - * @param p a predicate used to test elements - * @return true if `p` holds for all elements, false otherwise + * @param pred a predicate used to test elements + * @return true if `p` holds for all elements, false otherwise */ def forall(pred: T => Boolean): Boolean = { tasksupport.executeAndWaitResult(new Forall(pred, splitter assign new DefaultSignalling with VolatileAbort)) @@ -502,8 +502,8 @@ self: ParIterableLike[T, Repr, Sequential] => * * $abortsignalling * - * @param p a predicate used to test elements - * @return true if `p` holds for some element, false otherwise + * @param pred a predicate used to test elements + * @return true if `p` holds for some element, false otherwise */ def exists(pred: T => Boolean): Boolean = { tasksupport.executeAndWaitResult(new Exists(pred, splitter assign new DefaultSignalling with VolatileAbort)) @@ -517,8 +517,8 @@ self: ParIterableLike[T, Repr, Sequential] => * * $abortsignalling * - * @param p predicate used to test the elements - * @return an option value with the element if such an element exists, or `None` otherwise + * @param pred predicate used to test the elements + * @return an option value with the element if such an element exists, or `None` otherwise */ def find(pred: T => Boolean): Option[T] = { tasksupport.executeAndWaitResult(new Find(pred, splitter assign new DefaultSignalling with VolatileAbort)) @@ -685,7 +685,7 @@ self: ParIterableLike[T, Repr, Sequential] => * @tparam That type of the resulting collection * @param z neutral element for the operator `op` * @param op the associative operator for the scan - * @param cbf combiner factory which provides a combiner + * @param bf $bfinfo * @return a collection containing the prefix scan of the elements in the original collection * * @usecase def scan(z: T)(op: (T, T) => T): $Coll[T] diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala index b3c527da84..be5ab03ba7 100644 --- a/src/library/scala/collection/parallel/ParSeqLike.scala +++ b/src/library/scala/collection/parallel/ParSeqLike.scala @@ -162,7 +162,7 @@ self => * * $abortsignalling * - * @tparam U the element type of `that` parallel sequence + * @tparam S the element type of `that` parallel sequence * @param that the parallel sequence this sequence is being searched for * @param offset the starting offset for the search * @return `true` if there is a sequence `that` starting at `offset` in this sequence, `false` otherwise @@ -287,9 +287,7 @@ self => /** Computes the multiset intersection between this $coll and another sequence. * * @param that the sequence of elements to intersect with. - * @tparam B the element type of the returned $coll. - * @tparam That $thatinfo - * @param bf $bfinfo + * @tparam U the element type of `that` parallel sequence * @return a new collection of type `That` which contains all elements of this $coll * which also appear in `that`. * If an element value `x` appears diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index c5910ff2c8..a67a4d8eb7 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -39,8 +39,7 @@ private[collection] trait RemainsIterator[+T] extends Iterator[T] { /** Augments iterators with additional methods, mostly transformers, * assuming they iterate an iterable collection. * - * @param T type of the elements iterated. - * @param IterRepr iterator type. + * @tparam T type of the elements iterated. */ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[T] { @@ -377,7 +376,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter /** Parallel iterators allow splitting and provide a `remaining` method to * obtain the number of elements remaining in the iterator. * - * @param T type of the elements iterated. + * @tparam T type of the elements iterated. */ trait IterableSplitter[+T] extends AugmentedIterableIterator[T] @@ -537,7 +536,7 @@ self => /** Parallel sequence iterators allow splitting into arbitrary subsets. * - * @param T type of the elements iterated. + * @tparam T type of the elements iterated. */ trait SeqSplitter[+T] extends IterableSplitter[T] diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 05b3f89fa1..8d39d6e0de 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -26,7 +26,8 @@ import collection.parallel.Task * `ParHashMap` is a parallel map which internally keeps elements within a hash table. * It uses chaining to resolve collisions. * - * @tparam T type of the elements in the parallel hash map + * @tparam K type of the keys in the parallel hash map + * @tparam V type of the values in the parallel hash map * * @define Coll `ParHashMap` * @define coll parallel hash map diff --git a/src/library/scala/concurrent/Channel.scala b/src/library/scala/concurrent/Channel.scala index f6d6341151..7aeccd8d05 100644 --- a/src/library/scala/concurrent/Channel.scala +++ b/src/library/scala/concurrent/Channel.scala @@ -25,7 +25,6 @@ class Channel[A] { private var nreaders = 0 /** - * @param x ... */ def write(x: A) = synchronized { lastWritten.elem = x diff --git a/src/library/scala/concurrent/ConcurrentPackageObject.scala b/src/library/scala/concurrent/ConcurrentPackageObject.scala index a3d985733e..c3c329121c 100644 --- a/src/library/scala/concurrent/ConcurrentPackageObject.scala +++ b/src/library/scala/concurrent/ConcurrentPackageObject.scala @@ -11,7 +11,6 @@ package scala.concurrent import java.util.concurrent.{ Executors, ExecutorService, ThreadFactory } import scala.concurrent.forkjoin.{ ForkJoinPool, ForkJoinWorkerThread } import scala.concurrent.util.Duration -import ConcurrentPackageObject._ import language.implicitConversions @@ -36,19 +35,6 @@ abstract class ConcurrentPackageObject { case _ => true } - private[concurrent] def resolveEither[T](source: Either[Throwable, T]): Either[Throwable, T] = source match { - case Left(t) => resolver(t) - case _ => source - } - - private[concurrent] def resolver[T](throwable: Throwable): Either[Throwable, T] = throwable match { - case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value.asInstanceOf[T]) - case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) - case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) - case e: Error => Left(new ExecutionException("Boxed Error", e)) - case t => Left(t) - } - /* concurrency constructs */ /** Starts an asynchronous computation and returns a `Future` object with the result of that computation. @@ -102,18 +88,3 @@ abstract class ConcurrentPackageObject { @inline implicit final def int2durationops(x: Int): DurationOps = new DurationOps(x) } - -private[concurrent] object ConcurrentPackageObject { - // TODO, docs, return type - // Note that having this in the package object led to failures when - // compiling a subset of sources; it seems that the wildcard is not - // properly handled, and you get messages like "type _$1 defined twice". - // This is consistent with other package object breakdowns. - // private val resolverFunction: PartialFunction[Throwable, Either[Throwable, _]] = { - // case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value) - // case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) - // case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) - // case e: Error => Left(new ExecutionException("Boxed Error", e)) - // case t => Left(t) - // } -} diff --git a/src/library/scala/concurrent/ExecutionContext.scala b/src/library/scala/concurrent/ExecutionContext.scala index 4666674b5b..d2a2d5e8a8 100644 --- a/src/library/scala/concurrent/ExecutionContext.scala +++ b/src/library/scala/concurrent/ExecutionContext.scala @@ -54,8 +54,7 @@ object ExecutionContext { def fromExecutor(e: Executor, reporter: Throwable => Unit = defaultReporter): ExecutionContext with Executor = new impl.ExecutionContextImpl(e, reporter) def defaultReporter: Throwable => Unit = { - // `Error`s are currently wrapped by `resolver`. - // Also, re-throwing `Error`s here causes an exception handling test to fail. + // re-throwing `Error`s here causes an exception handling test to fail. //case e: Error => throw e case t => t.printStackTrace() } diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 70b3c3dbbb..2f90afe056 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -191,7 +191,7 @@ trait Future[+T] extends Awaitable[T] { * this future. If this future is completed with an exception then the new * future will also contain this exception. * - * $forComprehensionExample + * $forComprehensionExamples */ def map[S](f: T => S): Future[S] = { val p = Promise[S]() @@ -201,7 +201,7 @@ trait Future[+T] extends Awaitable[T] { case Right(v) => try p success f(v) catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -213,7 +213,7 @@ trait Future[+T] extends Awaitable[T] { * If this future is completed with an exception then the new future will * also contain this exception. * - * $forComprehensionExample + * $forComprehensionExamples */ def flatMap[S](f: T => Future[S]): Future[S] = { val p = Promise[S]() @@ -227,7 +227,7 @@ trait Future[+T] extends Awaitable[T] { case Right(v) => p success v } } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -260,7 +260,7 @@ trait Future[+T] extends Awaitable[T] { if (pred(v)) p success v else p failure new NoSuchElementException("Future.filter predicate is not satisfied by: " + v) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -309,7 +309,7 @@ trait Future[+T] extends Awaitable[T] { if (pf.isDefinedAt(v)) p success pf(v) else p failure new NoSuchElementException("Future.collect partial function is not defined at: " + v) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -334,7 +334,9 @@ trait Future[+T] extends Awaitable[T] { onComplete { case Left(t) if pf isDefinedAt t => try { p success pf(t) } - catch { case NonFatal(t) => p complete resolver(t) } + catch { + case NonFatal(t) => p failure t + } case otherwise => p complete otherwise } @@ -362,7 +364,7 @@ trait Future[+T] extends Awaitable[T] { try { p completeWith pf(t) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } case otherwise => p complete otherwise } diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala index f7ec0714cf..2e9de4a0d0 100644 --- a/src/library/scala/concurrent/Promise.scala +++ b/src/library/scala/concurrent/Promise.scala @@ -66,7 +66,7 @@ trait Promise[T] { /** Completes the promise with a value. * - * @param value The value to complete the promise with. + * @param v The value to complete the promise with. * * $promiseCompletion */ @@ -106,7 +106,7 @@ object Promise { /** Creates a promise object which can be completed with a value. * * @tparam T the type of the value in the promise - * @param execctx the execution context on which the promise is created on + * @param executor the execution context on which the promise is created on * @return the newly created `Promise` object */ def apply[T]()(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.DefaultPromise[T]() @@ -114,7 +114,7 @@ object Promise { /** Creates an already completed Promise with the specified exception. * * @tparam T the type of the value in the promise - * @param execctx the execution context on which the promise is created on + * @param executor the execution context on which the promise is created on * @return the newly created `Promise` object */ def failed[T](exception: Throwable)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Left(exception)) @@ -122,7 +122,7 @@ object Promise { /** Creates an already completed Promise with the specified result. * * @tparam T the type of the value in the promise - * @param execctx the execution context on which the promise is created on + * @param executor the execution context on which the promise is created on * @return the newly created `Promise` object */ def successful[T](result: T)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Right(result)) diff --git a/src/library/scala/concurrent/Scheduler.scala b/src/library/scala/concurrent/Scheduler.scala index e2eb4d69fe..6645abcc4e 100644 --- a/src/library/scala/concurrent/Scheduler.scala +++ b/src/library/scala/concurrent/Scheduler.scala @@ -35,7 +35,7 @@ trait Scheduler { /** Schedules a thunk for execution after a given delay. * * @param delay the duration after which the thunk should be executed - * @param thunk the thunk that is scheduled for execution + * @param task the thunk that is scheduled for execution * @return a `Cancellable` that may be used to cancel the execution * of the thunk */ diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 7dc3ed2988..3ed960c7ab 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -10,10 +10,10 @@ package scala.concurrent.impl -import java.util.concurrent.{Callable, Executor, ExecutorService, Executors, ThreadFactory} +import java.util.concurrent.{ Callable, Executor, ExecutorService, Executors, ThreadFactory } import scala.concurrent.forkjoin._ -import scala.concurrent.{ExecutionContext, resolver, Awaitable} -import scala.concurrent.util.{ Duration } +import scala.concurrent.{ ExecutionContext, Awaitable } +import scala.concurrent.util.Duration diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala index 20d4122e8f..bf136b6195 100644 --- a/src/library/scala/concurrent/impl/Future.scala +++ b/src/library/scala/concurrent/impl/Future.scala @@ -57,7 +57,7 @@ private[concurrent] object Future { case NonFatal(e) => // Commenting out reporting for now, since it produces too much output in the tests //executor.reportFailure(e) - scala.concurrent.resolver(e) + Left(e) } } }) diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index da70b3dea5..5a5b893f16 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -11,7 +11,7 @@ package scala.concurrent.impl import java.util.concurrent.TimeUnit.{ NANOSECONDS, MILLISECONDS } -import scala.concurrent.{Awaitable, ExecutionContext, resolveEither, resolver, blocking, CanAwait, TimeoutException} +import scala.concurrent.{ Awaitable, ExecutionContext, blocking, CanAwait, TimeoutException, ExecutionException } //import scala.util.continuations._ import scala.concurrent.util.Duration import scala.util @@ -26,6 +26,20 @@ private[concurrent] trait Promise[T] extends scala.concurrent.Promise[T] with Fu object Promise { + + private def resolveEither[T](source: Either[Throwable, T]): Either[Throwable, T] = source match { + case Left(t) => resolver(t) + case _ => source + } + + private def resolver[T](throwable: Throwable): Either[Throwable, T] = throwable match { + case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value.asInstanceOf[T]) + case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) + case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) + case e: Error => Left(new ExecutionException("Boxed Error", e)) + case t => Left(t) + } + /** Default promise implementation. */ class DefaultPromise[T](implicit val executor: ExecutionContext) extends AbstractPromise with Promise[T] { self => diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index 5e09e13680..319e021f04 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -100,8 +100,6 @@ object Source { /** Create a `Source` from array of bytes, decoding * the bytes according to codec. * - * @param bytes ... - * @param enc ... * @return the created `Source` instance. */ def fromBytes(bytes: Array[Byte])(implicit codec: Codec): Source = diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index ff52ca9bec..af2ab04576 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -71,11 +71,7 @@ object BigInt { new BigInt(new BigInteger(bitlength, certainty, rnd.self)) /** Constructs a randomly generated BigInt, uniformly distributed over the - * range 0 to (2 ^ numBits - 1), inclusive. - * - * @param numbits ... - * @param rnd ... - * @return ... + * range `0` to `(2 ^ numBits - 1)`, inclusive. */ def apply(numbits: Int, rnd: scala.util.Random): BigInt = new BigInt(new BigInteger(numbits, rnd.self)) @@ -87,10 +83,6 @@ object BigInt { /** Translates the string representation of a `BigInt` in the * specified `radix` into a BigInt. - * - * @param x ... - * @param radix ... - * @return ... */ def apply(x: String, radix: Int): BigInt = new BigInt(new BigInteger(x, radix)) diff --git a/src/library/scala/parallel/Future.scala b/src/library/scala/parallel/Future.scala index f61d376093..8b71794756 100644 --- a/src/library/scala/parallel/Future.scala +++ b/src/library/scala/parallel/Future.scala @@ -12,6 +12,8 @@ package scala.parallel /** A future is a function without parameters that will block the caller if * the parallel computation associated with the function is not completed. + * + * @tparam R the type of the result * * @since 2.9 */ @@ -23,7 +25,6 @@ trait Future[@specialized +R] extends (() => R) { * '''Note:''' creating a circular dependency between futures by calling * this method will result in a deadlock. * - * @tparam R the type of the result * @return the result * @throws the exception that was thrown during a parallel computation */ diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala index ca4e60f3f6..3427136fde 100644 --- a/src/library/scala/reflect/api/Trees.scala +++ b/src/library/scala/reflect/api/Trees.scala @@ -727,7 +727,7 @@ trait Trees { self: Universe => def Ident(sym: Symbol): Ident /** Marks underlying reference to id as boxed. - * @pre: id must refer to a captured variable + * @pre id must refer to a captured variable * A reference such marked will refer to the boxed entity, no dereferencing * with `.elem` is done on it. * This tree node can be emitted by macros such as reify that call referenceCapturedVariable. diff --git a/src/library/scala/reflect/api/Types.scala b/src/library/scala/reflect/api/Types.scala index 5c7563c2c5..3d42242641 100755 --- a/src/library/scala/reflect/api/Types.scala +++ b/src/library/scala/reflect/api/Types.scala @@ -111,10 +111,12 @@ trait Types { self: Universe => * Proceed analogously for thistypes referring to outer classes. * * Example: + * {{{ * class D[T] { def m: T } * class C extends p.D[Int] * T.asSeenFrom(ThisType(C), D) (where D is owner of m) * = Int + * }}} */ def asSeenFrom(pre: Type, clazz: Symbol): Type @@ -481,10 +483,6 @@ trait Types { self: Universe => def refinedType(parents: List[Type], owner: Symbol, decls: Scope, pos: Position): Type /** The canonical creator for a refined type with an initially empty scope. - * - * @param parents ... - * @param owner ... - * @return ... */ def refinedType(parents: List[Type], owner: Symbol): Type diff --git a/src/library/scala/reflect/api/Universe.scala b/src/library/scala/reflect/api/Universe.scala index 9670780522..05b5963c73 100755 --- a/src/library/scala/reflect/api/Universe.scala +++ b/src/library/scala/reflect/api/Universe.scala @@ -28,18 +28,23 @@ abstract class Universe extends Symbols * * For instance, given the abstract syntax tree representation of the <[ x + 1 ]> expression: * + * {{{ * Apply(Select(Ident("x"), "+"), List(Literal(Constant(1)))) + * }}} * * The reifier transforms it to the following expression: - * + * + * {{{ * <[ * val $mr: scala.reflect.api.Universe = <reference to the Universe that calls the reify> * $mr.Expr[Int]($mr.Apply($mr.Select($mr.Ident($mr.newFreeVar("x", <Int>, x), "+"), List($mr.Literal($mr.Constant(1)))))) * ]> + * }}} * * Reification performs expression splicing (when processing Expr.eval and Expr.value) * and type splicing (for every type T that has a TypeTag[T] implicit in scope): * + * {{{ * val two = mirror.reify(2) // Literal(Constant(2)) * val four = mirror.reify(two.eval + two.eval) // Apply(Select(two.tree, newTermName("$plus")), List(two.tree)) * @@ -51,6 +56,7 @@ abstract class Universe extends Symbols * val factory = c.reify{ new Queryable[T] } * ... * } + * }}} * * The transformation looks mostly straightforward, but it has its tricky parts: * * Reifier retains symbols and types defined outside the reified tree, however diff --git a/src/library/scala/runtime/BoxesRunTime.java b/src/library/scala/runtime/BoxesRunTime.java index 258a176671..8fe9a017d0 100644 --- a/src/library/scala/runtime/BoxesRunTime.java +++ b/src/library/scala/runtime/BoxesRunTime.java @@ -228,7 +228,7 @@ public final class BoxesRunTime * as yet have not. * * Note: Among primitives, Float.NaN != Float.NaN, but the boxed - * verisons are equal. This still needs reconciliation. + * versions are equal. This still needs reconciliation. */ public static int hashFromLong(java.lang.Long n) { int iv = n.intValue(); @@ -242,6 +242,9 @@ public final class BoxesRunTime long lv = n.longValue(); if (lv == dv) return java.lang.Long.valueOf(lv).hashCode(); + + float fv = n.floatValue(); + if (fv == dv) return java.lang.Float.valueOf(fv).hashCode(); else return n.hashCode(); } public static int hashFromFloat(java.lang.Float n) { diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala index f702b9e3da..396323d1e8 100644 --- a/src/library/scala/runtime/RichDouble.scala +++ b/src/library/scala/runtime/RichDouble.scala @@ -18,14 +18,12 @@ final class RichDouble(val self: Double) extends FractionalProxy[Double] { /** Converts an angle measured in degrees to an approximately equivalent * angle measured in radians. * - * @param x an angle, in degrees * @return the measurement of the angle x in radians. */ def toRadians: Double = math.toRadians(self) /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees. - * @param x angle, in radians * @return the measurement of the angle x in degrees. */ def toDegrees: Double = math.toDegrees(self) diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala index 6b72a9dd55..4fc9e8864a 100644 --- a/src/library/scala/runtime/RichFloat.scala +++ b/src/library/scala/runtime/RichFloat.scala @@ -18,7 +18,6 @@ final class RichFloat(val self: Float) extends FractionalProxy[Float] { /** Converts an angle measured in degrees to an approximately equivalent * angle measured in radians. * - * @param x an angle, in degrees * @return the measurement of the angle `x` in radians. */ def toRadians: Float = math.toRadians(self).toFloat @@ -26,7 +25,6 @@ final class RichFloat(val self: Float) extends FractionalProxy[Float] { /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees. * - * @param x angle, in radians * @return the measurement of the angle `x` in degrees. */ def toDegrees: Float = math.toDegrees(self).toFloat diff --git a/src/library/scala/runtime/Statics.java b/src/library/scala/runtime/Statics.java new file mode 100644 index 0000000000..485511ecbb --- /dev/null +++ b/src/library/scala/runtime/Statics.java @@ -0,0 +1,89 @@ +package scala.runtime; + +/** Not for public consumption. Usage by the runtime only. + */ + +public final class Statics { + public static int mix(int hash, int data) { + int h = mixLast(hash, data); + h = Integer.rotateLeft(h, 13); + return h * 5 + 0xe6546b64; + } + + public static int mixLast(int hash, int data) { + int k = data; + + k *= 0xcc9e2d51; + k = Integer.rotateLeft(k, 15); + k *= 0x1b873593; + + return hash ^ k; + } + + public static int finalizeHash(int hash, int length) { + return avalanche(hash ^ length); + } + + /** Force all bits of the hash to avalanche. Used for finalizing the hash. */ + public static int avalanche(int h) { + h ^= h >>> 16; + h *= 0x85ebca6b; + h ^= h >>> 13; + h *= 0xc2b2ae35; + h ^= h >>> 16; + + return h; + } + + public static int longHash(long lv) { + if ((int)lv == lv) + return (int)lv; + else + return (int)(lv ^ (lv >>> 32)); + } + + public static int doubleHash(double dv) { + int iv = (int)dv; + if (iv == dv) + return iv; + + float fv = (float)dv; + if (fv == dv) + return java.lang.Float.floatToIntBits(fv); + + long lv = (long)dv; + if (lv == dv) + return (int)lv; + + lv = Double.doubleToLongBits(dv); + return (int)(lv ^ (lv >>> 32)); + } + + public static int floatHash(float fv) { + int iv = (int)fv; + if (iv == fv) + return iv; + + long lv = (long)fv; + if (lv == fv) + return (int)(lv^(lv>>>32)); + + return java.lang.Float.floatToIntBits(fv); + } + + public static int anyHash(Object x) { + if (x == null) + return 0; + + if (x instanceof java.lang.Long) + return longHash(((java.lang.Long)x).longValue()); + + if (x instanceof java.lang.Double) + return doubleHash(((java.lang.Double)x).doubleValue()); + + if (x instanceof java.lang.Float) + return floatHash(((java.lang.Float)x).floatValue()); + + return x.hashCode(); + } +} diff --git a/src/library/scala/sys/Prop.scala b/src/library/scala/sys/Prop.scala index 33b88f119f..687a32cf7d 100644 --- a/src/library/scala/sys/Prop.scala +++ b/src/library/scala/sys/Prop.scala @@ -38,7 +38,7 @@ trait Prop[+T] { /** Sets the property. * - * @param the new string value + * @param newValue the new string value * @return the old value, or null if it was unset. */ def set(newValue: String): String diff --git a/src/library/scala/sys/package.scala b/src/library/scala/sys/package.scala index 16faded419..b27da8e61d 100644 --- a/src/library/scala/sys/package.scala +++ b/src/library/scala/sys/package.scala @@ -69,8 +69,8 @@ package object sys { * * Note that shutdown hooks are NOT guaranteed to be run. * - * @param the body of code to run at shutdown - * @return the Thread which will run the shutdown hook. + * @param body the body of code to run at shutdown + * @return the Thread which will run the shutdown hook. */ def addShutdownHook(body: => Unit): ShutdownHookThread = ShutdownHookThread(body) diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index c8e31766ea..9acae34d4e 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -49,9 +49,6 @@ trait Benchmark { /** Run the benchmark the specified number of times and return a list with * the execution times in milliseconds in reverse order of the execution. - * - * @param noTimes ... - * @return ... */ def runBenchmark(noTimes: Int): List[Long] = for (i <- List.range(1, noTimes + 1)) yield { diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index c0a54799a3..6a0fca40ca 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -33,9 +33,6 @@ abstract class Document { /** * Format this document on `writer` and try to set line * breaks so that the result fits in `width` columns. - * - * @param width ... - * @param writer ... */ def format(width: Int, writer: Writer) { type FmtState = (Int, Boolean, Document) diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala index e2ebe7851c..209cd6c062 100644 --- a/src/library/scala/util/Marshal.scala +++ b/src/library/scala/util/Marshal.scala @@ -16,6 +16,7 @@ package scala.util * @author Stephane Micheloud * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") object Marshal { import java.io._ import scala.reflect.ClassTag diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 17c356801b..65a1b8c685 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -101,8 +101,7 @@ class Random(val self: java.util.Random) { /** Returns a new collection of the same type in a randomly chosen order. * - * @param coll the [[scala.collection.TraversableOnce]] to shuffle - * @return the shuffled [[scala.collection.TraversableOnce]] + * @return the shuffled collection */ def shuffle[T, CC[X] <: TraversableOnce[X]](xs: CC[T])(implicit bf: CanBuildFrom[CC[T], T, CC[T]]): CC[T] = { val buf = new ArrayBuffer[T] ++= xs diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index c78b2d0790..d8d260c478 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -17,6 +17,7 @@ import scala.collection.{ mutable, immutable } * [[scala.util.automata.NondetWordAutom]] over `A` using the celebrated * position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). */ +@deprecated("This class will be removed", "2.10.0") abstract class BaseBerrySethi { val lang: Base import lang.{ Alt, Eps, Meta, RegExp, Sequ, Star } @@ -54,9 +55,6 @@ abstract class BaseBerrySethi { /** Starts from the right-to-left * precondition: pos is final * pats are successor patterns of a Sequence node - * - * @param r ... - * @return ... */ protected def compFollow(rs: Seq[RegExp]): Set[Int] = { follow(0) = @@ -72,10 +70,6 @@ abstract class BaseBerrySethi { } /** Returns the first set of an expression, setting the follow set along the way. - * - * @param fol1 ... - * @param r ... - * @return ... */ protected def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { case x: Alt => Set((x.rs reverseMap (compFollow1(fol1, _))).flatten: _*) @@ -92,8 +86,6 @@ abstract class BaseBerrySethi { } /** Returns the "Sethi-length" of a pattern, creating the set of position along the way. - * - * @param r ... */ protected def traverse(r: RegExp): Unit = r match { // (is tree automaton stuff, more than Berry-Sethi) diff --git a/src/library/scala/util/automata/DetWordAutom.scala b/src/library/scala/util/automata/DetWordAutom.scala index 16c5d2944b..c6d72f1a06 100644 --- a/src/library/scala/util/automata/DetWordAutom.scala +++ b/src/library/scala/util/automata/DetWordAutom.scala @@ -20,6 +20,7 @@ import scala.collection.{ mutable, immutable } * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") abstract class DetWordAutom[T <: AnyRef] { val nstates: Int val finals: Array[Int] diff --git a/src/library/scala/util/automata/Inclusion.scala b/src/library/scala/util/automata/Inclusion.scala index 63133998b4..4eaf1dfc02 100644 --- a/src/library/scala/util/automata/Inclusion.scala +++ b/src/library/scala/util/automata/Inclusion.scala @@ -17,14 +17,12 @@ package scala.util.automata * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") trait Inclusion[A <: AnyRef] { val labels: Seq[A] /** Returns true if `dfa1` is included in `dfa2`. - * - * @param dfa1 ... - * @param dfa2 ... */ def inclusion(dfa1: DetWordAutom[A], dfa2: DetWordAutom[A]) = { diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala index b09e82ca11..3b6f0b251a 100644 --- a/src/library/scala/util/automata/NondetWordAutom.scala +++ b/src/library/scala/util/automata/NondetWordAutom.scala @@ -17,6 +17,7 @@ import scala.collection.{ immutable, mutable } * All states are reachable. Accepting states are those for which * the partial function `finals` is defined. */ +@deprecated("This class will be removed", "2.10.0") abstract class NondetWordAutom[T <: AnyRef] { val nstates: Int val labels: Seq[T] diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/util/automata/SubsetConstruction.scala index 81805fce2f..1cdcd734cd 100644 --- a/src/library/scala/util/automata/SubsetConstruction.scala +++ b/src/library/scala/util/automata/SubsetConstruction.scala @@ -10,6 +10,7 @@ package scala.util.automata import scala.collection.{ mutable, immutable } +@deprecated("This class will be removed", "2.10.0") class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { import nfa.labels diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index a7ad92e648..1d4d1f971f 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -17,6 +17,7 @@ import scala.util.regexp.WordExp * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") abstract class WordBerrySethi extends BaseBerrySethi { override val lang: WordExp @@ -52,7 +53,6 @@ abstract class WordBerrySethi extends BaseBerrySethi { /** Returns the first set of an expression, setting the follow set along * the way. * - * @param fol1 ... * @param r the regular expression * @return the computed set */ diff --git a/src/library/scala/util/grammar/HedgeRHS.scala b/src/library/scala/util/grammar/HedgeRHS.scala index 8fb3d4c5dc..da109f41c5 100644 --- a/src/library/scala/util/grammar/HedgeRHS.scala +++ b/src/library/scala/util/grammar/HedgeRHS.scala @@ -10,13 +10,17 @@ package scala.util.grammar +@deprecated("This class will be removed", "2.10.0") abstract class HedgeRHS /** Right hand side of a hedge production, deriving a single tree. */ +@deprecated("This class will be removed", "2.10.0") case class ConsRHS(tnt: Int, hnt: Int) extends HedgeRHS /** Right hand side of a hedge production, deriving any hedge. */ +@deprecated("This class will be removed", "2.10.0") case object AnyHedgeRHS extends HedgeRHS /** Right hand side of a hedge production, deriving the empty hedge. */ +@deprecated("This class will be removed", "2.10.0") case object EmptyHedgeRHS extends HedgeRHS diff --git a/src/library/scala/util/grammar/TreeRHS.scala b/src/library/scala/util/grammar/TreeRHS.scala index ebe16b25bd..d6e7c01588 100644 --- a/src/library/scala/util/grammar/TreeRHS.scala +++ b/src/library/scala/util/grammar/TreeRHS.scala @@ -11,9 +11,12 @@ package scala.util.grammar /** Right hand side of a tree production. */ +@deprecated("This class will be removed", "2.10.0") abstract class TreeRHS /** Right hand side of a tree production, labelled with a letter from an alphabet. */ +@deprecated("This class will be removed", "2.10.0") case class LabelledRHS[A](label: A, hnt: Int) extends TreeRHS +@deprecated("This class will be removed", "2.10.0") case object AnyTreeRHS extends TreeRHS diff --git a/src/library/scala/util/parsing/ast/AbstractSyntax.scala b/src/library/scala/util/parsing/ast/AbstractSyntax.scala index 220643a0d7..67e8a87221 100644 --- a/src/library/scala/util/parsing/ast/AbstractSyntax.scala +++ b/src/library/scala/util/parsing/ast/AbstractSyntax.scala @@ -14,6 +14,7 @@ import scala.util.parsing.input.Positional * * @author Adriaan Moors */ +@deprecated("This class will be removed", "2.10.0") trait AbstractSyntax { /** The base class for elements of the abstract syntax tree. */ diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala index 09ad5ce2ab..b93c24fde4 100644 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ b/src/library/scala/util/parsing/ast/Binders.scala @@ -24,6 +24,7 @@ import language.implicitConversions * * @author Adriaan Moors */ +@deprecated("This class will be removed", "2.10.0") trait Mappable { trait Mapper { def apply[T <% Mappable[T]](x: T): T } /* TODO: having type `Forall T. T => T` is too strict: sometimes we want to allow `Forall T >: precision. T => T` for some type `precision`, so that, @@ -325,11 +326,11 @@ trait Binders extends AbstractSyntax with Mappable { // TODO: move this to some utility object higher in the scala hierarchy? /** Returns a given result, but executes the supplied closure before returning. * (The effect of this closure does not influence the returned value.) - * - * @param result the result to be returned - * @param block code to be executed, purely for its side-effects */ trait ReturnAndDo[T]{ + /** + * @param block code to be executed, purely for its side-effects + */ def andDo(block: => Unit): T } diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala index 255730e5db..ff3554a6af 100644 --- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala +++ b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala @@ -5,10 +5,14 @@ import scala.util.parsing.combinator._ import scala.util.parsing.input._ import language.postfixOps +@deprecated("This class will be removed", "2.10.0") case class Ident(s: String) +@deprecated("This class will be removed", "2.10.0") case class Number(n: Int) +@deprecated("This class will be removed", "2.10.0") case class Str(s: String) +@deprecated("This class will be removed", "2.10.0") object RegexTest extends RegexParsers { val ident: Parser[Any] = """[a-zA-Z_]\w*""".r ^^ (s => Ident(s)) val number: Parser[Any] = """\d\d*""".r ^^ (s => Number(s.toInt)) diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala index 4607dc8843..1b98d63289 100644 --- a/src/library/scala/util/parsing/combinator/testing/Tester.scala +++ b/src/library/scala/util/parsing/combinator/testing/Tester.scala @@ -28,6 +28,7 @@ import scala.util.parsing.combinator.syntactical.TokenParsers * @author Martin Odersky * @author Adriaan Moors */ +@deprecated("This class will be removed", "2.10.0") abstract class Tester { val syntactic: TokenParsers { val lexical: Lexical } diff --git a/src/library/scala/util/parsing/input/CharArrayReader.scala b/src/library/scala/util/parsing/input/CharArrayReader.scala index e798c9883a..63d76c9382 100644 --- a/src/library/scala/util/parsing/input/CharArrayReader.scala +++ b/src/library/scala/util/parsing/input/CharArrayReader.scala @@ -21,10 +21,8 @@ object CharArrayReader { /** A character array reader reads a stream of characters (keeping track of their positions) * from an array. * - * @param source an array of characters + * @param chars an array of characters * @param index starting offset into the array; the first element returned will be `source(index)` - * @param line the line number of the first element (counting from index `0` of `source`) - * @param column the column number of the first element (counting from index `0` of `source`) * * @author Martin Odersky * @author Adriaan Moors diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala index c2483c44e3..57a2c9c4c2 100644 --- a/src/library/scala/util/parsing/input/OffsetPosition.scala +++ b/src/library/scala/util/parsing/input/OffsetPosition.scala @@ -45,10 +45,9 @@ case class OffsetPosition(source: java.lang.CharSequence, offset: Int) extends P /** The column number referred to by the position; column numbers start at 1. */ def column: Int = offset - index(line - 1) + 1 - /** The contents of the line numbered `lnum` (must not contain a new-line character). + /** The contents of the line numbered at the current offset. * - * @param lnum a 1-based integer index into the `document` - * @return the line at `lnum` (not including a newline) + * @return the line at `offset` (not including a newline) */ def lineContents: String = source.subSequence(index(line - 1), index(line)).toString @@ -59,7 +58,7 @@ case class OffsetPosition(source: java.lang.CharSequence, offset: Int) extends P /** Compare this position to another, by first comparing their line numbers, * and then -- if necessary -- using the columns to break a tie. * - * @param `that` a `Position` to compare to this `Position` + * @param that a `Position` to compare to this `Position` * @return true if this position's line number or (in case of equal line numbers) * column is smaller than the corresponding components of `that` */ diff --git a/src/library/scala/util/parsing/input/PagedSeqReader.scala b/src/library/scala/util/parsing/input/PagedSeqReader.scala index 134cf0a79a..284afef57b 100644 --- a/src/library/scala/util/parsing/input/PagedSeqReader.scala +++ b/src/library/scala/util/parsing/input/PagedSeqReader.scala @@ -23,7 +23,7 @@ object PagedSeqReader { /** A character array reader reads a stream of characters (keeping track of their positions) * from an array. * - * @param source the source sequence + * @param seq the source sequence * @param offset starting offset. * * @author Martin Odersky diff --git a/src/library/scala/util/parsing/input/Position.scala b/src/library/scala/util/parsing/input/Position.scala index be817013a0..9cb0031746 100644 --- a/src/library/scala/util/parsing/input/Position.scala +++ b/src/library/scala/util/parsing/input/Position.scala @@ -27,10 +27,7 @@ trait Position { /** The column number referred to by the position; column numbers start at 1. */ def column: Int - /** The contents of the line numbered `lnum` (must not contain a new-line character). - * - * @param lnum a 1-based integer index into the `document` - * @return the line at `lnum` (not including a newline) + /** The contents of the line at this position. (must not contain a new-line character). */ protected def lineContents: String diff --git a/src/library/scala/util/parsing/input/Positional.scala b/src/library/scala/util/parsing/input/Positional.scala index ff9d81d4e5..2e9163d5ad 100644 --- a/src/library/scala/util/parsing/input/Positional.scala +++ b/src/library/scala/util/parsing/input/Positional.scala @@ -12,6 +12,7 @@ package scala.util.parsing.input * * @author Martin Odersky, Adriaan Moors */ +@deprecated("This class will be removed", "2.10.0") trait Positional { /** The source position of this object, initially set to undefined. */ diff --git a/src/library/scala/util/parsing/input/StreamReader.scala b/src/library/scala/util/parsing/input/StreamReader.scala index 8244177359..3858dc3210 100644 --- a/src/library/scala/util/parsing/input/StreamReader.scala +++ b/src/library/scala/util/parsing/input/StreamReader.scala @@ -13,14 +13,16 @@ import scala.collection.immutable.PagedSeq /** An object to create a `StreamReader` from a `java.io.Reader`. * - * @param in the `java.io.Reader` that provides the underlying - * stream of characters for this Reader. - * * @author Miles Sabin */ object StreamReader { final val EofCh = '\032' + /** Create a `StreamReader` from a `java.io.Reader`. + * + * @param in the `java.io.Reader` that provides the underlying + * stream of characters for this Reader. + */ def apply(in: java.io.Reader): StreamReader = { new StreamReader(PagedSeq.fromReader(in), 0, 1) } diff --git a/src/library/scala/util/regexp/Base.scala b/src/library/scala/util/regexp/Base.scala index 8e23d46eb9..81962ea8bd 100644 --- a/src/library/scala/util/regexp/Base.scala +++ b/src/library/scala/util/regexp/Base.scala @@ -15,8 +15,9 @@ package scala.util.regexp * @author Burak Emir * @version 1.0 */ -abstract class Base -{ + +@deprecated("This class will be removed", "2.10.0") +abstract class Base { type _regexpT <: RegExp abstract class RegExp { diff --git a/src/library/scala/util/regexp/PointedHedgeExp.scala b/src/library/scala/util/regexp/PointedHedgeExp.scala index 23aa46448c..056031a339 100644 --- a/src/library/scala/util/regexp/PointedHedgeExp.scala +++ b/src/library/scala/util/regexp/PointedHedgeExp.scala @@ -15,6 +15,7 @@ package scala.util.regexp * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") abstract class PointedHedgeExp extends Base { type _regexpT <: RegExp diff --git a/src/library/scala/util/regexp/SyntaxError.scala b/src/library/scala/util/regexp/SyntaxError.scala index 0f5c2af187..c19dfe126e 100644 --- a/src/library/scala/util/regexp/SyntaxError.scala +++ b/src/library/scala/util/regexp/SyntaxError.scala @@ -16,4 +16,5 @@ package scala.util.regexp * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") class SyntaxError(e: String) extends RuntimeException(e) diff --git a/src/library/scala/util/regexp/WordExp.scala b/src/library/scala/util/regexp/WordExp.scala index cf146934d1..05674f118c 100644 --- a/src/library/scala/util/regexp/WordExp.scala +++ b/src/library/scala/util/regexp/WordExp.scala @@ -38,6 +38,7 @@ package scala.util.regexp * @author Burak Emir * @version 1.0 */ +@deprecated("This class will be removed", "2.10.0") abstract class WordExp extends Base { abstract class Label diff --git a/src/library/scala/xml/Atom.scala b/src/library/scala/xml/Atom.scala index 72572fb5e4..7bed714f68 100644 --- a/src/library/scala/xml/Atom.scala +++ b/src/library/scala/xml/Atom.scala @@ -37,9 +37,6 @@ class Atom[+A](val data: A) extends SpecialNode with Serializable { /** Returns text, with some characters escaped according to the XML * specification. - * - * @param sb ... - * @return ... */ def buildString(sb: StringBuilder): StringBuilder = Utility.escape(data.toString, sb) diff --git a/src/library/scala/xml/Comment.scala b/src/library/scala/xml/Comment.scala index 014cead47c..9ce053190a 100644 --- a/src/library/scala/xml/Comment.scala +++ b/src/library/scala/xml/Comment.scala @@ -11,7 +11,7 @@ package scala.xml /** The class `Comment` implements an XML node for comments. * * @author Burak Emir - * @param text the text contained in this node, may not contain "--" + * @param commentText the text contained in this node, may not contain "--" */ case class Comment(commentText: String) extends SpecialNode { diff --git a/src/library/scala/xml/EntityRef.scala b/src/library/scala/xml/EntityRef.scala index 60feeb845d..66438135c8 100644 --- a/src/library/scala/xml/EntityRef.scala +++ b/src/library/scala/xml/EntityRef.scala @@ -12,7 +12,7 @@ package scala.xml * * @author Burak Emir * @version 1.0 - * @param text the text contained in this node. + * @param entityName the name of the entity reference, for example `amp`. */ case class EntityRef(entityName: String) extends SpecialNode { final override def doCollectNamespaces = false diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala index b44a817499..e98ec90aca 100644 --- a/src/library/scala/xml/MetaData.scala +++ b/src/library/scala/xml/MetaData.scala @@ -102,7 +102,6 @@ extends AbstractIterable[MetaData] * @param namespace_uri namespace uri of key * @param owner the element owning this attribute list * @param key the attribute key - * @return ... */ final def apply(namespace_uri: String, owner: Node, key: String): Seq[Node] = apply(namespace_uri, owner.scope, key) @@ -112,15 +111,12 @@ extends AbstractIterable[MetaData] * * @param namespace_uri namespace uri of key * @param scp a namespace scp (usually of the element owning this attribute list) - * @param key to be looked fore + * @param k to be looked for * @return value as Seq[Node] if key is found, null otherwise */ - def apply(namespace_uri:String, scp:NamespaceBinding, k:String): Seq[Node] + def apply(namespace_uri: String, scp: NamespaceBinding, k: String): Seq[Node] /** returns a copy of this MetaData item with next field set to argument. - * - * @param next ... - * @return ... */ def copy(next: MetaData): MetaData @@ -208,31 +204,13 @@ extends AbstractIterable[MetaData] } /** - * @param scope ... - * @return `'''true'''` iff ... */ def wellformed(scope: NamespaceBinding): Boolean - /** - * @param key ... - * @return ... - */ def remove(key: String): MetaData - /** - * @param namespace ... - * @param scope ... - * @param key ... - * @return ... - */ def remove(namespace: String, scope: NamespaceBinding, key: String): MetaData - /** - * @param namespace ... - * @param owner ... - * @param key ... - * @return ... - */ final def remove(namespace: String, owner: Node, key: String): MetaData = remove(namespace, owner.scope, key) } diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala index 02e34e1bdc..7fca644730 100755 --- a/src/library/scala/xml/Node.scala +++ b/src/library/scala/xml/Node.scala @@ -155,8 +155,7 @@ abstract class Node extends NodeSeq { /** * String representation of this node * - * @param stripComment if true, strips comment nodes from result - * @return ... + * @param stripComments if true, strips comment nodes from result */ def buildString(stripComments: Boolean): String = Utility.serialize(this, stripComments = stripComments).toString @@ -170,9 +169,6 @@ abstract class Node extends NodeSeq { /** * Appends qualified name of this node to `StringBuilder`. - * - * @param sb ... - * @return ... */ def nameToString(sb: StringBuilder): StringBuilder = { if (null != prefix) { diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index f0be338fcf..40ddc7d85c 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -88,9 +88,6 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S * There is no support for searching a prefixed attribute by its literal prefix. * * The document order is preserved. - * - * @param that ... - * @return ... */ def \(that: String): NodeSeq = { def fail = throw new IllegalArgumentException(that) @@ -138,9 +135,6 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S * There is no support for searching a prefixed attribute by its literal prefix. * * The document order is preserved. - * - * @param that ... - * @return ... */ def \\ (that: String): NodeSeq = { def filt(cond: (Node) => Boolean) = this flatMap (_.descendant_or_self) filter cond diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index b80d6a1c73..5cab113d85 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -11,10 +11,10 @@ package scala.xml /** prefixed attributes always have a non-null namespace. * - * @param pre ... - * @param key ... + * @param pre + * @param key * @param value the attribute value - * @param next ... + * @param next1 */ class PrefixedAttribute( val pre: String, diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 64dbd00f2f..da82aca33a 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -42,10 +42,6 @@ class PrettyPrinter(width: Int, step: Int) { } /** Try to cut at whitespace. - * - * @param s ... - * @param ind ... - * @return ... */ protected def cut(s: String, ind: Int): List[Item] = { val tmp = width - cur @@ -74,10 +70,6 @@ class PrettyPrinter(width: Int, step: Int) { } /** Try to make indented box, if possible, else para. - * - * @param ind ... - * @param s ... - * @return ... */ protected def makeBox(ind: Int, s: String) = if (cur + s.length > width) { // fits in this line @@ -99,10 +91,6 @@ class PrettyPrinter(width: Int, step: Int) { cur = 0 } - /** - * @param n ... - * @return ... - */ protected def leafTag(n: Node) = { def mkLeaf(sb: StringBuilder) { sb append '<' @@ -149,7 +137,6 @@ class PrettyPrinter(width: Int, step: Int) { private def doPreserve(node: Node) = node.attribute(XML.namespace, XML.space).map(_.toString == XML.preserve) getOrElse false - /** @param tail: what we'd like to sqeeze in */ protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit = node match { case Text(s) if s.trim() == "" => @@ -210,7 +197,6 @@ class PrettyPrinter(width: Int, step: Int) { * given namespace to prefix mapping to the given string buffer. * * @param n the node to be serialized - * @param pmap the namespace to prefix mapping * @param sb the stringbuffer to append to */ def format(n: Node, sb: StringBuilder) { // entry point @@ -250,9 +236,9 @@ class PrettyPrinter(width: Int, step: Int) { /** Returns a formatted string containing well-formed XML with * given namespace to prefix mapping. * - * @param n the node to be serialized - * @param pmap the namespace to prefix mapping - * @return ... + * @param n the node to be serialized + * @param pscope the namespace to prefix mapping + * @return the formatted string */ def format(n: Node, pscope: NamespaceBinding = null): String = sbToString(format(n, pscope, _)) diff --git a/src/library/scala/xml/ProcInstr.scala b/src/library/scala/xml/ProcInstr.scala index b3f4ba9186..152bcf989f 100644 --- a/src/library/scala/xml/ProcInstr.scala +++ b/src/library/scala/xml/ProcInstr.scala @@ -12,8 +12,8 @@ package scala.xml /** an XML node for processing instructions (PI) * * @author Burak Emir - * @param target target name of this PI - * @param text text contained in this node, may not contain "?>" + * @param target target name of this PI + * @param proctext text contained in this node, may not contain "?>" */ case class ProcInstr(target: String, proctext: String) extends SpecialNode { diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala index bcd5fc731f..3d62afb2ef 100644 --- a/src/library/scala/xml/TextBuffer.scala +++ b/src/library/scala/xml/TextBuffer.scala @@ -25,9 +25,6 @@ class TextBuffer val sb = new StringBuilder() /** Appends this string to the text buffer, trimming whitespaces as needed. - * - * @param cs ... - * @return ... */ def append(cs: Seq[Char]): this.type = { cs foreach { c => diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 062a62e240..17c91fa52c 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -77,9 +77,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Escapes the characters < > & and " from string. - * - * @param text ... - * @return ... */ final def escape(text: String): String = sbToString(escape(text, _)) @@ -102,10 +99,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Appends escaped string to `s`. - * - * @param text ... - * @param s ... - * @return ... */ final def escape(text: String, s: StringBuilder): StringBuilder = { // Implemented per XML spec: @@ -135,8 +128,6 @@ object Utility extends AnyRef with parsing.TokenTests { * Appends unescaped string to `s`, `amp` becomes `&`, * `lt` becomes `<` etc.. * - * @param ref ... - * @param s ... * @return `'''null'''` if `ref` was not a predefined entity. */ final def unescape(ref: String, s: StringBuilder): StringBuilder = @@ -145,18 +136,12 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Returns a set of all namespaces used in a sequence of nodes * and all their descendants, including the empty namespaces. - * - * @param nodes ... - * @return ... */ def collectNamespaces(nodes: Seq[Node]): mutable.Set[String] = nodes.foldLeft(new mutable.HashSet[String]) { (set, x) => collectNamespaces(x, set) ; set } /** * Adds all namespaces in node to set. - * - * @param n ... - * @param set ... */ def collectNamespaces(n: Node, set: mutable.Set[String]) { if (n.doCollectNamespaces) { @@ -273,9 +258,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Returns prefix of qualified name if any. - * - * @param name ... - * @return ... */ final def prefix(name: String): Option[String] = (name indexOf ':') match { case -1 => None @@ -284,11 +266,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Returns a hashcode for the given constituents of a node - * - * @param uri - * @param label - * @param attribHashCode - * @param children */ def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = scala.util.MurmurHash3.orderedHash(label +: attribHashCode +: scpeHash +: children, pre.##) @@ -298,10 +275,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Appends "s" if string `s` does not contain ", * 's' otherwise. - * - * @param s ... - * @param sb ... - * @return ... */ def appendQuoted(s: String, sb: StringBuilder) = { val ch = if (s contains '"') '\'' else '"' @@ -310,10 +283,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Appends "s" and escapes and " i s with \" - * - * @param s ... - * @param sb ... - * @return ... */ def appendEscapedQuoted(s: String, sb: StringBuilder): StringBuilder = { sb.append('"') @@ -324,11 +293,6 @@ object Utility extends AnyRef with parsing.TokenTests { sb.append('"') } - /** - * @param s ... - * @param index ... - * @return ... - */ def getName(s: String, index: Int): String = { if (index >= s.length) null else { @@ -341,9 +305,6 @@ object Utility extends AnyRef with parsing.TokenTests { /** * Returns `'''null'''` if the value is a correct attribute value, * error message if it isn't. - * - * @param value ... - * @return ... */ def checkAttributeValue(value: String): String = { var i = 0 @@ -365,12 +326,6 @@ object Utility extends AnyRef with parsing.TokenTests { null } - /** - * new - * - * @param value ... - * @return ... - */ def parseAttributeValue(value: String): Seq[Node] = { val sb = new StringBuilder var rfb: StringBuilder = null @@ -426,11 +381,6 @@ object Utility extends AnyRef with parsing.TokenTests { * | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";" * }}} * See [66] - * - * @param ch ... - * @param nextch ... - * @param reportSyntaxError ... - * @return ... */ def parseCharRef(ch: () => Char, nextch: () => Unit, reportSyntaxError: String => Unit, reportTruncatedError: String => Unit): String = { val hex = (ch() == 'x') && { nextch(); true } diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index f0ef09b901..64aa7e2f74 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -14,7 +14,7 @@ package dtd * * @author Burak Emir * - * @param target name of this DOCTYPE + * @param name name of this DOCTYPE * @param extID None, or Some(external ID of this doctype) * @param intSubset sequence of internal subset declarations */ diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index fdde18a926..a0a5818d07 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -41,7 +41,7 @@ abstract class ExternalID extends parsing.TokenTests /** a system identifier * * @author Burak Emir - * @param systemLiteral the system identifier literal + * @param systemId the system identifier literal */ case class SystemID(systemId: String) extends ExternalID { val publicId = null @@ -54,8 +54,8 @@ case class SystemID(systemId: String) extends ExternalID { /** a public identifier (see http://www.w3.org/QA/2002/04/valid-dtd-list.html). * * @author Burak Emir - * @param publicLiteral the public identifier literal - * @param systemLiteral (can be null for notation pubIDs) the system identifier literal + * @param publicId the public identifier literal + * @param systemId (can be null for notation pubIDs) the system identifier literal */ case class PublicID(publicId: String, systemId: String) extends ExternalID { if (!checkPubID(publicId)) diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 4bd0336a26..52ddf6b476 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -249,7 +249,7 @@ class XIncludeFilter extends XMLFilterImpl { * calls to `characters()`. It's used to include files with `parse="text"`. * * @param url URL of the document that will be read - * @param encoding Encoding of the document; e.g. UTF-8, + * @param encoding1 Encoding of the document; e.g. UTF-8, * ISO-8859-1, etc. * @return void * @throws SAXException if the requested document cannot diff --git a/src/library/scala/xml/parsing/ExternalSources.scala b/src/library/scala/xml/parsing/ExternalSources.scala index ca6cea4c67..127d66bf6f 100644 --- a/src/library/scala/xml/parsing/ExternalSources.scala +++ b/src/library/scala/xml/parsing/ExternalSources.scala @@ -23,11 +23,6 @@ import scala.io.Source trait ExternalSources { self: ExternalSources with MarkupParser with MarkupHandler => - /** ... - * - * @param systemId ... - * @return ... - */ def externalSource(systemId: String): Source = { if (systemId startsWith "http:") return Source fromURL new URL(systemId) diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala index 5aad0e7ce1..507a14a418 100644 --- a/src/library/scala/xml/parsing/FactoryAdapter.scala +++ b/src/library/scala/xml/parsing/FactoryAdapter.scala @@ -158,7 +158,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node /** End element. * @param uri - * @param localName + * @param _localName * @param qname * @throws org.xml.sax.SAXException if .. */ diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala index 83db2f177d..8d66fd0a7f 100755 --- a/src/library/scala/xml/parsing/MarkupHandler.scala +++ b/src/library/scala/xml/parsing/MarkupHandler.scala @@ -64,7 +64,6 @@ abstract class MarkupHandler extends Logged * @param pos the position in the source file * @param pre the prefix * @param label the local name - * @param attrs the attributes (metadata) */ def elemEnd(pos: Int, pre: String, label: String): Unit = () @@ -77,7 +76,6 @@ abstract class MarkupHandler extends Logged * @param attrs the attributes (metadata) * @param empty `true` if the element was previously empty; `false` otherwise. * @param args the children of this element - * @return ... */ def elem(pos: Int, pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, empty: Boolean, args: NodeSeq): NodeSeq diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala index c6da4bb546..096f8a8f38 100644 --- a/src/library/scala/xml/parsing/MarkupParserCommon.scala +++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala @@ -54,8 +54,8 @@ private[scala] trait MarkupParserCommon extends TokenTests { xTakeUntil(mkProcInstr(_, n, _), () => tmppos, "?>") } - /** attribute value, terminated by either ' or ". value may not contain <. - * @param endch either ' or " + /** attribute value, terminated by either `'` or `"`. value may not contain `<`. + @param endCh either `'` or `"` */ def xAttributeValue(endCh: Char): String = { val buf = new StringBuilder diff --git a/src/library/scala/xml/pull/XMLEvent.scala b/src/library/scala/xml/pull/XMLEvent.scala index dff81e8ed6..58d7d9fac5 100644 --- a/src/library/scala/xml/pull/XMLEvent.scala +++ b/src/library/scala/xml/pull/XMLEvent.scala @@ -38,7 +38,7 @@ case class EvElemEnd(pre: String, label: String) extends XMLEvent case class EvText(text: String) extends XMLEvent /** An entity reference was encountered. - * @param the name of the entity, e.g. `gt` when encountering the entity `>` + * @param entity the name of the entity, e.g. `gt` when encountering the entity `>` */ case class EvEntityRef(entity: String) extends XMLEvent diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala index 002f86abe7..0ae417a7f8 100644 --- a/src/library/scala/xml/transform/BasicTransformer.scala +++ b/src/library/scala/xml/transform/BasicTransformer.scala @@ -18,11 +18,6 @@ package transform */ abstract class BasicTransformer extends Function1[Node,Node] { - /** - * @param n ... - * @param ns ... - * @return ... - */ protected def unchanged(n: Node, ns: Seq[Node]) = ns.length == 1 && (ns.head == n) diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala index 750e270c18..5d994eeb37 100644 --- a/src/partest/scala/tools/partest/nest/SBTRunner.scala +++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala @@ -54,15 +54,17 @@ object SBTRunner extends DirectRunner { val config = parseArgs(args, CommandLineOptions()) fileManager.SCALAC_OPTS = config.scalacOptions fileManager.CLASSPATH = config.classpath getOrElse sys.error("No classpath set") + + def findClasspath(jar: String, name: String): Option[String] = { + val optJar = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches (".*"+jar+".*\\.jar"))).headOption + val optClassDir = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches (".*"+name+File.separator+"classes"))).headOption + optJar orElse optClassDir + } // Find scala library jar file... - val lib: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-library.*\\.jar")).headOption - fileManager.LATEST_LIB = lib getOrElse sys.error("No scala-library found! Classpath = " + fileManager.CLASSPATH) - val comp: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-compiler.*\\.jar")).headOption - fileManager.LATEST_COMP = comp getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH) - val partest: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-partest.*\\.jar")).headOption - fileManager.LATEST_PARTEST = partest getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH) - val actors: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-actors.*\\.jar")).headOption - fileManager.LATEST_ACTORS = actors getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH) + fileManager.LATEST_LIB = findClasspath("scala-library", "scala-library") getOrElse sys.error("No scala-library found! Classpath = " + fileManager.CLASSPATH) + fileManager.LATEST_COMP = findClasspath("scala-compiler", "scala-compiler") getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH) + fileManager.LATEST_PARTEST = findClasspath("scala-partest", "partest") getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH) + fileManager.LATEST_ACTORS = findClasspath("scala-actors", "actors") getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH) // TODO - Do something useful here!!! fileManager.JAVAC_CMD = "javac" |