From d614ae6e76249ab746a3e78af6e216301ba9bdb4 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 19 Aug 2012 18:25:35 +0200 Subject: SI-6258 Reject partial funs with undefined param types This regressed with virtpatmat. With -Xoldpatmat, pattern matching anonymous functions with an expected type of PartialFunction[A, B] are translated to a Function tree, and typed by typedFunction, which issues an error of the parameter types are not fully defined. This commit adds the same check to MatchFunTyper. It doesn't plug the hole in RefChecks#validateVariance (which is reminiscent of SI-3577.) Seems to me that in general one should handle: a) both BoundedWildcardType and WildcardType when in a place that can be called during inference, or b) neither otherwise --- test/files/neg/t6258.check | 16 ++++++++++++++++ test/files/neg/t6258.scala | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/files/neg/t6258.check create mode 100644 test/files/neg/t6258.scala (limited to 'test') diff --git a/test/files/neg/t6258.check b/test/files/neg/t6258.check new file mode 100644 index 0000000000..73363d8280 --- /dev/null +++ b/test/files/neg/t6258.check @@ -0,0 +1,16 @@ +t6258.scala:2: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?, Int] + val f : PartialFunction[_, Int] = { case a : Int => a } // undefined param + ^ +t6258.scala:5: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?,Int] + foo { case a : Int => a } // undefined param + ^ +t6258.scala:22: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?,Any] + bar[M[Any]] (foo { // undefined param + ^ +three errors found diff --git a/test/files/neg/t6258.scala b/test/files/neg/t6258.scala new file mode 100644 index 0000000000..5046a4750a --- /dev/null +++ b/test/files/neg/t6258.scala @@ -0,0 +1,25 @@ +object Test { + val f : PartialFunction[_, Int] = { case a : Int => a } // undefined param + + def foo[A](pf: PartialFunction[A, Int]) {}; + foo { case a : Int => a } // undefined param + + val g : PartialFunction[Int, _] = { case a : Int => a } // okay +} + + +// Another variation, seen in the wild with Specs2. +class X { + trait Matcher[-T] + + def bar[T](m: Matcher[T]) = null + def bar[T](i: Int) = null + + def foo[T](p: PartialFunction[T, Any]): Matcher[T] = null + + case class M[X](a: X) + + bar[M[Any]] (foo { // undefined param + case M(_) => null + }) +} -- cgit v1.2.3 From 455526f52c0d7a98f2b0bef8f29e7fb542bfe600 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 16 Aug 2012 15:03:33 -0700 Subject: Large logging cleanup effort. Quieted down many logging statements which contribute disproportionate noise. Made others emit something more sensible. Spent lots of time on the inliner trying to find a regular format to make the logs more readable. Long way to go here but it'd be so worth it to have readable logs instead of mind-numbing indiscriminate text dumps. --- src/compiler/scala/tools/nsc/Global.scala | 5 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 56 ++--- .../backend/icode/analysis/CopyPropagation.scala | 8 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 4 +- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 4 +- .../tools/nsc/backend/opt/ClosureElimination.scala | 27 ++- .../nsc/backend/opt/DeadCodeElimination.scala | 21 +- .../nsc/backend/opt/InlineExceptionHandlers.scala | 5 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 229 +++++++++++---------- .../scala/tools/nsc/interpreter/IMain.scala | 3 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 13 +- .../scala/tools/nsc/transform/AddInterfaces.scala | 20 +- .../scala/tools/nsc/transform/Erasure.scala | 8 +- .../scala/tools/nsc/transform/Flatten.scala | 16 +- .../scala/tools/nsc/transform/UnCurry.scala | 6 +- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- .../scala/reflect/internal/SymbolTable.scala | 2 + src/reflect/scala/reflect/internal/Symbols.scala | 2 +- test/files/run/compiler-asSeenFrom.check | 12 +- 19 files changed, 226 insertions(+), 217 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 80e9ede271..fd05229088 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -271,9 +271,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) log("Running operation '%s' after every phase.\n".format(msg) + describeAfterEveryPhase(op)) } - def shouldLogAtThisPhase = ( - (settings.log.isSetByUser) - && ((settings.log containsPhase globalPhase) || (settings.log containsPhase phase)) + override def shouldLogAtThisPhase = settings.log.isSetByUser && ( + (settings.log containsPhase globalPhase) || (settings.log containsPhase phase) ) // Over 200 closure objects are eliminated by inlining this. @inline final def log(msg: => AnyRef) { diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 431802d185..d3a5975a2a 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -125,7 +125,7 @@ abstract class GenICode extends SubComponent { // in companion object accessors to @static fields, we access the static field directly val hostClass = m.symbol.owner.companionClass val staticfield = hostClass.info.findMember(m.symbol.accessed.name, NoFlags, NoFlags, false) - + if (m.symbol.isGetter) { ctx1.bb.emit(LOAD_FIELD(staticfield, true) setHostClass hostClass, tree.pos) ctx1.bb.closeWith(RETURN(m.returnType)) @@ -659,16 +659,16 @@ abstract class GenICode extends SubComponent { } else { val sym = tree.symbol val local = ctx.method.addLocal(new Local(sym, toTypeKind(sym.info), false)) - + if (rhs == EmptyTree) { debuglog("Uninitialized variable " + tree + " at: " + (tree.pos)); ctx.bb.emit(getZeroOf(local.kind)) } - + var ctx1 = ctx if (rhs != EmptyTree) ctx1 = genLoad(rhs, ctx, local.kind); - + ctx1.bb.emit(STORE_LOCAL(local), tree.pos) ctx1.scope.add(local) ctx1.bb.emit(SCOPE_ENTER(local)) @@ -727,10 +727,10 @@ abstract class GenICode extends SubComponent { ctx1.bb.enterIgnoreMode generatedType = expectedType ctx1 - } + } genLoadReturn - case t @ Try(_, _, _) => + case t @ Try(_, _, _) => genLoadTry(t, ctx, generatedType = _) case Throw(expr) => @@ -750,7 +750,7 @@ abstract class GenICode extends SubComponent { case Object_asInstanceOf => true case _ => abort("Unexpected type application " + fun + "[sym: " + sym.fullName + "]" + " in: " + tree) } - + val Select(obj, _) = fun val l = toTypeKind(obj.tpe) val r = toTypeKind(targs.head.tpe) @@ -794,7 +794,7 @@ abstract class GenICode extends SubComponent { ctx.bb.emit(THIS(ctx.clazz.symbol), tree.pos) val ctx1 = genLoadArguments(args, fun.symbol.info.paramTypes, ctx) - + ctx1.bb.emit(CALL_METHOD(fun.symbol, invokeStyle), tree.pos) generatedType = if (fun.symbol.isConstructor) UNIT @@ -812,7 +812,7 @@ abstract class GenICode extends SubComponent { val ctor = fun.symbol debugassert(ctor.isClassConstructor, "'new' call to non-constructor: " + ctor.name) - + generatedType = toTypeKind(tpt.tpe) debugassert(generatedType.isReferenceType || generatedType.isArrayType, "Non reference type cannot be instantiated: " + generatedType) @@ -858,7 +858,7 @@ abstract class GenICode extends SubComponent { ctx1 } ctx2 - + case _ => abort("Cannot instantiate " + tpt + " of kind: " + generatedType) } @@ -899,7 +899,7 @@ abstract class GenICode extends SubComponent { ctx1 case app @ Apply(fun @ Select(qual, _), args) - if !ctx.method.symbol.isStaticConstructor + if !ctx.method.symbol.isStaticConstructor && fun.symbol.isAccessor && fun.symbol.accessed.hasStaticAnnotation && qual.tpe.typeSymbol.orElse(fun.symbol.owner).companionClass != NoSymbol => // bypass the accessor to the companion object and load the static field directly @@ -938,11 +938,11 @@ abstract class GenICode extends SubComponent { } } genLoadApply5 - + case app @ Apply(fun, args) => def genLoadApply6 = { val sym = fun.symbol - + if (sym.isLabel) { // jump to a label val label = ctx.labels.getOrElse(sym, { // it is a forward jump, scan for labels @@ -979,7 +979,7 @@ abstract class GenICode extends SubComponent { Static(true) else Dynamic - + var ctx1 = if (invokeStyle.hasInstance) { if (forMSIL && !(invokeStyle.isInstanceOf[SuperCall]) && msil_IsValuetypeInstMethod(sym)) @@ -987,24 +987,26 @@ abstract class GenICode extends SubComponent { else genLoadQualifier(fun, ctx) } else ctx - + ctx1 = genLoadArguments(args, sym.info.paramTypes, ctx1) val cm = CALL_METHOD(sym, invokeStyle) - + /** In a couple cases, squirrel away a little extra information in the * CALL_METHOD for use by GenJVM. */ fun match { case Select(qual, _) => val qualSym = findHostClass(qual.tpe, sym) - - if (qualSym == ArrayClass) cm setTargetTypeKind toTypeKind(qual.tpe) - else cm setHostClass qualSym - - log( - if (qualSym == ArrayClass) "Stored target type kind " + toTypeKind(qual.tpe) + " for " + sym.fullName - else s"Set more precise host class for ${sym.fullName} hostClass: $qualSym" - ) + if (qualSym == ArrayClass) { + val kind = toTypeKind(qual.tpe) + cm setTargetTypeKind kind + log(s"Stored target type kind for {$sym.fullName} as $kind") + } + else { + cm setHostClass qualSym + if (qual.tpe.typeSymbol != qualSym) + log(s"Precisified host class for $sym from ${qual.tpe.typeSymbol.fullName} to ${qualSym.fullName}") + } case _ => } ctx1.bb.emit(cm, tree.pos) @@ -1140,7 +1142,7 @@ abstract class GenICode extends SubComponent { val elmKind = toTypeKind(tpt.tpe) generatedType = ARRAY(elmKind) val elems = _elems.toIndexedSeq - + ctx1.bb.emit(CONSTANT(new Constant(elems.length)), tree.pos) ctx1.bb.emit(CREATE_ARRAY(elmKind, 1)) // inline array literals @@ -1163,7 +1165,7 @@ abstract class GenICode extends SubComponent { val afterCtx = ctx1.newBlock var caseCtx: Context = null generatedType = toTypeKind(tree.tpe) - + var targets: List[BasicBlock] = Nil var tags: List[Int] = Nil var default: BasicBlock = afterCtx.bb @@ -1190,7 +1192,7 @@ abstract class GenICode extends SubComponent { abort("Invalid case statement in switch-like pattern match: " + tree + " at: " + (tree.pos)) } - + caseCtx = genLoad(body, tmpCtx, generatedType) // close the block unless it's already been closed by the body, which closes the block if it ends in a jump (which is emitted to have alternatives share their body) caseCtx.bb.closeWith(JUMP(afterCtx.bb) setPos caze.pos) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index d1d8e4a385..df158a29ea 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -200,7 +200,7 @@ abstract class CopyPropagation { in(b) = lattice.bottom out(b) = lattice.bottom assert(out.contains(b), out) - log("Added point: " + b) + debuglog("CopyAnalysis added point: " + b) } m.exh foreach { e => in(e.startBlock) = new copyLattice.State(copyLattice.emptyBinding, copyLattice.exceptionHandlerStack); @@ -531,11 +531,11 @@ abstract class CopyPropagation { case 0 => () case 1 if ctor.tpe.paramTypes.head == ctor.owner.rawowner.tpe => // it's an unused outer - log("considering unused outer at position 0 in " + ctor.tpe.paramTypes) + debuglog("considering unused outer at position 0 in " + ctor.tpe.paramTypes) paramTypes = paramTypes.tail values = values.tail case _ => - log("giving up on " + ctor + "(diff: " + diff + ")") + debuglog("giving up on " + ctor + "(diff: " + diff + ")") return bindings } @@ -566,7 +566,7 @@ abstract class CopyPropagation { method.blocks map { b => "\nIN(%s):\t Bindings: %s".format(b.label, in(b).bindings) + "\nIN(%s):\t Stack: %s".format(b.label, in(b).stack) - } + } ).mkString } /* class CopyAnalysis */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index b57f5e86a3..ea0a0148e4 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -154,8 +154,10 @@ abstract class GenASM extends SubComponent with BytecodeWriters { inform("[running phase " + name + " on icode]") if (settings.Xdce.value) - for ((sym, cls) <- icodes.classes if inliner.isClosureClass(sym) && !deadCode.liveClosures(sym)) + for ((sym, cls) <- icodes.classes if inliner.isClosureClass(sym) && !deadCode.liveClosures(sym)) { + log(s"Optimizer eliminated ${sym.fullNameString}") icodes.classes -= sym + } // For predictably ordered error messages. var sortedClasses = classes.values.toList sortBy ("" + _.symbol.fullName) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 930791d88d..0f64a55d70 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -122,8 +122,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with inform("[running phase " + name + " on icode]") if (settings.Xdce.value) - for ((sym, cls) <- icodes.classes if inliner.isClosureClass(sym) && !deadCode.liveClosures(sym)) + for ((sym, cls) <- icodes.classes if inliner.isClosureClass(sym) && !deadCode.liveClosures(sym)) { + log(s"Optimizer eliminated ${sym.fullNameString}") icodes.classes -= sym + } // For predictably ordered error messages. val sortedClasses = classes.values.toList sortBy ("" + _.symbol.fullName) diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index 7772ccbdd5..eb2da72401 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -35,7 +35,7 @@ abstract class ClosureElimination extends SubComponent { case (STORE_LOCAL(x), LOAD_LOCAL(y)) if (x == y) => var liveOut = liveness.out(bb) if (!liveOut(x)) { - log("store/load to a dead local? " + x) + debuglog("store/load to a dead local? " + x) val instrs = bb.getArray var idx = instrs.length - 1 while (idx > 0 && (instrs(idx) ne i2)) { @@ -43,7 +43,7 @@ abstract class ClosureElimination extends SubComponent { idx -= 1 } if (!liveOut(x)) { - log("removing dead store/load " + x) + log("Removing dead store/load of " + x.sym.initialize.defString) Some(Nil) } else None } else @@ -84,6 +84,7 @@ abstract class ClosureElimination extends SubComponent { */ class ClosureElim { def analyzeClass(cls: IClass): Unit = if (settings.Xcloselim.value) { + log(s"Analyzing ${cls.methods.size} methods in $cls.") cls.methods foreach { m => analyzeMethod(m) peephole(m) @@ -95,7 +96,6 @@ abstract class ClosureElimination extends SubComponent { /* Some embryonic copy propagation. */ def analyzeMethod(m: IMethod): Unit = try {if (m.hasCode) { - log("Analyzing " + m) cpp.init(m) cpp.run @@ -110,23 +110,20 @@ abstract class ClosureElimination extends SubComponent { t match { case Deref(This) | Const(_) => bb.replaceInstruction(i, valueToInstruction(t)); - log("replaced " + i + " with " + t) + debuglog(s"replaced $i with $t") case _ => - bb.replaceInstruction(i, LOAD_LOCAL(info.getAlias(l))) - log("replaced " + i + " with " + info.getAlias(l)) - + val t = info.getAlias(l) + bb.replaceInstruction(i, LOAD_LOCAL(t)) + debuglog(s"replaced $i with $t") } case LOAD_FIELD(f, false) /* if accessible(f, m.symbol) */ => def replaceFieldAccess(r: Record) { val Record(cls, bindings) = r - info.getFieldNonRecordValue(r, f) match { - case Some(v) => - bb.replaceInstruction(i, - DROP(REFERENCE(cls)) :: valueToInstruction(v) :: Nil); - log("Replaced " + i + " with " + info.getFieldNonRecordValue(r, f)); - case None => + info.getFieldNonRecordValue(r, f) foreach { v => + bb.replaceInstruction(i, DROP(REFERENCE(cls)) :: valueToInstruction(v) :: Nil) + debuglog(s"replaced $i with $v") } } @@ -157,14 +154,14 @@ abstract class ClosureElimination extends SubComponent { value match { case Boxed(LocalVar(loc2)) => bb.replaceInstruction(i, DROP(icodes.ObjectReference) :: valueToInstruction(info.getBinding(loc2)) :: Nil) - log("replaced " + i + " with " + info.getBinding(loc2)) + debuglog("replaced " + i + " with " + info.getBinding(loc2)) case _ => () } case Boxed(LocalVar(loc1)) :: _ => val loc2 = info.getAlias(loc1) bb.replaceInstruction(i, DROP(icodes.ObjectReference) :: valueToInstruction(Deref(LocalVar(loc2))) :: Nil) - log("replaced " + i + " with " + LocalVar(loc2)) + debuglog("replaced " + i + " with " + LocalVar(loc2)) case _ => } diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index fd949576e1..36a5d61cfb 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -44,6 +44,7 @@ abstract class DeadCodeElimination extends SubComponent { class DeadCode { def analyzeClass(cls: IClass) { + log(s"Analyzing ${cls.methods.size} methods in $cls.") cls.methods.foreach { m => this.method = m dieCodeDie(m) @@ -73,7 +74,7 @@ abstract class DeadCodeElimination extends SubComponent { def dieCodeDie(m: IMethod) { if (m.hasCode) { - log("dead code elimination on " + m); + debuglog("dead code elimination on " + m); dropOf.clear() m.code.blocks.clear() accessedLocals = m.params.reverse @@ -82,8 +83,10 @@ abstract class DeadCodeElimination extends SubComponent { mark sweep(m) accessedLocals = accessedLocals.distinct - if ((m.locals diff accessedLocals).nonEmpty) { - log("Removed dead locals: " + (m.locals diff accessedLocals)) + val diff = m.locals diff accessedLocals + if (diff.nonEmpty) { + val msg = diff.map(_.sym.name)mkString(", ") + log(s"Removed ${diff.size} dead locals: $msg") m.locals = accessedLocals.reverse } } @@ -126,7 +129,7 @@ abstract class DeadCodeElimination extends SubComponent { case RETURN(_) | JUMP(_) | CJUMP(_, _, _, _) | CZJUMP(_, _, _, _) | STORE_FIELD(_, _) | THROW(_) | LOAD_ARRAY_ITEM(_) | STORE_ARRAY_ITEM(_) | SCOPE_ENTER(_) | SCOPE_EXIT(_) | STORE_THIS(_) | LOAD_EXCEPTION(_) | SWITCH(_, _) | MONITOR_ENTER() | MONITOR_EXIT() => worklist += ((bb, idx)) - case CALL_METHOD(m1, _) if isSideEffecting(m1) => worklist += ((bb, idx)); log("marking " + m1) + case CALL_METHOD(m1, _) if isSideEffecting(m1) => worklist += ((bb, idx)); debuglog("marking " + m1) case CALL_METHOD(m1, SuperCall(_)) => worklist += ((bb, idx)) // super calls to constructor case DROP(_) => @@ -173,7 +176,7 @@ abstract class DeadCodeElimination extends SubComponent { instr match { case LOAD_LOCAL(l1) => for ((l2, bb1, idx1) <- defs((bb, idx)) if l1 == l2; if !useful(bb1)(idx1)) { - log("\tAdding " + bb1(idx1)) + debuglog("\tAdding " + bb1(idx1)) worklist += ((bb1, idx1)) } @@ -197,7 +200,7 @@ abstract class DeadCodeElimination extends SubComponent { case _ => for ((bb1, idx1) <- rdef.findDefs(bb, idx, instr.consumed) if !useful(bb1)(idx1)) { - log("\tAdding " + bb1(idx1)) + debuglog("\tAdding " + bb1(idx1)) worklist += ((bb1, idx1)) } } @@ -232,7 +235,7 @@ abstract class DeadCodeElimination extends SubComponent { } else { i match { case NEW(REFERENCE(sym)) => - log("skipped object creation: " + sym + "inside " + m) + log(s"Eliminated instantation of $sym inside $m") case _ => () } debuglog("Skipped: bb_" + bb + ": " + idx + "( " + i + ")") @@ -240,7 +243,7 @@ abstract class DeadCodeElimination extends SubComponent { } if (bb.nonEmpty) bb.close - else log("empty block encountered") + else log(s"empty block encountered in $m") } } @@ -252,7 +255,7 @@ abstract class DeadCodeElimination extends SubComponent { foreachWithIndex(bb.toList) { (i, idx) => if (!useful(bb)(idx)) { foreachWithIndex(i.consumedTypes.reverse) { (consumedType, depth) => - log("Finding definitions of: " + i + "\n\t" + consumedType + " at depth: " + depth) + debuglog("Finding definitions of: " + i + "\n\t" + consumedType + " at depth: " + depth) val defs = rdef.findDefs(bb, idx, 1, depth) for (d <- defs) { val (bb, idx) = d diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala index f1f597322e..98120f0614 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala @@ -93,10 +93,9 @@ abstract class InlineExceptionHandlers extends SubComponent { val startTime = System.currentTimeMillis currentClass = c - log("Starting " + c) + debuglog("Starting InlineExceptionHandlers on " + c) c.methods foreach applyMethod - - log("Finished " + c + "... " + (System.currentTimeMillis - startTime) + "ms") + debuglog("Finished InlineExceptionHandlers on " + c + "... " + (System.currentTimeMillis - startTime) + "ms") currentClass = null } diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 82d44a0e62..62bb23c3a7 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -44,7 +44,7 @@ abstract class Inliners extends SubComponent { import definitions.{ NullClass, NothingClass, ObjectClass, PredefModule, RuntimePackage, ScalaInlineClass, ScalaNoInlineClass, - isFunctionType + isFunctionType, isByNameParamType } val phaseName = "inliner" @@ -143,7 +143,6 @@ abstract class Inliners extends SubComponent { } def isBottomType(sym: Symbol) = sym == NullClass || sym == NothingClass - def posToStr(pos: scala.reflect.internal.util.Position) = if (pos.isDefined) pos.point.toString else "" /** Is the given class a closure? */ def isClosureClass(cls: Symbol): Boolean = @@ -194,6 +193,27 @@ abstract class Inliners extends SubComponent { private var currentIClazz: IClass = _ private def warn(pos: Position, msg: String) = currentIClazz.cunit.inlinerWarning(pos, msg) + private def ownedName(sym: Symbol): String = afterUncurry { + val count = ( + if (!sym.isMethod) 1 + else if (sym.owner.isAnonymousFunction) 3 + else 2 + ) + (sym.ownerChain take count filterNot (_.isPackageClass)).reverseMap(_.nameString).mkString(".") + } + private def inlineLog(what: String, main: => String, comment: => String) { + def cstr = comment match { + case "" => "" + case str => " // " + str + } + val width = if (currentIClazz eq null) 40 else currentIClazz.symbol.enclosingPackage.fullName.length + 25 + val fmt = "%8s %-" + width + "s" + cstr + log(fmt.format(what, main)) + } + private def inlineLog(what: String, main: Symbol, comment: => String) { + inlineLog(what, ownedName(main), comment) + } + val recentTFAs = mutable.Map.empty[Symbol, Tuple2[Boolean, analysis.MethodTFA]] private def getRecentTFA(incm: IMethod, forceable: Boolean): (Boolean, analysis.MethodTFA) = { @@ -244,14 +264,15 @@ abstract class Inliners extends SubComponent { def analyzeClass(cls: IClass): Unit = if (settings.inline.value) { - debuglog("Analyzing " + cls) + inlineLog("class", s"${cls.symbol.decodedName}", s"analyzing ${cls.methods.size} methods in $cls") this.currentIClazz = cls val ms = cls.methods sorted imethodOrdering ms foreach { im => - if(hasInline(im.symbol)) { - log("Not inlining into " + im.symbol.originalName.decode + " because it is marked @inline.") - } else if(im.hasCode && !im.symbol.isBridge) { + if (hasInline(im.symbol)) { + inlineLog("skip", im.symbol, "no inlining into @inline methods") + } + else if(im.hasCode && !im.symbol.isBridge) { analyzeMethod(im) } } @@ -296,6 +317,8 @@ abstract class Inliners extends SubComponent { * */ def analyzeMethod(m: IMethod): Unit = { // m.normalize + if (settings.debug.value) + inlineLog("caller", ownedName(m.symbol), "in " + m.symbol.owner.fullName) var sizeBeforeInlining = m.code.blockCount var instrBeforeInlining = m.code.instructionCount @@ -306,8 +329,8 @@ abstract class Inliners extends SubComponent { val fresh = mutable.HashMap.empty[String, Int] withDefaultValue 0 // how many times have we already inlined this method here? val inlinedMethodCount = mutable.HashMap.empty[Symbol, Int] withDefaultValue 0 - val caller = new IMethodInfo(m) + def analyzeMessage = s"Analyzing ${caller.length} blocks of $m for inlining sites." def preInline(isFirstRound: Boolean): Int = { val inputBlocks = caller.m.linearizedBlocks() @@ -354,15 +377,17 @@ abstract class Inliners extends SubComponent { */ def analyzeInc(i: CALL_METHOD, bb: BasicBlock, receiver: Symbol, stackLength: Int, concreteMethod: Symbol): Boolean = { assert(bb.toList contains i, "Candidate callsite does not belong to BasicBlock.") - - var inlined = false val shouldWarn = hasInline(i.method) - def warnNoInline(reason: String) = { - if (shouldWarn) { - warn(i.pos, "Could not inline required method %s because %s.".format(i.method.originalName.decode, reason)) - } - } + def warnNoInline(reason: String): Boolean = { + def msg = "Could not inline required method %s because %s.".format(i.method.originalName.decode, reason) + if (settings.debug.value) + inlineLog("fail", i.method.fullName, reason) + if (shouldWarn) + warn(i.pos, msg) + + false + } var isAvailable = icodes available concreteMethod.enclClass @@ -378,92 +403,69 @@ abstract class Inliners extends SubComponent { isAvailable = icodes.load(concreteMethod.enclClass) } - def isCandidate = ( - isClosureClass(receiver) - || concreteMethod.isEffectivelyFinal - || receiver.isEffectivelyFinal - ) + def isCandidate = ( + isClosureClass(receiver) + || concreteMethod.isEffectivelyFinal + || receiver.isEffectivelyFinal + ) - def isApply = concreteMethod.name == nme.apply + def isApply = concreteMethod.name == nme.apply - def isCountable = !( - isClosureClass(receiver) - || isApply - || isMonadicMethod(concreteMethod) - || receiver.enclosingPackage == definitions.RuntimePackage - ) // only count non-closures + def isCountable = !( + isClosureClass(receiver) + || isApply + || isMonadicMethod(concreteMethod) + || receiver.enclosingPackage == definitions.RuntimePackage + ) // only count non-closures debuglog("Treating " + i + "\n\treceiver: " + receiver + "\n\ticodes.available: " + isAvailable + "\n\tconcreteMethod.isEffectivelyFinal: " + concreteMethod.isEffectivelyFinal) - if (isAvailable && isCandidate) { - lookupIMethod(concreteMethod, receiver) match { - - case Some(callee) if callee.hasCode => - val inc = new IMethodInfo(callee) - val pair = new CallerCalleeInfo(caller, inc, fresh, inlinedMethodCount) - - if(inc.hasHandlers && (stackLength == -1)) { - // no inlining is done, yet don't warn about it, stackLength == -1 indicates we're trying to inlineWithoutTFA. - // Shortly, a TFA will be computed and an error message reported if indeed inlining not possible. - return false - } - - (pair isStampedForInlining stackLength) match { - - case inlInfo if inlInfo.isSafe => - - (inlInfo: @unchecked) match { - - case FeasibleInline(accessNeeded, toBecomePublic) => - for(f <- toBecomePublic) { - debuglog("Making public (synthetic) field-symbol: " + f) - f setFlag Flags.notPRIVATE - f setFlag Flags.notPROTECTED - } - // only add to `knownSafe` after all `toBecomePublic` fields actually made public. - if(accessNeeded == NonPublicRefs.Public) { tfa.knownSafe += inc.sym } - - case InlineableAtThisCaller => () - - } + if (!isCandidate) warnNoInline("it can be overridden") + else if (!isAvailable) warnNoInline("bytecode unavailable") + else lookupIMethod(concreteMethod, receiver) filter (callee => callee.hasCode || warnNoInline("callee has no code")) exists { callee => + val inc = new IMethodInfo(callee) + val pair = new CallerCalleeInfo(caller, inc, fresh, inlinedMethodCount) - retry = true - inlined = true - if (isCountable) { count += 1 }; - - pair.doInline(bb, i) - if (!pair.isInlineForced || inc.isMonadic) { caller.inlinedCalls += 1 }; - inlinedMethodCount(inc.sym) += 1 - - // Remove the caller from the cache (this inlining might have changed its calls-private relation). - usesNonPublics -= m - recentTFAs -= m.symbol - - - case DontInlineHere(msg) => - debuglog("inline failed, reason: " + msg) - warnNoInline(msg) - - case NeverSafeToInline => () - } - - case Some(callee) => - assert(!callee.hasCode, "The case clause right before this one should have handled this case.") - warnNoInline("callee (" + callee + ") has no code") - () + if (inc.hasHandlers && (stackLength == -1)) { + // no inlining is done, yet don't warn about it, stackLength == -1 indicates we're trying to inlineWithoutTFA. + // Shortly, a TFA will be computed and an error message reported if indeed inlining not possible. + false + } + else { + val isSafe = pair isStampedForInlining stackLength match { + case DontInlineHere(msg) => warnNoInline(msg) + case NeverSafeToInline => false + case InlineableAtThisCaller => true + case inl @ FeasibleInline(_, _) if !inl.isSafe => false + case FeasibleInline(required, toPublicize) => + for (f <- toPublicize) { + inlineLog("access", f, "making public") + f setFlag Flags.notPRIVATE + f setFlag Flags.notPROTECTED + } + // only add to `knownSafe` after all `toPublicize` fields actually made public. + if (required == NonPublicRefs.Public) + tfa.knownSafe += inc.sym - case None => - warnNoInline("bytecode was not available") - debuglog("could not find icode\n\treceiver: " + receiver + "\n\tmethod: " + concreteMethod) + true + } + isSafe && { + retry = true + if (isCountable) count += 1 + pair.doInline(bb, i) + if (!pair.isInlineForced || inc.isMonadic) caller.inlinedCalls += 1 + inlinedMethodCount(inc.sym) += 1 + + // Remove the caller from the cache (this inlining might have changed its calls-private relation). + usesNonPublics -= m + recentTFAs -= m.symbol + true + } } - } else { - warnNoInline(if(!isAvailable) "bytecode was not available" else "it can be overridden") } - - inlined } /* Pre-inlining consists in invoking the usual inlining subroutine with (receiver class, concrete method) pairs as input @@ -485,7 +487,7 @@ abstract class Inliners extends SubComponent { do { retry = false - log("Analyzing " + m + " count " + count + " with " + caller.length + " blocks") + debuglog(analyzeMessage) /* it's important not to inline in unreachable basic blocks. linearizedBlocks() returns only reachable ones. */ tfa.callerLin = caller.m.linearizedBlocks() @@ -567,9 +569,16 @@ abstract class Inliners extends SubComponent { m.normalize if (sizeBeforeInlining > 0) { val instrAfterInlining = m.code.instructionCount - val prefix = if ((instrAfterInlining > 2 * instrBeforeInlining) && (instrAfterInlining > 200)) " !! " else "" - log(prefix + " %s blocks before inlining: %d (%d) after: %d (%d)".format( - m.symbol.fullName, sizeBeforeInlining, instrBeforeInlining, m.code.blockCount, instrAfterInlining)) + val prefix = if ((instrAfterInlining > 2 * instrBeforeInlining) && (instrAfterInlining > 200)) "!!" else "" + val inlinings = caller.inlinedCalls + if (inlinings > 0) { + val s1 = s"instructions $instrBeforeInlining -> $instrAfterInlining" + val s2 = if (sizeBeforeInlining == m.code.blockCount) "" else s", blocks $sizeBeforeInlining -> ${m.code.blockCount}" + val callees = inlinedMethodCount.toList map { case (k, v) => k.fullNameString + ( if (v == 1) "" else "/" + v ) } + + inlineLog("inlined", m.symbol.fullName, callees.sorted.mkString(inlinings + " inlined: ", ", ", "")) + inlineLog("<>", m.symbol.fullName, s"${m.symbol.nameString}: $s1$s2") + } } } @@ -589,6 +598,8 @@ abstract class Inliners extends SubComponent { } class IMethodInfo(val m: IMethod) { + override def toString = m.toString + val sym = m.symbol val name = sym.name def owner = sym.owner @@ -688,7 +699,7 @@ abstract class Inliners extends SubComponent { val i = iter.next() getAccess(i) match { case Private => - log("instruction " + i + " requires private access.") + inlineLog("access", s"instruction $i requires private access", "pos=" + i.pos) toBecomePublic = Nil seen = Private case Protected => seen = Protected @@ -765,11 +776,10 @@ abstract class Inliners extends SubComponent { tfa.warnIfInlineFails.remove(instr) val targetPos = instr.pos - log("Inlining " + inc.m + " in " + caller.m + " at pos: " + posToStr(targetPos)) def blockEmit(i: Instruction) = block.emit(i, targetPos) def newLocal(baseName: String, kind: TypeKind) = - new Local(caller.sym.newVariable(freshName(baseName), targetPos), kind, false) + new Local(caller.sym.newVariable(freshName(baseName), targetPos) setInfo kind.toType, kind, false) val (hasRETURN, a) = getRecentTFA(inc.m, isInlineForced) @@ -956,6 +966,7 @@ abstract class Inliners extends SubComponent { if(reasonWhyNever != null) { tfa.knownNever += inc.sym + inlineLog("never", inc.sym, reasonWhyNever) // next time around NeverSafeToInline is returned, thus skipping (duplicate) msg, this is intended. return DontInlineHere(inc.m + " " + reasonWhyNever) } @@ -978,10 +989,15 @@ abstract class Inliners extends SubComponent { * As a result of (b), some synthetic private members can be chosen to become public. */ - if(!isInlineForced && !isScoreOK) { + val score = inlinerScore + val scoreStr = if (score > 0) "+" + score else "" + score + val what = if (score > 0) "ok to" else "don't" + inlineLog(scoreStr, inc.m.symbol, s"$what inline into ${ownedName(caller.m.symbol)}") + + if (!isInlineForced && score <= 0) { // During inlining retry, a previous caller-callee pair that scored low may pass. // Thus, adding the callee to tfa.knownUnsafe isn't warranted. - return DontInlineHere("too low score (heuristics)") + return DontInlineHere(s"inliner heuristic") } if(inc.hasHandlers && (stackLength > inc.minimumStack)) { @@ -1000,7 +1016,9 @@ abstract class Inliners extends SubComponent { val accReq = inc.accessRequirements if(!canAccess(accReq.accessNeeded)) { tfa.knownUnsafe += inc.sym - return DontInlineHere("access level required by callee not matched by caller") + val msg = "access level required by callee not matched by caller" + inlineLog("fail", inc.sym, msg) + return DontInlineHere(msg) } FeasibleInline(accReq.accessNeeded, accReq.toBecomePublic) @@ -1022,9 +1040,7 @@ abstract class Inliners extends SubComponent { * - it's good to inline closures functions. * - it's bad (useless) to inline inside bridge methods */ - def isScoreOK: Boolean = { - debuglog(s"shouldInline: ${caller.m} , callee: ${inc.m}") - + def inlinerScore: Int = { var score = 0 // better not inline inside closures, but hope that the closure itself is repeatedly inlined @@ -1036,18 +1052,15 @@ abstract class Inliners extends SubComponent { if (inc.isLarge) score -= 1; if (caller.isSmall && isLargeSum) { score -= 1 - debuglog(s"shouldInline: score decreased to $score because small $caller would become large") + debuglog(s"inliner score decreased to $score because small caller $caller would become large") } if (inc.isMonadic) score += 3 else if (inc.isHigherOrder) score += 1 - if (inc.isInClosure) score += 2; - if (inlinedMethodCount(inc.sym) > 2) score -= 2; - - log(s"shouldInline(${inc.m}) score: $score") - - score > 0 + if (inc.isInClosure) score += 2 + if (inlinedMethodCount(inc.sym) > 2) score -= 2 + score } } diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 96d7dadbd7..a2df1494ef 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -387,8 +387,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends newSym <- req.definedSymbols get name oldSym <- oldReq.definedSymbols get name.companionName } { - replwarn("warning: previously defined %s is not a companion to %s.".format( - stripString("" + oldSym), stripString("" + newSym))) + afterTyper(replwarn(s"warning: previously defined $oldSym is not a companion to $newSym.")) replwarn("Companions must be defined together; you may wish to use :paste mode for this.") } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 437a5e1434..175c322786 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -37,7 +37,7 @@ abstract class ICodeReader extends ClassfileParser { cls.info // ensure accurate type information isScalaModule = cls.isModule && !cls.isJavaDefined - log("Reading class: " + cls + " isScalaModule?: " + isScalaModule) + log("ICodeReader reading " + cls) val name = cls.javaClassName classPath.findSourceFile(name) match { @@ -99,11 +99,9 @@ abstract class ICodeReader extends ClassfileParser { if (sym == NoSymbol) sym = owner.info.findMember(newTermName(name + nme.LOCAL_SUFFIX_STRING), 0, 0, false).suchThat(_.tpe =:= tpe) if (sym == NoSymbol) { - log("Could not find symbol for " + name + ": " + tpe) - log(owner.info.member(name).tpe + " : " + tpe) sym = if (field) owner.newValue(name, owner.pos, toScalaFieldFlags(jflags)) else dummySym sym setInfoAndEnter tpe - log("added " + sym + ": " + sym.tpe) + log(s"ICodeReader could not locate ${name.decode} in $owner. Created ${sym.defString}.") } (jflags, sym) } @@ -172,10 +170,7 @@ abstract class ICodeReader extends ClassfileParser { } else if (nme.isModuleName(name)) { val strippedName = nme.stripModuleSuffix(name) - val sym = forceMangledName(newTermName(strippedName.decode), true) - - if (sym == NoSymbol) rootMirror.getModule(strippedName) - else sym + forceMangledName(newTermName(strippedName.decode), true) orElse rootMirror.getModule(strippedName) } else { forceMangledName(name, false) @@ -956,7 +951,7 @@ abstract class ICodeReader extends ClassfileParser { case None => checkValidIndex val l = freshLocal(idx, kind, false) - log("Added new local for idx " + idx + ": " + kind) + debuglog("Added new local for idx " + idx + ": " + kind) locals += (idx -> List((l, kind))) l } diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index a8cdee7154..4a668d4c61 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -79,12 +79,11 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => // -optimise and not otherwise, but the classpath can use arbitrary // logic so the classpath must be queried. if (classPath.context.isValidName(implName + ".class")) { - log("unlinking impl class " + implSym) iface.owner.info.decls unlink implSym NoSymbol } else { - log("not unlinking existing " + implSym + " as the impl class is not visible on the classpath.") + log(s"not unlinking $iface's existing implClass ${implSym.name} because it is not on the classpath.") implSym } } @@ -113,9 +112,10 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => iface.info implClassMap.getOrElse(iface, atPhase(implClassPhase) { - log("Creating implClass for " + iface) - if (iface.implClass ne NoSymbol) - log("%s.implClass already exists: %s".format(iface, iface.implClass)) + if (iface.implClass eq NoSymbol) + debuglog(s"${iface.fullLocationString} has no implClass yet, creating it now.") + else + log(s"${iface.fullLocationString} impl class is ${iface.implClass.nameString}") newImplClass(iface) }) @@ -137,7 +137,7 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => * given the decls ifaceDecls of its interface. */ private def implDecls(implClass: Symbol, ifaceDecls: Scope): Scope = { - log("LazyImplClassType calculating decls for " + implClass) + debuglog("LazyImplClassType calculating decls for " + implClass) val decls = newScope if ((ifaceDecls lookup nme.MIXIN_CONSTRUCTOR) == NoSymbol) { @@ -152,16 +152,16 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => for (sym <- ifaceDecls) { if (isInterfaceMember(sym)) { if (needsImplMethod(sym)) { - log("Cloning " + sym + " for implementation method in " + implClass) val clone = sym.cloneSymbol(implClass).resetFlag(lateDEFERRED) if (currentRun.compiles(implClass)) implMethodMap(sym) = clone decls enter clone sym setFlag lateDEFERRED + if (!sym.isSpecialized) + log(s"Cloned ${sym.name} from ${sym.owner} into implClass ${implClass.fullName}") } - else log(sym + " needs no implementation method in " + implClass) } else { - log("Destructively modifying owner of %s from %s to %s".format(sym, sym.owner, implClass)) + log(s"Destructively modifying owner of $sym from ${sym.owner} to $implClass") sym.owner = implClass // note: OK to destructively modify the owner here, // because symbol will not be accessible from outside the sourcefile. @@ -174,7 +174,7 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => } override def complete(implSym: Symbol) { - log("LazyImplClassType completing " + implSym) + debuglog("LazyImplClassType completing " + implSym) /** If `tp` refers to a non-interface trait, return a * reference to its implementation class. Otherwise return `tp`. diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index d97fbf5daa..8af9fd6eb8 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -490,7 +490,7 @@ abstract class Erasure extends AddInterfaces @inline private def box(tree: Tree, target: => String): Tree = { val result = box1(tree) - log("boxing "+tree+":"+tree.tpe+" to "+target+" = "+result+":"+result.tpe) + log(s"boxing ${tree.summaryString}: ${tree.tpe} into $target: ${result.tpe}") result } @@ -525,7 +525,7 @@ abstract class Erasure extends AddInterfaces * fields (see TupleX). (ID) */ case Apply(boxFun, List(arg)) if isUnbox(tree.symbol) && safeToRemoveUnbox(arg.tpe.typeSymbol) => - log("boxing an unbox: " + tree + "/" + tree.symbol + " and replying with " + arg + " of type " + arg.tpe) + log(s"boxing an unbox: ${tree.symbol} -> ${arg.tpe}") arg case _ => (REF(boxMethod(x)) APPLY tree) setPos (tree.pos) setType ObjectClass.tpe @@ -537,7 +537,7 @@ abstract class Erasure extends AddInterfaces private def unbox(tree: Tree, pt: Type): Tree = { val result = unbox1(tree, pt) - log("unboxing "+tree+":"+tree.tpe+" to "+pt+" = "+result+":"+result.tpe) + log(s"unboxing ${tree.summaryString}: ${tree.tpe} with pt=$pt as type ${result.tpe}") result } @@ -614,7 +614,7 @@ abstract class Erasure extends AddInterfaces * @return the adapted tree */ private def adaptToType(tree: Tree, pt: Type): Tree = { - //if (settings.debug.value && pt != WildcardType) + if (settings.debug.value && pt != WildcardType) log("adapting " + tree + ":" + tree.tpe + " : " + tree.tpe.parents + " to " + pt)//debug if (tree.tpe <:< pt) tree diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala index 94eaba67d7..3bbf429fc2 100644 --- a/src/compiler/scala/tools/nsc/transform/Flatten.scala +++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala @@ -22,12 +22,14 @@ abstract class Flatten extends InfoTransform { */ private def replaceSymbolInCurrentScope(sym: Symbol): Symbol = afterFlatten { val scope = sym.owner.info.decls - val old = scope lookup sym.name - if (old ne NoSymbol) - scope unlink old - + val old = scope lookup sym.name andAlso scope.unlink scope enter sym - log("lifted " + sym.fullLocationString) + + if (old eq NoSymbol) + log(s"lifted ${sym.fullLocationString}") + else + log(s"lifted ${sym.fullLocationString} after unlinking existing $old from scope.") + old } @@ -35,9 +37,7 @@ abstract class Flatten extends InfoTransform { if (!sym.isLifted) { sym setFlag LIFTED debuglog("re-enter " + sym.fullLocationString) - val old = replaceSymbolInCurrentScope(sym) - if (old ne NoSymbol) - log("unlinked " + old.fullLocationString + " after lifting " + sym) + replaceSymbolInCurrentScope(sym) } } private def liftSymbol(sym: Symbol) { diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 181463657b..5bff653499 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -484,11 +484,7 @@ abstract class UnCurry extends InfoTransform arg setType functionType(Nil, arg.tpe) } else { - log("byname | %s | %s | %s".format( - arg.pos.source.path + ":" + arg.pos.line, fun.fullName, - if (fun.isPrivate) "private" else "") - ) - + log(s"Argument '$arg' at line ${arg.pos.safeLine} is $formal from ${fun.fullName}") 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. diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 4eea8461d3..a9c31cfe1f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1870,7 +1870,7 @@ trait Typers extends Modes with Adaptations with Tags { * @param rhs ... */ def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree) { - log("computing param aliases for "+clazz+":"+clazz.primaryConstructor.tpe+":"+rhs)//debug + debuglog(s"computing param aliases for $clazz:${clazz.primaryConstructor.tpe}:$rhs") def decompose(call: Tree): (Tree, List[Tree]) = call match { case Apply(fn, args) => val (superConstr, args1) = decompose(fn) diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index 4100e97cdd..2424e75949 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -47,6 +47,8 @@ abstract class SymbolTable extends macros.Universe def globalError(msg: String): Unit = abort(msg) def abort(msg: String): Nothing = throw new FatalError(supplementErrorMessage(msg)) + def shouldLogAtThisPhase = false + @deprecated("Give us a reason", "2.10.0") def abort(): Nothing = abort("unknown error") diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index aab41a0b29..c0e6a66767 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -943,7 +943,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** If this symbol has an expanded name, its original name, otherwise its name itself. * @see expandName */ - def originalName: Name = nme.originalName(name) + def originalName: Name = nme.originalName(nme.dropLocalSuffix(name)) /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. */ diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index 96e257d303..47d40b0331 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -269,8 +269,8 @@ value jZ { // after parser value jZ { // after explicitouter protected val $outer: D.this.type - val ll$D$J$$$outer(): D.this.type - val ll$C$I$$$outer(): C.this.type + val $outer(): D.this.type + val $outer(): C.this.type def thisI(): I.this.type def thisC(): C.this.type def t2(): T2 @@ -279,9 +279,9 @@ value jZ { // after explicitouter value jZ { // after erasure protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#I def thisC(): ll.C def t2(): Object @@ -290,9 +290,9 @@ value jZ { // after erasure value jZ { // after flatten protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#C$I def thisC(): ll.C def t2(): Object -- cgit v1.2.3 From 9da135880d0b78b440f4ce62dd8b7dc156571d71 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 5 Sep 2012 18:50:58 +0200 Subject: several fixes to scala.concurrent.util.Duration - add test cases (migrated from Akka sources) - add overflow checking (will throw IllegalArgumentException instead of giving wrong results) - make string parsing more precise when giving >100days in nanoseconds - make method signatures more precise in retaining FiniteDuration throughout calculations - fix mul/div of infinities by negative number - add Ordering for Deadline (was accidentally left out earlier) --- src/library/scala/concurrent/util/Duration.scala | 67 ++++++++++++-- test/files/jvm/duration-java.check | 46 +++++----- test/files/jvm/duration-java/Test.java | 12 ++- test/files/jvm/duration-tck.scala | 107 +++++++++++++++++++++++ 4 files changed, 199 insertions(+), 33 deletions(-) create mode 100644 test/files/jvm/duration-tck.scala (limited to 'test') diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index bf0f3006f1..c5b7e8328d 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -10,20 +10,25 @@ package scala.concurrent.util import java.util.concurrent.TimeUnit import TimeUnit._ -import java.lang.{ Double => JDouble } +import java.lang.{ Double => JDouble, Long => JLong } import language.implicitConversions -case class Deadline private (time: Duration) { +case class Deadline private (time: Duration) extends Ordered[Deadline] { def +(other: Duration): Deadline = copy(time = time + other) def -(other: Duration): Deadline = copy(time = time - other) def -(other: Deadline): Duration = time - other.time def timeLeft: Duration = this - Deadline.now def hasTimeLeft(): Boolean = !isOverdue() def isOverdue(): Boolean = (time.toNanos - System.nanoTime()) < 0 + def compare(other: Deadline) = time compare other.time } object Deadline { def now: Deadline = Deadline(Duration(System.nanoTime, NANOSECONDS)) + + implicit object DeadlineIsOrdered extends Ordering[Deadline] { + def compare(a: Deadline, b: Deadline) = a compare b + } } // TODO: "Inf", "PlusInf", "MinusInf", where did these names come from? @@ -48,9 +53,12 @@ object Duration { case "MinusInf" | "-Inf" => MinusInf case _ => val unitName = s1.reverse takeWhile (_.isLetter) reverse; - def length = JDouble.parseDouble(s1 dropRight unitName.length) timeUnit get unitName match { - case Some(unit) => Duration(length, unit) + case Some(unit) => + val valueStr = s1 dropRight unitName.length + val valueD = JDouble.parseDouble(valueStr) + if (valueD <= 9007199254740992d && valueD >= -9007199254740992d) Duration(valueD, unit) + else Duration(JLong.parseLong(valueStr), unit) case _ => sys.error("format error " + s) } } @@ -86,8 +94,11 @@ object Duration { def unapply(d: Duration): Option[(Long, TimeUnit)] = if (d.isFinite) Some((d.length, d.unit)) else None - def fromNanos(nanos: Double): FiniteDuration = + def fromNanos(nanos: Double): FiniteDuration = { + if (nanos > Long.MaxValue || nanos < Long.MinValue) + throw new IllegalArgumentException("trying to construct too large duration with " + nanos + "ns") fromNanos((nanos + 0.5).toLong) + } def fromNanos(nanos: Long): FiniteDuration = { if (nanos % 86400000000000L == 0) { @@ -137,8 +148,12 @@ object Duration { if (other ne this) this else throw new IllegalArgumentException("illegal subtraction of infinities") - def *(factor: Double): Duration = this - def /(factor: Double): Duration = this + private def mult(f: Double) = + if (f == 0d) fail("multiply by zero") + else if (f < 0d) -this + else this + def *(factor: Double): Duration = mult(factor) + def /(factor: Double): Duration = mult(factor) def /(other: Duration): Double = other match { case _: Infinite => throw new IllegalArgumentException("illegal division of infinities") // maybe questionable but pragmatic: Inf / 0 => Inf @@ -273,6 +288,23 @@ object FiniteDuration { class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { import Duration._ + require(unit match { + /* + * sorted so that the first cases should be most-used ones, because enum + * is checked one after the other. + */ + case NANOSECONDS ⇒ true + case MICROSECONDS ⇒ length <= 9223372036854775L && length >= -9223372036854775L + case MILLISECONDS ⇒ length <= 9223372036854L && length >= -9223372036854L + case SECONDS ⇒ length <= 9223372036L && length >= -9223372036L + case MINUTES ⇒ length <= 153722867L && length >= -153722867L + case HOURS ⇒ length <= 2562047L && length >= -2562047L + case DAYS ⇒ length <= 106751L && length >= -106751L + case _ ⇒ + val v = unit.convert(length, DAYS) + v <= 106751L && v >= -106751L + }, "Duration is limited to 2^63ns (ca. 292 years)") + def toNanos = unit.toNanos(length) def toMicros = unit.toMicros(length) def toMillis = unit.toMillis(length) @@ -289,12 +321,19 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { case x: FiniteDuration => toNanos compare x.toNanos case _ => -(other compare this) } + + private def add(a: Long, b: Long): Long = { + val c = a + b + // check if the signs of the top bit of both summands differ from the sum + if (((a ^ c) & (b ^ c)) < 0) throw new IllegalArgumentException("integer overflow") + else c + } def +(other: Duration) = other match { - case x: FiniteDuration => fromNanos(toNanos + x.toNanos) + case x: FiniteDuration => fromNanos(add(toNanos, x.toNanos)) case _ => other } def -(other: Duration) = other match { - case x: FiniteDuration => fromNanos(toNanos - x.toNanos) + case x: FiniteDuration => fromNanos(add(toNanos, -x.toNanos)) case _ => other } @@ -304,6 +343,16 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { def /(other: Duration) = if (other.isFinite) toNanos.toDouble / other.toNanos else 0 + // overridden methods taking FiniteDurations, so that you can calculate while statically staying finite + def +(other: FiniteDuration) = fromNanos(add(toNanos, other.toNanos)) + def -(other: FiniteDuration) = fromNanos(add(toNanos, -other.toNanos)) + def plus(other: FiniteDuration) = this + other + def minus(other: FiniteDuration) = this - other + override def div(factor: Double) = this / factor + override def mul(factor: Double) = this * factor + def min(other: FiniteDuration) = if (this < other) this else other + def max(other: FiniteDuration) = if (this > other) this else other + def unary_- = Duration(-length, unit) final def isFinite() = true diff --git a/test/files/jvm/duration-java.check b/test/files/jvm/duration-java.check index 7ae257dcc0..49d06fbe93 100644 --- a/test/files/jvm/duration-java.check +++ b/test/files/jvm/duration-java.check @@ -201,7 +201,7 @@ 6.0E7 seconds => 1000000 minutes 1.0E8 seconds => 100000000 seconds 1.0E9 seconds => 1000000000 seconds - 1.0E12 seconds => 9223372036854775807 nanoseconds + 1.0E12 seconds => class java.lang.IllegalArgumentException 0.0 minutes => 0 days 1.0 minutes => 1 minute 7.0 minutes => 7 minutes @@ -251,8 +251,8 @@ 3.0E7 minutes => 500000 hours 6.0E7 minutes => 1000000 hours 1.0E8 minutes => 100000000 minutes - 1.0E9 minutes => 9223372036854775807 nanoseconds - 1.0E12 minutes => 9223372036854775807 nanoseconds + 1.0E9 minutes => class java.lang.IllegalArgumentException + 1.0E12 minutes => class java.lang.IllegalArgumentException 0.0 hours => 0 days 1.0 hours => 1 hour 7.0 hours => 7 hours @@ -295,15 +295,15 @@ 60000.0 hours => 2500 days 100000.0 hours => 100000 hours 1000000.0 hours => 1000000 hours - 7000000.0 hours => 9223372036854775807 nanoseconds - 1.0E7 hours => 9223372036854775807 nanoseconds - 1.2E7 hours => 9223372036854775807 nanoseconds - 2.4E7 hours => 9223372036854775807 nanoseconds - 3.0E7 hours => 9223372036854775807 nanoseconds - 6.0E7 hours => 9223372036854775807 nanoseconds - 1.0E8 hours => 9223372036854775807 nanoseconds - 1.0E9 hours => 9223372036854775807 nanoseconds - 1.0E12 hours => 9223372036854775807 nanoseconds + 7000000.0 hours => class java.lang.IllegalArgumentException + 1.0E7 hours => class java.lang.IllegalArgumentException + 1.2E7 hours => class java.lang.IllegalArgumentException + 2.4E7 hours => class java.lang.IllegalArgumentException + 3.0E7 hours => class java.lang.IllegalArgumentException + 6.0E7 hours => class java.lang.IllegalArgumentException + 1.0E8 hours => class java.lang.IllegalArgumentException + 1.0E9 hours => class java.lang.IllegalArgumentException + 1.0E12 hours => class java.lang.IllegalArgumentException 0.0 days => 0 days 1.0 days => 1 day 7.0 days => 7 days @@ -345,16 +345,18 @@ 30000.0 days => 30000 days 60000.0 days => 60000 days 100000.0 days => 100000 days - 1000000.0 days => 9223372036854775807 nanoseconds - 7000000.0 days => 9223372036854775807 nanoseconds - 1.0E7 days => 9223372036854775807 nanoseconds - 1.2E7 days => 9223372036854775807 nanoseconds - 2.4E7 days => 9223372036854775807 nanoseconds - 3.0E7 days => 9223372036854775807 nanoseconds - 6.0E7 days => 9223372036854775807 nanoseconds - 1.0E8 days => 9223372036854775807 nanoseconds - 1.0E9 days => 9223372036854775807 nanoseconds - 1.0E12 days => 9223372036854775807 nanoseconds + 1000000.0 days => class java.lang.IllegalArgumentException + 7000000.0 days => class java.lang.IllegalArgumentException + 1.0E7 days => class java.lang.IllegalArgumentException + 1.2E7 days => class java.lang.IllegalArgumentException + 2.4E7 days => class java.lang.IllegalArgumentException + 3.0E7 days => class java.lang.IllegalArgumentException + 6.0E7 days => class java.lang.IllegalArgumentException + 1.0E8 days => class java.lang.IllegalArgumentException + 1.0E9 days => class java.lang.IllegalArgumentException + 1.0E12 days => class java.lang.IllegalArgumentException +10000000000000001 nanoseconds => 10000000000000001 nanoseconds +10000000000000002 nanoseconds => 10000000000000002 nanoseconds Inf => Duration.Inf -Inf => Duration.MinusInf +Inf => Duration.Inf diff --git a/test/files/jvm/duration-java/Test.java b/test/files/jvm/duration-java/Test.java index 02feb522b8..1c53ccb266 100644 --- a/test/files/jvm/duration-java/Test.java +++ b/test/files/jvm/duration-java/Test.java @@ -26,10 +26,18 @@ public class Test { for (TimeUnit t : TimeUnit.values()) { for (Double n: makeNumbers()) { String s = "" + n + " " + t.toString().toLowerCase(); - Duration d = Duration.create(n, t); - p(String.format("%25s => %s", s, d)); + String result; + try { + Duration d = Duration.create(n, t); + result = d.toString(); + } catch(Exception e) { + result = e.getClass().toString(); + } + p(String.format("%25s => %s", s, result)); } } + for (String s: new String[] {"10000000000000001 nanoseconds", "10000000000000002 nanoseconds"}) + p(String.format("%25s => %s", s, Duration.create(s))); for (String s: Arrays.asList("Inf", "-Inf", "+Inf", "PlusInf", "MinusInf")) { Duration d = Duration.create(s); p(String.format("%25s => %s", s, d)); diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala new file mode 100644 index 0000000000..679712aa59 --- /dev/null +++ b/test/files/jvm/duration-tck.scala @@ -0,0 +1,107 @@ +/** + * Copyright (C) 2012 Typesafe Inc. + */ + +import scala.concurrent.util._ +import duration._ +import scala.reflect._ +import java.util.concurrent.TimeUnit._ + +object Test extends App { + + implicit class Assert(val left: Any) extends AnyVal { + def =!=(right: Any) = assert(left == right, s"$left was not equal to $right") + } + + def intercept[T <: Exception : ClassTag](code: => Unit) = + try { code; assert(false, "did not throw expected exception " + classTag[T]) } + catch { + case ex: Exception => if (classTag[T].runtimeClass isAssignableFrom ex.getClass) () else throw ex + } + + { // test field ops + val zero = 0 seconds + val one = 1 second + val two = one + one + val three = 3 * one + (0 * one) =!= (zero) + (2 * one) =!= (two) + (three - two) =!= (one) + (three / 3) =!= (one) + (two / one) =!= (2) + (one + zero) =!= (one) + (one / 1000000) =!= (1.micro) + } + + { // test infinities + val one = 1.second + val inf = Duration.Inf + val minf = Duration.MinusInf + (-inf) =!= (minf) + intercept[IllegalArgumentException] { minf + inf } + intercept[IllegalArgumentException] { inf - inf } + intercept[IllegalArgumentException] { inf + minf } + intercept[IllegalArgumentException] { minf - minf } + (inf + inf) =!= (inf) + (inf - minf) =!= (inf) + (minf - inf) =!= (minf) + (minf + minf) =!= (minf) + assert(inf == inf) + assert(minf == minf) + inf.compareTo(inf) =!= (0) + inf.compareTo(one) =!= (1) + minf.compareTo(minf) =!= (0) + minf.compareTo(one) =!= (-1) + assert(inf != minf) + assert(minf != inf) + assert(one != inf) + assert(minf != one) + inf =!= (minf * -1d) + inf =!= (minf / -1d) + } + + { // test overflow protection + for (unit ← Seq(DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS, NANOSECONDS)) { + val x = unit.convert(Long.MaxValue, NANOSECONDS) + val dur = Duration(x, unit) + val mdur = Duration(-x, unit) + -mdur =!= (dur) + intercept[IllegalArgumentException] { Duration(x + 10000000d, unit) } + intercept[IllegalArgumentException] { Duration(-x - 10000000d, unit) } + if (unit != NANOSECONDS) { + intercept[IllegalArgumentException] { Duration(x + 1, unit) } + intercept[IllegalArgumentException] { Duration(-x - 1, unit) } + } + intercept[IllegalArgumentException] { dur + 1.day } + intercept[IllegalArgumentException] { mdur - 1.day } + intercept[IllegalArgumentException] { dur * 1.1 } + intercept[IllegalArgumentException] { mdur * 1.1 } + intercept[IllegalArgumentException] { dur * 2.1 } + intercept[IllegalArgumentException] { mdur * 2.1 } + intercept[IllegalArgumentException] { dur / 0.9 } + intercept[IllegalArgumentException] { mdur / 0.9 } + intercept[IllegalArgumentException] { dur / 0.4 } + intercept[IllegalArgumentException] { mdur / 0.4 } + Duration(x + unit.toString.toLowerCase) + Duration("-" + x + unit.toString.toLowerCase) + intercept[IllegalArgumentException] { Duration("%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + intercept[IllegalArgumentException] { Duration("-%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + } + } + + { // test Deadline + val dead = 2.seconds.fromNow + val dead2 = 2 seconds fromNow + // view bounds vs. very local type inference vs. operator precedence: sigh + assert(dead.timeLeft > (1 second: Duration)) + assert(dead2.timeLeft > (1 second: Duration)) + Thread.sleep(1.second.toMillis) + assert(dead.timeLeft < (1 second: Duration)) + assert(dead2.timeLeft < (1 second: Duration)) + } + + { // check statically retaining finite-ness + val d: FiniteDuration = 1.second * 2 / 1.4 mul 1.1 div 2.1 plus 3.seconds minus 1.millisecond min 1.second max 1.second + } + +} -- cgit v1.2.3 From 816cecf9a95989dfc570f2acad87d4156b09e2ff Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 28 Aug 2012 13:37:02 -0700 Subject: More fix for invalid companions. Eliminated InvalidCompanions exception entirely. Anyone's guess why we unholstered this exception every time someone calls "isCodefinedWith" rather than when symbols are created. I moved the check into Namers, where it can be done once and with sufficient finesse not to crash so much. With this patch in place, "playbench" can be built with java7. --- .../scala/tools/nsc/typechecker/Infer.scala | 11 +++-- .../scala/tools/nsc/typechecker/Namers.scala | 49 ++++++++++++++++------ src/reflect/scala/reflect/internal/Symbols.scala | 37 +++++----------- test/files/neg/t5031.check | 6 +-- test/files/neg/t5031b.check | 5 +++ test/files/neg/t5031b/a.scala | 3 ++ test/files/neg/t5031b/b.scala | 3 ++ 7 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 test/files/neg/t5031b.check create mode 100644 test/files/neg/t5031b/a.scala create mode 100644 test/files/neg/t5031b/b.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 1b3602fca2..803fb2857e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -923,10 +923,13 @@ trait Infer { /** Is sym1 (or its companion class in case it is a module) a subclass of * sym2 (or its companion class in case it is a module)? */ - def isProperSubClassOrObject(sym1: Symbol, sym2: Symbol): Boolean = - sym1 != sym2 && sym1 != NoSymbol && (sym1 isSubClass sym2) || - sym1.isModuleClass && isProperSubClassOrObject(sym1.linkedClassOfClass, sym2) || - sym2.isModuleClass && isProperSubClassOrObject(sym1, sym2.linkedClassOfClass) + def isProperSubClassOrObject(sym1: Symbol, sym2: Symbol): Boolean = ( + (sym1 != sym2) && (sym1 != NoSymbol) && ( + (sym1 isSubClass sym2) + || (sym1.isModuleClass && isProperSubClassOrObject(sym1.linkedClassOfClass, sym2)) + || (sym2.isModuleClass && isProperSubClassOrObject(sym1, sym2.linkedClassOfClass)) + ) + ) /** is symbol `sym1` defined in a proper subclass of symbol `sym2`? */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index adced9d8c9..62f01b8afa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -359,10 +359,39 @@ trait Namers extends MethodSynthesis { } } + /** Given a ClassDef or ModuleDef, verifies there isn't a companion which + * has been defined in a separate file. + */ + private def validateCompanionDefs(tree: ImplDef) { + val sym = tree.symbol + if (sym eq NoSymbol) return + + val ctx = if (context.owner.isPackageObjectClass) context.outer else context + val module = if (sym.isModule) sym else ctx.scope lookup tree.name.toTermName + val clazz = if (sym.isClass) sym else ctx.scope lookup tree.name.toTypeName + val fails = ( + module.isModule + && clazz.isClass + && !module.isSynthetic + && !clazz.isSynthetic + && (clazz.sourceFile ne null) + && (module.sourceFile ne null) + && !(module isCoDefinedWith clazz) + ) + if (fails) { + context.unit.error(tree.pos, ( + s"Companions '$clazz' and '$module' must be defined in same file:\n" + + s" Found in ${clazz.sourceFile.canonicalPath} and ${module.sourceFile.canonicalPath}") + ) + } + } + def enterModuleDef(tree: ModuleDef) = { val sym = enterModuleSymbol(tree) sym.moduleClass setInfo namerOf(sym).moduleClassTypeCompleter(tree) sym setInfo completerOf(tree) + validateCompanionDefs(tree) + sym } /** Enter a module symbol. The tree parameter can be either @@ -635,6 +664,7 @@ trait Namers extends MethodSynthesis { } else context.unit.error(tree.pos, "implicit classes must accept exactly one primary constructor parameter") } + validateCompanionDefs(tree) } // this logic is needed in case typer was interrupted half @@ -699,7 +729,7 @@ trait Namers extends MethodSynthesis { // } } - def moduleClassTypeCompleter(tree: Tree) = { + def moduleClassTypeCompleter(tree: ModuleDef) = { mkTypeCompleter(tree) { sym => val moduleSymbol = tree.symbol assert(moduleSymbol.moduleClass == sym, moduleSymbol.moduleClass) @@ -1545,18 +1575,11 @@ trait Namers extends MethodSynthesis { * call this method? */ def companionSymbolOf(original: Symbol, ctx: Context): Symbol = { - try { - original.companionSymbol orElse { - ctx.lookup(original.name.companionName, original.owner).suchThat(sym => - (original.isTerm || sym.hasModuleFlag) && - (sym isCoDefinedWith original) - ) - } - } - catch { - case e: InvalidCompanions => - ctx.unit.error(original.pos, e.getMessage) - NoSymbol + original.companionSymbol orElse { + ctx.lookup(original.name.companionName, original.owner).suchThat(sym => + (original.isTerm || sym.hasModuleFlag) && + (sym isCoDefinedWith original) + ) } } } diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 3548657c04..dc73d0bc9f 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -1790,26 +1790,16 @@ trait Symbols extends api.Symbols { self: SymbolTable => } else owner.enclosingTopLevelClass /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */ - def isCoDefinedWith(that: Symbol) = { - (this.rawInfo ne NoType) && - (this.effectiveOwner == that.effectiveOwner) && { - !this.effectiveOwner.isPackageClass || - (this.sourceFile eq null) || - (that.sourceFile eq null) || - (this.sourceFile == that.sourceFile) || { - // recognize companion object in separate file and fail, else compilation - // appears to succeed but highly opaque errors come later: see bug #1286 - if (this.sourceFile.path != that.sourceFile.path) { - // The cheaper check can be wrong: do the expensive normalization - // before failing. - if (this.sourceFile.canonicalPath != that.sourceFile.canonicalPath) - throw InvalidCompanions(this, that) - } - - false - } - } - } + def isCoDefinedWith(that: Symbol) = ( + (this.rawInfo ne NoType) + && (this.effectiveOwner == that.effectiveOwner) + && ( !this.effectiveOwner.isPackageClass + || (this.sourceFile eq null) + || (that.sourceFile eq null) + || (this.sourceFile.path == that.sourceFile.path) // Cheap possibly wrong check, then expensive normalization + || (this.sourceFile.canonicalPath == that.sourceFile.canonicalPath) + ) + ) /** The internal representation of classes and objects: * @@ -3202,13 +3192,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => if (settings.debug.value) printStackTrace() } - case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable({ - "Companions '" + sym1 + "' and '" + sym2 + "' must be defined in same file:\n" + - " Found in " + sym1.sourceFile.canonicalPath + " and " + sym2.sourceFile.canonicalPath - }) { - override def toString = getMessage - } - /** A class for type histories */ private sealed case class TypeHistory(var validFrom: Period, info: Type, prev: TypeHistory) { assert((prev eq null) || phaseId(validFrom) > phaseId(prev.validFrom), this) diff --git a/test/files/neg/t5031.check b/test/files/neg/t5031.check index 8983d8daf9..2f1090c321 100644 --- a/test/files/neg/t5031.check +++ b/test/files/neg/t5031.check @@ -1,5 +1,5 @@ -Id.scala:3: error: Companions 'class Test' and 'object Test' must be defined in same file: +package.scala:2: error: Companions 'class Test' and 'object Test' must be defined in same file: Found in t5031/package.scala and t5031/Id.scala -object Test - ^ + class Test + ^ one error found diff --git a/test/files/neg/t5031b.check b/test/files/neg/t5031b.check new file mode 100644 index 0000000000..3bc2284a4d --- /dev/null +++ b/test/files/neg/t5031b.check @@ -0,0 +1,5 @@ +b.scala:3: error: Companions 'class Bippy' and 'object Bippy' must be defined in same file: + Found in t5031b/a.scala and t5031b/b.scala +object Bippy + ^ +one error found diff --git a/test/files/neg/t5031b/a.scala b/test/files/neg/t5031b/a.scala new file mode 100644 index 0000000000..0ab9aa9769 --- /dev/null +++ b/test/files/neg/t5031b/a.scala @@ -0,0 +1,3 @@ +package foo + +class Bippy diff --git a/test/files/neg/t5031b/b.scala b/test/files/neg/t5031b/b.scala new file mode 100644 index 0000000000..bdef237af5 --- /dev/null +++ b/test/files/neg/t5031b/b.scala @@ -0,0 +1,3 @@ +package foo + +object Bippy -- cgit v1.2.3 From e398de4a703f5ebad7282977b2240670a8b797f8 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 6 Sep 2012 12:51:55 +0200 Subject: removes Type.isConcrete This method was no longer used anywhere, except for a place where it wasn't really necessary. Its implementation is non-trivial, and I have doubts about it, so I propose to remove it altogether instead of living with some dubious code necessary for some dubious matter. --- src/compiler/scala/tools/nsc/typechecker/Macros.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 19 ------------------- test/files/run/macro-expand-tparams-implicit.check | 2 +- test/files/run/macro-expand-tparams-prefix-a.check | 2 +- test/files/run/macro-expand-tparams-prefix-b.check | 2 +- test/files/run/macro-expand-tparams-prefix-c1.check | 2 +- test/files/run/macro-expand-tparams-prefix-c2.check | 2 +- test/files/run/macro-undetparams-macroitself.check | 2 +- 8 files changed, 7 insertions(+), 26 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 01e773e528..59935677a8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -630,7 +630,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { macroDef.owner) } else targ.tpe - if (tpe.isConcrete) context.TypeTag(tpe) else context.AbsTypeTag(tpe) + context.AbsTypeTag(tpe) }) macroTraceVerbose("tags: ")(tags) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index c266e26895..daf4588438 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -317,25 +317,6 @@ trait Types extends api.Types { self: SymbolTable => def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type = substSym(from, to) def substituteTypes(from: List[Symbol], to: List[Type]): Type = subst(from, to) - def isConcrete = { - def notConcreteSym(sym: Symbol) = - sym.isAbstractType && !sym.isExistential - - def notConcreteTpe(tpe: Type): Boolean = tpe match { - case ThisType(_) => false - case SuperType(_, _) => false - case SingleType(pre, sym) => notConcreteSym(sym) - case ConstantType(_) => false - case TypeRef(_, sym, args) => notConcreteSym(sym) || (args exists notConcreteTpe) - case RefinedType(_, _) => false - case ExistentialType(_, _) => false - case AnnotatedType(_, tp, _) => notConcreteTpe(tp) - case _ => true - } - - !notConcreteTpe(this) - } - // the only thingies that we want to splice are: 1) type parameters, 2) abstract type members // the thingies that we don't want to splice are: 1) concrete types (obviously), 2) existential skolems def isSpliceable = { diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check index 80c6b826ba..1c1a785706 100644 --- a/test/files/run/macro-expand-tparams-implicit.check +++ b/test/files/run/macro-expand-tparams-implicit.check @@ -1,2 +1,2 @@ TypeTag[Int] -TypeTag[String] +AbsTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check index 6c23b47d64..6a7f9c5f52 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ b/test/files/run/macro-expand-tparams-prefix-a.check @@ -1,4 +1,4 @@ TypeTag[Int] TypeTag[Int] -TypeTag[String] +AbsTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check index 67dabff11e..daae32bd0a 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ b/test/files/run/macro-expand-tparams-prefix-b.check @@ -1,2 +1,2 @@ TypeTag[Boolean] TypeTag[Int] -TypeTag[Boolean] TypeTag[String] +TypeTag[Boolean] AbsTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check index 8d1c4e3416..5356b3e6d1 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ b/test/files/run/macro-expand-tparams-prefix-c1.check @@ -1,3 +1,3 @@ TypeTag[Int] -TypeTag[String] +AbsTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check index 8d1c4e3416..5356b3e6d1 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ b/test/files/run/macro-expand-tparams-prefix-c2.check @@ -1,3 +1,3 @@ TypeTag[Int] -TypeTag[String] +AbsTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check index 80c6b826ba..1c1a785706 100644 --- a/test/files/run/macro-undetparams-macroitself.check +++ b/test/files/run/macro-undetparams-macroitself.check @@ -1,2 +1,2 @@ TypeTag[Int] -TypeTag[String] +AbsTypeTag[String] -- cgit v1.2.3 From 93d3cc703806bec34c4ef0c7817239966363c193 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 5 Sep 2012 14:15:01 -0400 Subject: Fixes SI-6271 - Missing isEmpty override for views. GenIterableView didn't override isEmpty for views to look at *filtered* iterator, but was instead pulling unfiltered iterator and causing issues. Chalk up another bizzare bug to lack of insight/visibility into linearization and what havoc overriding new methods can spew on our library. --- .../scala/collection/GenIterableViewLike.scala | 1 + test/files/run/t6271.scala | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/files/run/t6271.scala (limited to 'test') diff --git a/src/library/scala/collection/GenIterableViewLike.scala b/src/library/scala/collection/GenIterableViewLike.scala index 9e3927eaf4..142561df20 100644 --- a/src/library/scala/collection/GenIterableViewLike.scala +++ b/src/library/scala/collection/GenIterableViewLike.scala @@ -25,6 +25,7 @@ self => def iterator: Iterator[B] override def foreach[U](f: B => U): Unit = iterator foreach f override def toString = viewToString + override def isEmpty = !iterator.hasNext } trait EmptyView extends Transformed[Nothing] with super.EmptyView { diff --git a/test/files/run/t6271.scala b/test/files/run/t6271.scala new file mode 100644 index 0000000000..8ebf7ad8b5 --- /dev/null +++ b/test/files/run/t6271.scala @@ -0,0 +1,32 @@ +object Test extends App { + def filterIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x filter (_ > 0) ) } + filtered.iterator.toIterable.flatten + } + def takenIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x take 0 ) } + filtered.iterator.toIterable.flatten + } + def droppedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x drop 1 ) } + filtered.iterator.toIterable.flatten + } + def flatMappedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x flatMap (_ => List()) ) } + filtered.iterator.toIterable.flatten + } + def slicedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x slice (2,3) ) } + filtered.iterator.toIterable.flatten + } + filterIssue + takenIssue + droppedIssue + flatMappedIssue + slicedIssue +} -- cgit v1.2.3 From d27dc71d676abc62ad9ff64c60bd42516b39ea19 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 6 Sep 2012 13:16:16 +0200 Subject: SI-6246 deprecated apis for core class tags Aliases ClassTag.XXX to Manifest.XXX to reuse already existing implementations of deprecated APIs. --- src/library/scala/reflect/ClassTag.scala | 36 +++++++------ src/library/scala/reflect/Manifest.scala | 19 ++++--- test/files/run/t6246.check | 90 ++++++++++++++++++++++++++++++++ test/files/run/t6246.scala | 26 +++++++++ 4 files changed, 148 insertions(+), 23 deletions(-) create mode 100644 test/files/run/t6246.check create mode 100644 test/files/run/t6246.scala (limited to 'test') diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 5255c44f10..373fdb4129 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -2,7 +2,7 @@ package scala.reflect import java.lang.{ Class => jClass } import language.{implicitConversions, existentials} -import scala.runtime.ScalaRunTime.arrayClass +import scala.runtime.ScalaRunTime.{ arrayClass } /** A `ClassTag[T]` wraps a runtime class, which can be accessed via the `runtimeClass` method. * @@ -64,25 +64,25 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial } object ClassTag { + private val ObjectTYPE = classOf[java.lang.Object] private val NothingTYPE = classOf[scala.runtime.Nothing$] private val NullTYPE = classOf[scala.runtime.Null$] - private val ObjectTYPE = classOf[java.lang.Object] - val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def runtimeClass = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte } - val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def runtimeClass = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short } - val Char : ClassTag[scala.Char] = new ClassTag[scala.Char]{ def runtimeClass = java.lang.Character.TYPE; private def readResolve() = ClassTag.Char } - val Int : ClassTag[scala.Int] = new ClassTag[scala.Int]{ def runtimeClass = java.lang.Integer.TYPE; private def readResolve() = ClassTag.Int } - val Long : ClassTag[scala.Long] = new ClassTag[scala.Long]{ def runtimeClass = java.lang.Long.TYPE; private def readResolve() = ClassTag.Long } - val Float : ClassTag[scala.Float] = new ClassTag[scala.Float]{ def runtimeClass = java.lang.Float.TYPE; private def readResolve() = ClassTag.Float } - val Double : ClassTag[scala.Double] = new ClassTag[scala.Double]{ def runtimeClass = java.lang.Double.TYPE; private def readResolve() = ClassTag.Double } - val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean]{ def runtimeClass = java.lang.Boolean.TYPE; private def readResolve() = ClassTag.Boolean } - val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def runtimeClass = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit } - val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Any } - val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object } - val AnyVal : ClassTag[scala.AnyVal] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyVal]] - val AnyRef : ClassTag[scala.AnyRef] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyRef]] - val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } - val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } + val Byte : ClassTag[scala.Byte] = Manifest.Byte + val Short : ClassTag[scala.Short] = Manifest.Short + val Char : ClassTag[scala.Char] = Manifest.Char + val Int : ClassTag[scala.Int] = Manifest.Int + val Long : ClassTag[scala.Long] = Manifest.Long + val Float : ClassTag[scala.Float] = Manifest.Float + val Double : ClassTag[scala.Double] = Manifest.Double + val Boolean : ClassTag[scala.Boolean] = Manifest.Boolean + val Unit : ClassTag[scala.Unit] = Manifest.Unit + val Any : ClassTag[scala.Any] = Manifest.Any + val Object : ClassTag[java.lang.Object] = Manifest.Object + val AnyVal : ClassTag[scala.AnyVal] = Manifest.AnyVal + val AnyRef : ClassTag[scala.AnyRef] = Manifest.AnyRef + val Nothing : ClassTag[scala.Nothing] = Manifest.Nothing + val Null : ClassTag[scala.Null] = Manifest.Null def apply[T](runtimeClass1: jClass[_]): ClassTag[T] = runtimeClass1 match { @@ -96,6 +96,8 @@ object ClassTag { case java.lang.Boolean.TYPE => ClassTag.Boolean.asInstanceOf[ClassTag[T]] case java.lang.Void.TYPE => ClassTag.Unit.asInstanceOf[ClassTag[T]] case ObjectTYPE => ClassTag.Object.asInstanceOf[ClassTag[T]] + case NothingTYPE => ClassTag.Nothing.asInstanceOf[ClassTag[T]] + case NullTYPE => ClassTag.Null.asInstanceOf[ClassTag[T]] case _ => new ClassTag[T]{ def runtimeClass = runtimeClass1 } } diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 9347f5b6bb..8289fdab69 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -155,28 +155,34 @@ object ManifestFactory { private def readResolve(): Any = Manifest.Unit } - val Any: Manifest[scala.Any] = new PhantomManifest[scala.Any]("Any") { + private val ObjectTYPE = classOf[java.lang.Object] + private val NothingTYPE = classOf[scala.runtime.Nothing$] + private val NullTYPE = classOf[scala.runtime.Null$] + + val Any: Manifest[scala.Any] = new PhantomManifest[scala.Any](ObjectTYPE, "Any") { override def <:<(that: ClassManifest[_]): Boolean = (that eq this) private def readResolve(): Any = Manifest.Any } - val Object: Manifest[java.lang.Object] = new PhantomManifest[java.lang.Object]("Object") { + val Object: Manifest[java.lang.Object] = new PhantomManifest[java.lang.Object](ObjectTYPE, "Object") { override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.Object } - val AnyVal: Manifest[scala.AnyVal] = new PhantomManifest[scala.AnyVal]("AnyVal") { + val AnyRef: Manifest[scala.AnyRef] = Object.asInstanceOf[Manifest[scala.AnyRef]] + + val AnyVal: Manifest[scala.AnyVal] = new PhantomManifest[scala.AnyVal](ObjectTYPE, "AnyVal") { override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.AnyVal } - val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null]("Null") { + val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null](ObjectTYPE, "Null") { override def <:<(that: ClassManifest[_]): Boolean = (that ne null) && (that ne Nothing) && !(that <:< AnyVal) private def readResolve(): Any = Manifest.Null } - val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing]("Nothing") { + val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing](ObjectTYPE, "Nothing") { override def <:<(that: ClassManifest[_]): Boolean = (that ne null) private def readResolve(): Any = Manifest.Nothing } @@ -211,7 +217,8 @@ object ManifestFactory { def classType[T](prefix: Manifest[_], clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = new ClassTypeManifest[T](Some(prefix), clazz, args.toList) - private abstract class PhantomManifest[T](override val toString: String) extends ClassTypeManifest[T](None, classOf[java.lang.Object], Nil) { + private abstract class PhantomManifest[T](override val runtimeClass: Predef.Class[_], + override val toString: String) extends ClassTypeManifest[T](None, runtimeClass, Nil) { override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef] override val hashCode = System.identityHashCode(this) } diff --git a/test/files/run/t6246.check b/test/files/run/t6246.check new file mode 100644 index 0000000000..9532185ead --- /dev/null +++ b/test/files/run/t6246.check @@ -0,0 +1,90 @@ +runtimeClass = byte, toString = Byte +true +true +true +false +true +false +false +false +false +runtimeClass = short, toString = Short +true +true +true +false +true +false +false +false +false +runtimeClass = char, toString = Char +true +true +true +false +true +false +false +false +false +runtimeClass = int, toString = Int +true +true +true +false +true +false +false +false +false +runtimeClass = long, toString = Long +true +true +true +false +true +false +false +false +false +runtimeClass = float, toString = Float +true +true +true +false +true +false +false +false +false +runtimeClass = double, toString = Double +true +true +true +false +true +false +false +false +false +runtimeClass = void, toString = Unit +true +true +true +false +true +false +false +false +false +runtimeClass = boolean, toString = Boolean +true +true +true +false +true +false +false +false +false \ No newline at end of file diff --git a/test/files/run/t6246.scala b/test/files/run/t6246.scala new file mode 100644 index 0000000000..28765e1adf --- /dev/null +++ b/test/files/run/t6246.scala @@ -0,0 +1,26 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def testValueClass(tag: ClassTag[_]) { + println(s"runtimeClass = ${tag.runtimeClass}, toString = ${tag.toString}") + println(tag <:< tag) + println(tag <:< ClassTag.AnyVal) + println(tag <:< ClassTag.Any) + println(tag <:< ClassTag.Nothing) + println(ClassTag.Nothing <:< tag) + println(tag <:< ClassTag.Null) + println(ClassTag.Null <:< tag) + println(tag <:< ClassTag.Object) + println(ClassTag.Object <:< tag) + } + + testValueClass(ClassTag.Byte) + testValueClass(ClassTag.Short) + testValueClass(ClassTag.Char) + testValueClass(ClassTag.Int) + testValueClass(ClassTag.Long) + testValueClass(ClassTag.Float) + testValueClass(ClassTag.Double) + testValueClass(ClassTag.Unit) + testValueClass(ClassTag.Boolean) +} \ No newline at end of file -- cgit v1.2.3 From f28e4d246cbb52e81228959fe9d80716cc7e2dc3 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 6 Sep 2012 13:37:40 +0200 Subject: fixes Manifest.Nothing and Manifest.Null Also introduces an important change to Manifest.Nothing and Manifest.Null. Previously their `erasure` was equal to classOf[Object]. Now it's correctly set to classOf[scala.runtime.Nothing$] and classOf[scala.runtime.Null$] correspondingly. See a discussion here: https://groups.google.com/forum/#!topic/scala-internals/Y0ALGo7QPqE --- src/library/scala/reflect/ClassTag.scala | 9 +++++-- src/library/scala/reflect/Manifest.scala | 8 +++--- test/files/run/classtags_core.check | 30 +++++++++++----------- test/files/run/classtags_multi.check | 10 ++++---- .../run/interop_classtags_are_classmanifests.check | 6 ++--- test/files/run/t5881.check | 4 +-- test/files/run/valueclasses-classtag-basic.check | 2 +- .../run/valueclasses-classtag-existential.check | 2 +- test/files/run/valueclasses-classtag-generic.check | 2 +- test/files/run/virtpatmat_typetag.check | 20 +++++++-------- 10 files changed, 49 insertions(+), 44 deletions(-) (limited to 'test') diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 373fdb4129..aaef959d7c 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -2,7 +2,7 @@ package scala.reflect import java.lang.{ Class => jClass } import language.{implicitConversions, existentials} -import scala.runtime.ScalaRunTime.{ arrayClass } +import scala.runtime.ScalaRunTime.{ arrayClass, arrayElementClass } /** A `ClassTag[T]` wraps a runtime class, which can be accessed via the `runtimeClass` method. * @@ -60,7 +60,12 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial override def canEqual(x: Any) = x.isInstanceOf[ClassTag[_]] override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && this.runtimeClass == x.asInstanceOf[ClassTag[_]].runtimeClass override def hashCode = scala.runtime.ScalaRunTime.hash(runtimeClass) - override def toString = "ClassTag[" + runtimeClass + "]" + override def toString = { + def prettyprint(clazz: jClass[_]): String = + if (clazz.isArray) s"Array[${prettyprint(arrayElementClass(clazz))}]" else + clazz.getName + prettyprint(runtimeClass) + } } object ClassTag { diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 8289fdab69..f2a23f4372 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -176,13 +176,13 @@ object ManifestFactory { private def readResolve(): Any = Manifest.AnyVal } - val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null](ObjectTYPE, "Null") { + val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null](NullTYPE, "Null") { override def <:<(that: ClassManifest[_]): Boolean = (that ne null) && (that ne Nothing) && !(that <:< AnyVal) private def readResolve(): Any = Manifest.Null } - val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing](ObjectTYPE, "Nothing") { + val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing](NothingTYPE, "Nothing") { override def <:<(that: ClassManifest[_]): Boolean = (that ne null) private def readResolve(): Any = Manifest.Nothing } @@ -217,8 +217,8 @@ object ManifestFactory { def classType[T](prefix: Manifest[_], clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = new ClassTypeManifest[T](Some(prefix), clazz, args.toList) - private abstract class PhantomManifest[T](override val runtimeClass: Predef.Class[_], - override val toString: String) extends ClassTypeManifest[T](None, runtimeClass, Nil) { + private abstract class PhantomManifest[T](_runtimeClass: Predef.Class[_], + override val toString: String) extends ClassTypeManifest[T](None, _runtimeClass, Nil) { override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef] override val hashCode = System.identityHashCode(this) } diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index 6519db2178..5a9b41fd6d 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,30 @@ true -ClassTag[byte] +Byte true -ClassTag[short] +Short true -ClassTag[char] +Char true -ClassTag[int] +Int true -ClassTag[long] +Long true -ClassTag[float] +Float true -ClassTag[double] +Double true -ClassTag[boolean] +Boolean true -ClassTag[void] +Unit true -ClassTag[class java.lang.Object] +Any true -ClassTag[class java.lang.Object] +AnyVal true -ClassTag[class java.lang.Object] +Object true -ClassTag[class java.lang.Object] +Object true -ClassTag[class scala.runtime.Null$] +Null true -ClassTag[class scala.runtime.Nothing$] +Nothing diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check index 3a7f16c3a0..68cee4841d 100644 --- a/test/files/run/classtags_multi.check +++ b/test/files/run/classtags_multi.check @@ -1,5 +1,5 @@ -ClassTag[int] -ClassTag[class [I] -ClassTag[class [[I] -ClassTag[class [[[I] -ClassTag[class [[[[I] +Int +Array[int] +Array[Array[int]] +Array[Array[Array[int]]] +Array[Array[Array[Array[int]]]] diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check index 7a0a829af2..c07ed0e657 100644 --- a/test/files/run/interop_classtags_are_classmanifests.check +++ b/test/files/run/interop_classtags_are_classmanifests.check @@ -1,3 +1,3 @@ -ClassTag[int] -ClassTag[class java.lang.String] -ClassTag[class [I] +Int +java.lang.String +Array[int] diff --git a/test/files/run/t5881.check b/test/files/run/t5881.check index 477fb935a8..8e596e9323 100644 --- a/test/files/run/t5881.check +++ b/test/files/run/t5881.check @@ -1,2 +1,2 @@ -ClassTag[class scala.collection.immutable.List] -ClassTag[class scala.collection.immutable.List] +scala.collection.immutable.List +scala.collection.immutable.List diff --git a/test/files/run/valueclasses-classtag-basic.check b/test/files/run/valueclasses-classtag-basic.check index 0c13986b32..554c75e074 100644 --- a/test/files/run/valueclasses-classtag-basic.check +++ b/test/files/run/valueclasses-classtag-basic.check @@ -1 +1 @@ -ClassTag[class Foo] +Foo diff --git a/test/files/run/valueclasses-classtag-existential.check b/test/files/run/valueclasses-classtag-existential.check index 95e94e7aee..15ac02630f 100644 --- a/test/files/run/valueclasses-classtag-existential.check +++ b/test/files/run/valueclasses-classtag-existential.check @@ -1 +1 @@ -ClassTag[class java.lang.Object] +Object diff --git a/test/files/run/valueclasses-classtag-generic.check b/test/files/run/valueclasses-classtag-generic.check index 0c13986b32..554c75e074 100644 --- a/test/files/run/valueclasses-classtag-generic.check +++ b/test/files/run/valueclasses-classtag-generic.check @@ -1 +1 @@ -ClassTag[class Foo] +Foo diff --git a/test/files/run/virtpatmat_typetag.check b/test/files/run/virtpatmat_typetag.check index f9800b84d0..eaa9f3361f 100644 --- a/test/files/run/virtpatmat_typetag.check +++ b/test/files/run/virtpatmat_typetag.check @@ -1,10 +1,10 @@ -1 is not a ClassTag[int]; it's a class java.lang.Integer -1 is a ClassTag[class java.lang.Integer] -1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer -true is a ClassTag[class java.lang.Object] -woele is a ClassTag[class java.lang.String] -1 is not a ClassTag[int]; it's a class java.lang.Integer -1 is a ClassTag[class java.lang.Integer] -1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer -true is a ClassTag[class java.lang.Object] -woele is a ClassTag[class java.lang.String] +1 is not a Int; it's a class java.lang.Integer +1 is a java.lang.Integer +1 is not a java.lang.String; it's a class java.lang.Integer +true is a Any +woele is a java.lang.String +1 is not a Int; it's a class java.lang.Integer +1 is a java.lang.Integer +1 is not a java.lang.String; it's a class java.lang.Integer +true is a Any +woele is a java.lang.String -- cgit v1.2.3 From 6a740332c7bfd56b20993be6ecd0bf818104f56c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 6 Sep 2012 21:05:17 +0200 Subject: SI-6318 fixes ClassTag.unapply for primitives ClassTag.unapply now has overloads for primitive value classes so that it can preserve boxiness when performing subtyping tests. First I wanted to annotate ClassTag.unapply with a ClassTag itself, i.e. to transform its signature from "def unapply(x: Any): Option[T]" to "def unapply[U: ClassTag](x: U): Option[T]". But then virtpatmat_typetag.scala exhibited a nasty problem. When pattern matching with this unapply, patmat first infers U as something and then tries to pattern match against this inferred type. And if U gets inferred as an abstract type itself, bad things happen: warning: The outer reference in this type test cannot be checked at run time. That's why I decided to drop the ClassTag idea and go with 9 extra overloads. Not very beautiful, but definitely robust. --- src/library/scala/reflect/ClassTag.scala | 21 +++++++++- test/files/run/t6318_derived.check | 3 ++ test/files/run/t6318_derived.scala | 15 +++++++ test/files/run/t6318_primitives.check | 36 ++++++++++++++++ test/files/run/t6318_primitives.scala | 71 ++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6318_derived.check create mode 100644 test/files/run/t6318_derived.scala create mode 100644 test/files/run/t6318_primitives.check create mode 100644 test/files/run/t6318_primitives.scala (limited to 'test') diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 5255c44f10..8ce06d611e 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -54,7 +54,26 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial * `SomeExtractor(...)` is turned into `ct(SomeExtractor(...))` if `T` in `SomeExtractor.unapply(x: T)` * is uncheckable, but we have an instance of `ClassTag[T]`. */ - def unapply(x: Any): Option[T] = if (x != null && runtimeClass.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[T]) else None + def unapply(x: Any): Option[T] = unapply_impl(x) + def unapply(x: Byte): Option[T] = unapply_impl(x) + def unapply(x: Short): Option[T] = unapply_impl(x) + def unapply(x: Char): Option[T] = unapply_impl(x) + def unapply(x: Int): Option[T] = unapply_impl(x) + def unapply(x: Long): Option[T] = unapply_impl(x) + def unapply(x: Float): Option[T] = unapply_impl(x) + def unapply(x: Double): Option[T] = unapply_impl(x) + def unapply(x: Boolean): Option[T] = unapply_impl(x) + def unapply(x: Unit): Option[T] = unapply_impl(x) + + private def unapply_impl[U: ClassTag](x: U): Option[T] = + if (x == null) None + else { + val staticClass = classTag[U].runtimeClass + val dynamicClass = x.getClass + val effectiveClass = if (staticClass.isPrimitive) staticClass else dynamicClass + val conforms = runtimeClass.isAssignableFrom(effectiveClass) + if (conforms) Some(x.asInstanceOf[T]) else None + } /** case class accessories */ override def canEqual(x: Any) = x.isInstanceOf[ClassTag[_]] diff --git a/test/files/run/t6318_derived.check b/test/files/run/t6318_derived.check new file mode 100644 index 0000000000..ad43b6579b --- /dev/null +++ b/test/files/run/t6318_derived.check @@ -0,0 +1,3 @@ +Some(X) +true +Some(X) diff --git a/test/files/run/t6318_derived.scala b/test/files/run/t6318_derived.scala new file mode 100644 index 0000000000..ccdc18daee --- /dev/null +++ b/test/files/run/t6318_derived.scala @@ -0,0 +1,15 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + class X(val x: Int) extends AnyVal { override def toString = "X" } + val x = new X(1) + // the commented line crashes because of SI-6326 + //println(classTag[X].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[X].unapply(x)) + test(x) +} \ No newline at end of file diff --git a/test/files/run/t6318_primitives.check b/test/files/run/t6318_primitives.check new file mode 100644 index 0000000000..bb474c3bdc --- /dev/null +++ b/test/files/run/t6318_primitives.check @@ -0,0 +1,36 @@ +true +Some(1) +false +None +true +Some(1) +false +None +true +Some() +false +None +true +Some(1) +false +None +true +Some(1) +false +None +true +Some(1.0) +false +None +true +Some(1.0) +false +None +true +Some(true) +false +None +true +Some(()) +false +None diff --git a/test/files/run/t6318_primitives.scala b/test/files/run/t6318_primitives.scala new file mode 100644 index 0000000000..30f27120b3 --- /dev/null +++ b/test/files/run/t6318_primitives.scala @@ -0,0 +1,71 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + { + val x = 1.toByte + println(ClassTag.Byte.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Byte.unapply(x)) + test(x) + } + + { + val x = 1.toShort + println(ClassTag.Short.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Short.unapply(x)) + test(x) + } + + { + val x = 1.toChar + println(ClassTag.Char.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Char.unapply(x)) + test(x) + } + + { + val x = 1.toInt + println(ClassTag.Int.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Int.unapply(x)) + test(x) + } + + { + val x = 1.toLong + println(ClassTag.Long.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Long.unapply(x)) + test(x) + } + + { + val x = 1.toFloat + println(ClassTag.Float.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Float.unapply(x)) + test(x) + } + + { + val x = 1.toDouble + println(ClassTag.Double.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Double.unapply(x)) + test(x) + } + + { + val x = true + println(ClassTag.Boolean.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Boolean.unapply(x)) + test(x) + } + + { + val x = () + println(ClassTag.Unit.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Unit.unapply(x)) + test(x) + } +} \ No newline at end of file -- cgit v1.2.3 From 4831ef51a7b46b6ba4b8e120d5ff2ba66d8f7bac Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 6 Sep 2012 19:11:22 -0400 Subject: Fix for SI-6333 - Try throws from combinators. * Added more comprehensive tests to Try. * Delineated what methods do and don't catch exceptions in docs. * Fixed combinator methods that should catch exceptions. --- src/library/scala/util/Try.scala | 46 ++++++++++++++++++++++++++++------------ test/files/run/t6333.scala | 29 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 test/files/run/t6333.scala (limited to 'test') diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala index f381a18b0c..39500d7aaa 100644 --- a/src/library/scala/util/Try.scala +++ b/src/library/scala/util/Try.scala @@ -52,6 +52,8 @@ import language.implicitConversions * ''Note'': only non-fatal exceptions are caught by the combinators on `Try` (see [[scala.util.control.NonFatal]]). * Serious system errors, on the other hand, will be thrown. * + * ''Note:'': all Try combinators will catch exceptions and return failure unless otherwise specified in the documentation. + * * `Try` comes to the Scala standard library after years of use as an integral part of Twitter's stack. * * @author based on Twitter's original implementation in com.twitter.util. @@ -68,12 +70,19 @@ sealed abstract class Try[+T] { def isSuccess: Boolean /** Returns the value from this `Success` or the given `default` argument if this is a `Failure`. + * + * ''Note:'': This will throw an exception if it is not a success and default throws an exception. */ - def getOrElse[U >: T](default: => U) = if (isSuccess) get else default + def getOrElse[U >: T](default: => U): U = + if (isSuccess) get else default /** Returns this `Try` if it's a `Success` or the given `default` argument if this is a `Failure`. */ - def orElse[U >: T](default: => Try[U]) = if (isSuccess) this else default + def orElse[U >: T](default: => Try[U]): Try[U] = + try if (isSuccess) this else default + catch { + case NonFatal(e) => Failure(e) + } /** Returns the value from this `Success` or throws the exception if this is a `Failure`. */ @@ -81,6 +90,8 @@ sealed abstract class Try[+T] { /** * Applies the given function `f` if this is a `Success`, otherwise returns `Unit` if this is a `Failure`. + * + * ''Note:'' If `f` throws, then this method may throw an exception. */ def foreach[U](f: T => U): Unit @@ -114,7 +125,7 @@ sealed abstract class Try[+T] { /** * Returns `None` if this is a `Failure` or a `Some` containing the value if this is a `Success`. */ - def toOption = if (isSuccess) Some(get) else None + def toOption: Option[T] = if (isSuccess) Some(get) else None /** * Transforms a nested `Try`, ie, a `Try` of type `Try[Try[T]]`, @@ -131,15 +142,21 @@ sealed abstract class Try[+T] { /** Completes this `Try` by applying the function `f` to this if this is of type `Failure`, or conversely, by applying * `s` if this is a `Success`. */ - def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U] = this match { - case Success(v) => s(v) - case Failure(e) => f(e) - } + def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U] = + try this match { + case Success(v) => s(v) + case Failure(e) => f(e) + } catch { + case NonFatal(e) => Failure(e) + } } object Try { - + /** Constructs a `Try` using the by-name parameter. This + * method will ensure any non-fatal exception is caught and a + * `Failure` object is returned. + */ def apply[T](r: => T): Try[T] = { try { Success(r) } catch { case NonFatal(e) => Failure(e) @@ -152,16 +169,20 @@ final case class Failure[+T](val exception: Throwable) extends Try[T] { def isFailure: Boolean = true def isSuccess: Boolean = false def recoverWith[U >: T](f: PartialFunction[Throwable, Try[U]]): Try[U] = - if (f.isDefinedAt(exception)) f(exception) else this + try { + if (f isDefinedAt exception) f(exception) else this + } catch { + case NonFatal(e) => Failure(e) + } def get: T = throw exception def flatMap[U](f: T => Try[U]): Try[U] = Failure[U](exception) def flatten[U](implicit ev: T <:< Try[U]): Try[U] = Failure[U](exception) - def foreach[U](f: T => U): Unit = {} + def foreach[U](f: T => U): Unit = () def map[U](f: T => U): Try[U] = Failure[U](exception) def filter(p: T => Boolean): Try[T] = this - def recover[U >: T](rescueException: PartialFunction[Throwable, U]): Try[U] = { + def recover[U >: T](rescueException: PartialFunction[Throwable, U]): Try[U] = try { - if (rescueException.isDefinedAt(exception)) { + if (rescueException isDefinedAt exception) { Try(rescueException(exception)) } else { this @@ -169,7 +190,6 @@ final case class Failure[+T](val exception: Throwable) extends Try[T] { } catch { case NonFatal(e) => Failure(e) } - } def failed: Try[Throwable] = Success(exception) } diff --git a/test/files/run/t6333.scala b/test/files/run/t6333.scala new file mode 100644 index 0000000000..266d95ce69 --- /dev/null +++ b/test/files/run/t6333.scala @@ -0,0 +1,29 @@ +object Test extends App { + import util.Try + + val a = "apple" + def fail: String = throw new Exception("Fail!") + def argh: Try[String] = throw new Exception("Argh!") + + // No throw tests + def tryMethods(expr: => String): Unit = { + Try(expr) orElse argh + Try(expr).transform(_ => argh, _ => argh) + Try(expr).recoverWith { case e if (a == fail) => Try(a) } + Try(expr).recoverWith { case _ => argh } + Try(expr).getOrElse(a) + // TODO - Fail getOrElse? + Try(expr) orElse argh + Try(expr) orElse Try(a) + Try(expr) map (_ => fail) + Try(expr) map (_ => a) + Try(expr) flatMap (_ => argh) + Try(expr) flatMap (_ => Try(a)) + Try(expr) filter (_ => throw new Exception("O NOES")) + Try(expr) filter (_ => true) + Try(expr) recover { case _ => fail } + Try(expr).failed + } + tryMethods(a) + tryMethods(fail) +} -- cgit v1.2.3 From 7a833f94296849c0e2a6cbacb7e513599c831f38 Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 7 Sep 2012 16:04:52 +0200 Subject: second round of Duration cleanup - make Duration behave consistent with Double's non-finite semantics - add ScalaDoc - add complete test suite - change overflow protection impl after review comments - clean up code --- src/library/scala/concurrent/util/Duration.scala | 522 ++++++++++++++++++----- test/files/jvm/duration-tck.scala | 236 ++++++---- 2 files changed, 582 insertions(+), 176 deletions(-) (limited to 'test') diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index c5b7e8328d..c0eccec4db 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -13,32 +13,108 @@ import TimeUnit._ import java.lang.{ Double => JDouble, Long => JLong } import language.implicitConversions +/** + * This class stores a deadline, as obtained via `Deadline.now` or the + * duration DSL: + * + * {{{ + * import scala.concurrent.util.duration._ + * 3.seconds.fromNow + * }}} + * + * Its main purpose is to manage repeated attempts to achieve something (like + * awaiting a condition) by offering the methods `hasTimeLeft` and `timeLeft`. All + * durations are measured according to `System.nanoTime` aka wall-time; this + * does not take into account changes to the system clock (such as leap + * seconds). + */ case class Deadline private (time: Duration) extends Ordered[Deadline] { + /** + * Return a deadline advanced (i.e. moved into the future) by the given duration. + */ def +(other: Duration): Deadline = copy(time = time + other) + /** + * Return a deadline moved backwards (i.e. towards the past) by the given duration. + */ def -(other: Duration): Deadline = copy(time = time - other) + /** + * Calculate time difference between this and the other deadline, where the result is directed (i.e. may be negative). + */ def -(other: Deadline): Duration = time - other.time + /** + * Calculate time difference between this duration and now; the result is negative if the deadline has passed. + * + * '''''Note that on some systems this operation is costly because it entails a system call.''''' + * Check `System.nanoTime` for your platform. + */ def timeLeft: Duration = this - Deadline.now + /** + * Determine whether the deadline still lies in the future at the point where this method is called. + * + * '''''Note that on some systems this operation is costly because it entails a system call.''''' + * Check `System.nanoTime` for your platform. + */ def hasTimeLeft(): Boolean = !isOverdue() + /** + * Determine whether the deadline lies in the past at the point where this method is called. + * + * '''''Note that on some systems this operation is costly because it entails a system call.''''' + * Check `System.nanoTime` for your platform. + */ def isOverdue(): Boolean = (time.toNanos - System.nanoTime()) < 0 + /** + * The natural ordering for deadline is determined by the natural order of the underlying (finite) duration. + */ def compare(other: Deadline) = time compare other.time } object Deadline { + /** + * Construct a deadline due exactly at the point where this method is called. Useful for then + * advancing it to obtain a future deadline, or for sampling the current time exactly once and + * then comparing it to multiple deadlines (using subtraction). + */ def now: Deadline = Deadline(Duration(System.nanoTime, NANOSECONDS)) + /** + * The natural ordering for deadline is determined by the natural order of the underlying (finite) duration. + */ implicit object DeadlineIsOrdered extends Ordering[Deadline] { def compare(a: Deadline, b: Deadline) = a compare b } } -// TODO: "Inf", "PlusInf", "MinusInf", where did these names come from? -// TODO: Duration.create(n, DAYS) == Duration(Long.MaxValue, NANOSECONDS) forall (n: Double) >= 106752d object Duration { + /** + * This implicit conversion allows the use of a Deadline in place of a Duration, which will + * insert the time left until the deadline in its place. + */ implicit def timeLeft(implicit d: Deadline): Duration = d.timeLeft - def apply(length: Double, unit: TimeUnit): FiniteDuration = fromNanos(unit.toNanos(1) * length) - def apply(length: Long, unit: TimeUnit): FiniteDuration = new FiniteDuration(length, unit) - def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit)) + /** + * Construct a Duration from the given length and unit. Observe that nanosecond precision may be lost if + * + * - the unit is NANOSECONDS + * - and the length has an absolute value greater than 2^53 + * + * Will throw an exception if the length was finite but the resulting duration cannot be expressed + * as a [[FiniteDuration]]. Infinite inputs (and NaN) are converted into [[Duration.Inf]], + * [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + */ + def apply(length: Double, unit: TimeUnit): Duration = fromNanos(unit.toNanos(1) * length) + /** + * Construct a finite duration from the given length and time unit. The unit given is retained + * throughout calculations as long as possible, so that it can be retrieved later. + */ + def apply(length: Long, unit: TimeUnit): FiniteDuration = new FiniteDuration(length, unit) + /** + * Construct a finite duration from the given length and time unit, where the latter is + * looked up in a list of string representation. Valid choices are: + * + * `d, day, h, hour, min, minute, s, sec, second, ms, milli, millisecond, µs, micro, microsecond, ns, nano, nanosecond` + * and their pluralized forms (for every but the first mentioned form of each unit, i.e. no "ds", but "days"). + */ + def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit)) /** * Parse String into Duration. Format is `""`, where @@ -88,131 +164,217 @@ object Duration { protected[util] val timeUnit: Map[String, TimeUnit] = timeUnitLabels flatMap { case (unit, names) => expandLabels(names) map (_ -> unit) } toMap + /** + * Extract length and time unit out of a string, where the format must match the description for [[Duration$.apply(String):Duration apply(String)]]. + * The extractor will not match for malformed strings or non-finite durations. + */ def unapply(s: String): Option[(Long, TimeUnit)] = ( try Some(apply(s)) catch { case _: RuntimeException => None } ) flatMap unapply + /** + * Extract length and time unit out of a duration, if it is finite. + */ def unapply(d: Duration): Option[(Long, TimeUnit)] = if (d.isFinite) Some((d.length, d.unit)) else None - def fromNanos(nanos: Double): FiniteDuration = { - if (nanos > Long.MaxValue || nanos < Long.MinValue) + /** + * Construct a possibly infinite or undefined Duration from the given number of nanoseconds. + * + * - `Double.PositiveInfinity` is mapped to [[Duration.Inf]] + * - `Double.NegativeInfinity` is mapped to [[Duration.MinusInf]] + * - `Double.NaN` is mapped to [[Duration.Undefined]] + * - `-0d` is mapped to [[Duration.Zero]] (exactly like `0d`) + * + * The semantics of the resulting Duration objects matches the semantics of their Double + * counterparts with respect to arithmetic operations. + */ + def fromNanos(nanos: Double): Duration = { + if (nanos.isInfinite) + if (nanos > 0) Inf else MinusInf + else if (nanos.isNaN) + Undefined + else if (nanos > Long.MaxValue || nanos < Long.MinValue) throw new IllegalArgumentException("trying to construct too large duration with " + nanos + "ns") - fromNanos((nanos + 0.5).toLong) + else + fromNanos((nanos + 0.5).toLong) } + private val µs_per_ns = 1000L + private val ms_per_ns = µs_per_ns * 1000 + private val s_per_ns = ms_per_ns * 1000 + private val min_per_ns = s_per_ns * 60 + private val h_per_ns = min_per_ns * 60 + private val d_per_ns = h_per_ns * 24 + + /** + * Construct a finite duration from the given number of nanoseconds. This will throw an + * exception for `Long.MinValue` since that would lead to inconsistent behavior afterwards + * (cannot be negated). The result will have the coarsest possible time unit which can + * exactly express this duration. + */ def fromNanos(nanos: Long): FiniteDuration = { - if (nanos % 86400000000000L == 0) { - Duration(nanos / 86400000000000L, DAYS) - } else if (nanos % 3600000000000L == 0) { - Duration(nanos / 3600000000000L, HOURS) - } else if (nanos % 60000000000L == 0) { - Duration(nanos / 60000000000L, MINUTES) - } else if (nanos % 1000000000L == 0) { - Duration(nanos / 1000000000L, SECONDS) - } else if (nanos % 1000000L == 0) { - Duration(nanos / 1000000L, MILLISECONDS) - } else if (nanos % 1000L == 0) { - Duration(nanos / 1000L, MICROSECONDS) - } else { - Duration(nanos, NANOSECONDS) - } + if (nanos % d_per_ns == 0) Duration(nanos / d_per_ns, DAYS) + else if (nanos % h_per_ns == 0) Duration(nanos / h_per_ns, HOURS) + else if (nanos % min_per_ns == 0) Duration(nanos / min_per_ns, MINUTES) + else if (nanos % s_per_ns == 0) Duration(nanos / s_per_ns, SECONDS) + else if (nanos % ms_per_ns == 0) Duration(nanos / ms_per_ns, MILLISECONDS) + else if (nanos % µs_per_ns == 0) Duration(nanos / µs_per_ns, MICROSECONDS) + else Duration(nanos, NANOSECONDS) } /** - * Parse TimeUnit from string representation. + * Preconstructed value of `0.days`. */ + // unit as coarse as possible to keep (_ + Zero) sane unit-wise + val Zero: FiniteDuration = new FiniteDuration(0, DAYS) - val Zero: FiniteDuration = new FiniteDuration(0, NANOSECONDS) - - object Undefined extends Infinite { - private def fail(what: String) = throw new IllegalArgumentException(s"cannot $what Undefined duration") - + /** + * The Undefined value corresponds closely to Double.NaN: + * + * - it is the result of otherwise invalid operations + * - it does not equal itself (according to `equals()`) + * - it compares greater than any other Duration apart from itself (for which `compare` returns 0) + * + * The particular comparison semantics mirror those of Double.NaN. + * + * '''''Use `eq` when checking an input of a method against this value.''''' + */ + val Undefined: Infinite = new Infinite { override def toString = "Duration.Undefined" - override def equals(other: Any) = this eq other.asInstanceOf[AnyRef] - override def +(other: Duration): Duration = fail("add") - override def -(other: Duration): Duration = fail("subtract") - override def *(factor: Double): Duration = fail("multiply") - override def /(factor: Double): Duration = fail("divide") - override def /(other: Duration): Double = fail("divide") - def compare(other: Duration) = fail("compare") - def unary_- : Duration = fail("negate") + override def equals(other: Any) = false + override def +(other: Duration): Duration = this + override def -(other: Duration): Duration = this + override def *(factor: Double): Duration = this + override def /(factor: Double): Duration = this + override def /(other: Duration): Double = Double.NaN + def compare(other: Duration) = if (other eq this) 0 else 1 + def unary_- : Duration = this + def toUnit(unit: TimeUnit): Double = Double.NaN } sealed abstract class Infinite extends Duration { def +(other: Duration): Duration = other match { - case x: Infinite if x ne this => throw new IllegalArgumentException("illegal addition of infinities") + case x if x eq Undefined => Undefined + case x: Infinite if x ne this => Undefined case _ => this } - // Is this really intended to throw if the argument is "this" but otherwise return this? - def -(other: Duration): Duration = - if (other ne this) this - else throw new IllegalArgumentException("illegal subtraction of infinities") - - private def mult(f: Double) = - if (f == 0d) fail("multiply by zero") - else if (f < 0d) -this + def -(other: Duration): Duration = other match { + case x if x eq Undefined => Undefined + case x: Infinite if x eq this => Undefined + case _ => this + } + + def *(factor: Double): Duration = + if (factor == 0d || factor.isNaN) Undefined + else if (factor < 0d) -this + else this + def /(factor: Double): Duration = + if (factor == 0d || factor.isNaN || factor.isInfinite) Undefined + else if (factor < 0d) -this else this - def *(factor: Double): Duration = mult(factor) - def /(factor: Double): Duration = mult(factor) def /(other: Duration): Double = other match { - case _: Infinite => throw new IllegalArgumentException("illegal division of infinities") - // maybe questionable but pragmatic: Inf / 0 => Inf + case _: Infinite => Double.NaN case x => Double.PositiveInfinity * (if ((this > Zero) ^ (other >= Zero)) -1 else 1) } final def isFinite() = false private def fail(what: String) = throw new IllegalArgumentException(s"$what not allowed on infinite Durations") - def length: Long = fail("length") - def toNanos: Long = fail("toNanos") - def toMicros: Long = fail("toMicros") - def toMillis: Long = fail("toMillis") - def toSeconds: Long = fail("toSeconds") - def toMinutes: Long = fail("toMinutes") - def toHours: Long = fail("toHours") - def toDays: Long = fail("toDays") - - def unit: TimeUnit = fail("unit") - def toUnit(unit: TimeUnit): Double = fail("toUnit") + final def length: Long = fail("length") + final def unit: TimeUnit = fail("unit") + final def toNanos: Long = fail("toNanos") + final def toMicros: Long = fail("toMicros") + final def toMillis: Long = fail("toMillis") + final def toSeconds: Long = fail("toSeconds") + final def toMinutes: Long = fail("toMinutes") + final def toHours: Long = fail("toHours") + final def toDays: Long = fail("toDays") } /** - * Infinite duration: greater than any other and not equal to any other, - * including itself. + * Infinite duration: greater than any other (apart from Undefined) and not equal to any other + * but itself. This value closely corresponds to Double.PositiveInfinity, + * matching its semantics in arithmetic operations. */ val Inf: Infinite = new Infinite { override def toString = "Duration.Inf" - def compare(other: Duration) = if (other eq this) 0 else 1 + def compare(other: Duration) = other match { + case x if x eq Undefined => -1 + case x if x eq this => 0 + case _ => 1 + } def unary_- : Duration = MinusInf + def toUnit(unit: TimeUnit): Double = Double.PositiveInfinity } /** - * Infinite negative duration: lesser than any other and not equal to any other, - * including itself. + * Infinite duration: less than any other and not equal to any other + * but itself. This value closely corresponds to Double.NegativeInfinity, + * matching its semantics in arithmetic operations. */ val MinusInf: Infinite = new Infinite { override def toString = "Duration.MinusInf" - def compare(other: Duration) = if (other eq this) 0 else -1 + def compare(other: Duration) = other match { + case x if x eq this => 0 + case _ => -1 + } def unary_- : Duration = Inf + def toUnit(unit: TimeUnit): Double = Double.NegativeInfinity } // Java Factories - def create(length: Long, unit: TimeUnit): FiniteDuration = apply(length, unit) - def create(length: Double, unit: TimeUnit): FiniteDuration = apply(length, unit) - def create(length: Long, unit: String): FiniteDuration = apply(length, unit) - def create(s: String): Duration = apply(s) + /** + * Construct a finite duration from the given length and time unit. The unit given is retained + * throughout calculations as long as possible, so that it can be retrieved later. + */ + def create(length: Long, unit: TimeUnit): FiniteDuration = apply(length, unit) + /** + * Construct a Duration from the given length and unit. Observe that nanosecond precision may be lost if + * + * - the unit is NANOSECONDS + * - and the length has an absolute value greater than 2^53 + * + * Will throw an exception if the length was finite but the resulting duration cannot be expressed + * as a [[FiniteDuration]]. Infinite inputs (and NaN) are converted into [[Duration.Inf]], + * [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + */ + def create(length: Double, unit: TimeUnit): Duration = apply(length, unit) + /** + * Construct a finite duration from the given length and time unit, where the latter is + * looked up in a list of string representation. Valid choices are: + * + * `d, day, h, hour, min, minute, s, sec, second, ms, milli, millisecond, µs, micro, microsecond, ns, nano, nanosecond` + * and their pluralized forms (for every but the first mentioned form of each unit, i.e. no "ds", but "days"). + */ + def create(length: Long, unit: String): FiniteDuration = apply(length, unit) + /** + * Parse String into Duration. Format is `""`, where + * whitespace is allowed before, between and after the parts. Infinities are + * designated by `"Inf"`, `"PlusInf"`, `"+Inf"` and `"-Inf"` or `"MinusInf"`. + * Throws exception if format is not parseable. + */ + def create(s: String): Duration = apply(s) + + /** + * The natural ordering of durations matches the natural ordering for Double, including non-finite values. + */ implicit object DurationIsOrdered extends Ordering[Duration] { def compare(a: Duration, b: Duration) = a compare b } } /** - * Utility for working with java.util.concurrent.TimeUnit durations. + *

Utility for working with java.util.concurrent.TimeUnit durations.

+ * + * '''''This class is not meant as a general purpose representation of time, it is + * optimized for the needs of `scala.concurrent`.''''' + * + *

Basic Usage

* *

* Examples: - *

+ * {{{
  * import scala.concurrent.util.Duration
  * import java.util.concurrent.TimeUnit
  *
@@ -222,57 +384,196 @@ object Duration {
  * duration.toNanos
  * duration < 1.second
  * duration <= Duration.Inf
- * 
+ * }}} + * + * '''''Invoking inexpressible conversions (like calling `toSeconds` on an infinite duration) will throw an IllegalArgumentException.''''' * *

* Implicits are also provided for Int, Long and Double. Example usage: - *

+ * {{{
  * import scala.concurrent.util.Duration._
  *
  * val duration = 100 millis
- * 
+ * }}} + * + * '''''The DSL provided by the implicit conversions always allows construction of finite durations, even for infinite Double inputs; use Duration.Inf instead.''''' * * Extractors, parsing and arithmetic are also included: - *
+ * {{{
  * val d = Duration("1.2 µs")
  * val Duration(length, unit) = 5 millis
  * val d2 = d * 2.5
  * val d3 = d2 + 1.millisecond
- * 
+ * }}} + * + *

Handling of Time Units

+ * + * Calculations performed on finite durations always retain the more precise unit of either operand, no matter + * whether a coarser unit would be able to exactly express the same duration. This means that Duration can be + * used as a lossless container for a (length, unit) pair if it is constructed using the corresponding methods + * and no arithmetic is performed on it; adding/subtracting durations should in that case be done with care. + * + *

Correspondence to Double Semantics

+ * + * The semantics of arithmetic operations on Duration are two-fold: + * + * - exact addition/subtraction with nanosecond resolution for finite durations, independent of the summands' magnitude + * - isomorphic to `java.lang.Double` when it comes to infinite or undefined values + * + * The conversion between Duration and Double is done using [[Duration.toUnit]] (with unit NANOSECONDS) + * and [[Duration$.fromNanos(Double):Duration Duration.fromNanos(Double)]]. + * + *

Ordering

+ * + * The default ordering is consistent with the ordering of Double numbers, which means that Undefined is + * considered greater than all other durations, including [[Duration.Inf]]. + * + * @define exc Invoking this method on a non-finite duration will result in an IllegalArgumentException. */ -abstract class Duration extends Serializable with Ordered[Duration] { +sealed abstract class Duration extends Serializable with Ordered[Duration] { + /** + * Obtain the length of this Duration measured in the unit obtained by the `unit` method. $exc + */ def length: Long + /** + * Obtain the time unit in which the length of this duration is measured. $exc + */ def unit: TimeUnit + /** + * Return the length of this duration measured in whole nanoseconds, rounding towards zero. $exc + */ def toNanos: Long + /** + * Return the length of this duration measured in whole microseconds, rounding towards zero. $exc + */ def toMicros: Long + /** + * Return the length of this duration measured in whole milliseconds, rounding towards zero. $exc + */ def toMillis: Long + /** + * Return the length of this duration measured in whole seconds, rounding towards zero. $exc + */ def toSeconds: Long + /** + * Return the length of this duration measured in whole minutes, rounding towards zero. $exc + */ def toMinutes: Long + /** + * Return the length of this duration measured in whole hours, rounding towards zero. $exc + */ def toHours: Long + /** + * Return the length of this duration measured in whole days, rounding towards zero. $exc + */ def toDays: Long + /** + * Return the number of nanoseconds as floating point number, scaled down to the given unit. + * The result may not precisely represent this duration due to the Double datatype's inherent + * limitations (mantissa size effectively 53 bits). Non-finite durations are represented as + * - [[Duration.Undefined]] is mapped to Double.NaN + * - [[Duration.Inf]] is mapped to Double.PositiveInfinity + * - [[Duration.MinusInf]] is mapped to Double.NegativeInfinity + */ def toUnit(unit: TimeUnit): Double + /** + * Return the sum of that duration and this. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite summands the semantics match those + * of Double. + */ def +(other: Duration): Duration + /** + * Return the difference of that duration and this. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite summands the semantics match those + * of Double. + */ def -(other: Duration): Duration + /** + * Return this duration multiplied by the scalar factor. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite factors the semantics match those + * of Double. + */ def *(factor: Double): Duration + /** + * Return this duration divided by the scalar factor. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite factors the semantics match those + * of Double. + */ def /(factor: Double): Duration + /** + * Return the quotient of this and that duration as floating-point number. The semantics are + * determined by Double as if calculating the quotient of the nanosecond lengths of both factors. + */ def /(other: Duration): Double + /** + * Negate this duration. The only two values which are mapped to themselves are [[Duration.Zero]] and [[Duration.Undefined]]. + */ def unary_- : Duration + /** + * This method returns whether this duration is finite, which is not the same as + * `!isInfinite` for Double because this method also returns `false` for [[Duration.Undefined]]. + */ def isFinite(): Boolean + /** + * Return the smaller of this and that duration as determined by the natural ordering. + */ def min(other: Duration): Duration = if (this < other) this else other + /** + * Return the larger of this and that duration as determined by the natural ordering. + */ def max(other: Duration): Duration = if (this > other) this else other + /** + * Construct a [[Deadline]] from this duration by adding it to the current instant `Duration.now`. + */ def fromNow: Deadline = Deadline.now + this // Java API + + /** + * Return this duration divided by the scalar factor. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite factors the semantics match those + * of Double. + */ def div(factor: Double) = this / factor + /** + * Return the quotient of this and that duration as floating-point number. The semantics are + * determined by Double as if calculating the quotient of the nanosecond lengths of both factors. + */ def div(other: Duration) = this / other def gt(other: Duration) = this > other def gteq(other: Duration) = this >= other def lt(other: Duration) = this < other def lteq(other: Duration) = this <= other + /** + * Return the difference of that duration and this. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite summands the semantics match those + * of Double. + */ def minus(other: Duration) = this - other + /** + * Return this duration multiplied by the scalar factor. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite factors the semantics match those + * of Double. + */ def mul(factor: Double) = this * factor + /** + * Negate this duration. The only two values which are mapped to themselves are [[Duration.Zero]] and [[Duration.Undefined]]. + */ def neg() = -this + /** + * Return the sum of that duration and this. In case of an overflow, an IllegalArgumentException + * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite + * durations takes place. When involving non-finite summands the semantics match those + * of Double. + */ def plus(other: Duration) = this + other } @@ -285,6 +586,10 @@ object FiniteDuration { def apply(length: Long, unit: String) = new FiniteDuration(length, Duration.timeUnit(unit)) } +/** + * This class represents a finite duration. Its addition and subtraction operators are overloaded to retain + * this guarantee statically. The range of this class is limited to +-(2^63-1)ns, which is roughly 292 years. + */ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { import Duration._ @@ -293,7 +598,7 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { * sorted so that the first cases should be most-used ones, because enum * is checked one after the other. */ - case NANOSECONDS ⇒ true + case NANOSECONDS ⇒ length != Long.MinValue case MICROSECONDS ⇒ length <= 9223372036854775L && length >= -9223372036854775L case MILLISECONDS ⇒ length <= 9223372036854L && length >= -9223372036854L case SECONDS ⇒ length <= 9223372036L && length >= -9223372036L @@ -301,9 +606,9 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { case HOURS ⇒ length <= 2562047L && length >= -2562047L case DAYS ⇒ length <= 106751L && length >= -106751L case _ ⇒ - val v = unit.convert(length, DAYS) + val v = DAYS.convert(length, unit) v <= 106751L && v >= -106751L - }, "Duration is limited to 2^63ns (ca. 292 years)") + }, "Duration is limited to +-(2^63-1)ns (ca. 292 years)") def toNanos = unit.toNanos(length) def toMicros = unit.toMicros(length) @@ -322,30 +627,49 @@ class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duration { case _ => -(other compare this) } - private def add(a: Long, b: Long): Long = { - val c = a + b - // check if the signs of the top bit of both summands differ from the sum - if (((a ^ c) & (b ^ c)) < 0) throw new IllegalArgumentException("integer overflow") - else c + // see https://www.securecoding.cert.org/confluence/display/java/NUM00-J.+Detect+or+prevent+integer+overflow + private def safeAdd(a: Long, b: Long): Long = { + if ((b > 0) && (a > Long.MaxValue - b) || + (b < 0) && (a < Long.MinValue - b)) throw new IllegalArgumentException("integer overflow") + a + b + } + private def add(otherLength: Long, otherUnit: TimeUnit): FiniteDuration = { + val commonUnit = if (otherUnit.convert(1, unit) == 0) unit else otherUnit + val totalLength = safeAdd(commonUnit.convert(length, unit), commonUnit.convert(otherLength, otherUnit)) + new FiniteDuration(totalLength, commonUnit) } + def +(other: Duration) = other match { - case x: FiniteDuration => fromNanos(add(toNanos, x.toNanos)) + case x: FiniteDuration => add(x.length, x.unit) case _ => other } def -(other: Duration) = other match { - case x: FiniteDuration => fromNanos(add(toNanos, -x.toNanos)) + case x: FiniteDuration => add(-x.length, x.unit) case _ => other } - def *(factor: Double) = fromNanos(toNanos.toDouble * factor) - - def /(factor: Double) = fromNanos(toNanos.toDouble / factor) - - def /(other: Duration) = if (other.isFinite) toNanos.toDouble / other.toNanos else 0 + def *(factor: Double) = + if (!factor.isInfinite) fromNanos(toNanos * factor) + else if (factor.isNaN) Undefined + else if ((factor > 0) ^ (this < Zero)) Inf + else MinusInf + + def /(factor: Double) = + if (!factor.isInfinite) fromNanos(toNanos / factor) + else if (factor.isNaN) Undefined + else Zero + + // if this is made a constant, then scalac will elide the conditional and always return +0.0, SI-6331 + private def minusZero = -0d + def /(other: Duration): Double = + if (other.isFinite) toNanos.toDouble / other.toNanos + else if (other eq Undefined) Double.NaN + else if ((length < 0) ^ (other > Zero)) 0d + else minusZero // overridden methods taking FiniteDurations, so that you can calculate while statically staying finite - def +(other: FiniteDuration) = fromNanos(add(toNanos, other.toNanos)) - def -(other: FiniteDuration) = fromNanos(add(toNanos, -other.toNanos)) + def +(other: FiniteDuration) = add(other.length, other.unit) + def -(other: FiniteDuration) = add(-other.length, other.unit) def plus(other: FiniteDuration) = this + other def minus(other: FiniteDuration) = this - other override def div(factor: Double) = this / factor @@ -432,5 +756,9 @@ final class DurationLong(val n: Long) extends AnyVal with DurationConversions { } final class DurationDouble(val d: Double) extends AnyVal with DurationConversions { - override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(d, unit) + override protected def durationIn(unit: TimeUnit): FiniteDuration = + Duration(d, unit) match { + case f: FiniteDuration => f + case _ => throw new IllegalArgumentException("Duration DSL not applicable to " + d) + } } diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index 679712aa59..aa1ac50078 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -10,7 +10,13 @@ import java.util.concurrent.TimeUnit._ object Test extends App { implicit class Assert(val left: Any) extends AnyVal { - def =!=(right: Any) = assert(left == right, s"$left was not equal to $right") + import Duration.Undefined + def mustBe(right: Any) = right match { + case r: Double if r.isNaN => assert(left.asInstanceOf[Double].isNaN, s"$left was not NaN") + case r: Double if r == 0 && r.compareTo(0) == -1 => assert(left == 0 && left.asInstanceOf[Double].compareTo(0) == -1, s"$left was not -0.0") + case Undefined => assert(left.asInstanceOf[AnyRef] eq Undefined, s"$left was not Undefined") + case _ => assert(left == right, s"$left was not equal to $right") + } } def intercept[T <: Exception : ClassTag](code: => Unit) = @@ -19,89 +25,161 @@ object Test extends App { case ex: Exception => if (classTag[T].runtimeClass isAssignableFrom ex.getClass) () else throw ex } - { // test field ops - val zero = 0 seconds - val one = 1 second - val two = one + one - val three = 3 * one - (0 * one) =!= (zero) - (2 * one) =!= (two) - (three - two) =!= (one) - (three / 3) =!= (one) - (two / one) =!= (2) - (one + zero) =!= (one) - (one / 1000000) =!= (1.micro) - } + val zero = 0 seconds + val one = 1 second + val two = one + one + val three = 3 * one + val inf = Duration.Inf + val minf = Duration.MinusInf + val undef = Duration.Undefined + val inputs = List(zero, one, inf, minf, undef) + val nan = Double.NaN - { // test infinities - val one = 1.second - val inf = Duration.Inf - val minf = Duration.MinusInf - (-inf) =!= (minf) - intercept[IllegalArgumentException] { minf + inf } - intercept[IllegalArgumentException] { inf - inf } - intercept[IllegalArgumentException] { inf + minf } - intercept[IllegalArgumentException] { minf - minf } - (inf + inf) =!= (inf) - (inf - minf) =!= (inf) - (minf - inf) =!= (minf) - (minf + minf) =!= (minf) - assert(inf == inf) - assert(minf == minf) - inf.compareTo(inf) =!= (0) - inf.compareTo(one) =!= (1) - minf.compareTo(minf) =!= (0) - minf.compareTo(one) =!= (-1) - assert(inf != minf) - assert(minf != inf) - assert(one != inf) - assert(minf != one) - inf =!= (minf * -1d) - inf =!= (minf / -1d) - } + // test field ops + one.isFinite mustBe true + 0 * one mustBe zero + 2 * one mustBe two + three - two mustBe one + three / 3 mustBe one + two / one mustBe 2 + one + zero mustBe one + one / 1000000 mustBe 1.micro + + + // test infinities + + inf.isFinite mustBe false + minf.isFinite mustBe false + + inf mustBe inf + minf mustBe minf + -inf mustBe minf + -minf mustBe inf + + minf + inf mustBe undef + inf - inf mustBe undef + inf + minf mustBe undef + minf - minf mustBe undef + + inf + inf mustBe inf + inf - minf mustBe inf + minf - inf mustBe minf + minf + minf mustBe minf + + inf.compareTo(inf) mustBe 0 + inf.compareTo(one) mustBe 1 + inf.compareTo(minf) mustBe 1 + minf.compareTo(minf) mustBe 0 + minf.compareTo(one) mustBe -1 + minf.compareTo(inf) mustBe -1 + + assert(inf != minf) + assert(minf != inf) + assert(one != inf) + assert(minf != one) + + inf mustBe (minf * -1d) + inf mustBe (minf / -1d) + + one / inf mustBe 0d + -one / inf mustBe -0d + one / minf mustBe -0d + -one / minf mustBe 0d + + inputs filterNot (_.isFinite) foreach (x => x / zero mustBe x.toUnit(DAYS)) + inputs filterNot (_.isFinite) foreach (_ * 0d mustBe undef) + inputs filterNot (_.isFinite) foreach (x => x * Double.PositiveInfinity mustBe x) + inputs filterNot (_.isFinite) foreach (x => x * Double.NegativeInfinity mustBe -x) + + inf.toUnit(SECONDS) mustBe Double.PositiveInfinity + minf.toUnit(MINUTES) mustBe Double.NegativeInfinity + Duration.fromNanos(Double.PositiveInfinity) mustBe inf + Duration.fromNanos(Double.NegativeInfinity) mustBe minf + - { // test overflow protection - for (unit ← Seq(DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS, NANOSECONDS)) { - val x = unit.convert(Long.MaxValue, NANOSECONDS) - val dur = Duration(x, unit) - val mdur = Duration(-x, unit) - -mdur =!= (dur) - intercept[IllegalArgumentException] { Duration(x + 10000000d, unit) } - intercept[IllegalArgumentException] { Duration(-x - 10000000d, unit) } - if (unit != NANOSECONDS) { - intercept[IllegalArgumentException] { Duration(x + 1, unit) } - intercept[IllegalArgumentException] { Duration(-x - 1, unit) } - } - intercept[IllegalArgumentException] { dur + 1.day } - intercept[IllegalArgumentException] { mdur - 1.day } - intercept[IllegalArgumentException] { dur * 1.1 } - intercept[IllegalArgumentException] { mdur * 1.1 } - intercept[IllegalArgumentException] { dur * 2.1 } - intercept[IllegalArgumentException] { mdur * 2.1 } - intercept[IllegalArgumentException] { dur / 0.9 } - intercept[IllegalArgumentException] { mdur / 0.9 } - intercept[IllegalArgumentException] { dur / 0.4 } - intercept[IllegalArgumentException] { mdur / 0.4 } - Duration(x + unit.toString.toLowerCase) - Duration("-" + x + unit.toString.toLowerCase) - intercept[IllegalArgumentException] { Duration("%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } - intercept[IllegalArgumentException] { Duration("-%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + // test undefined & NaN + + undef.isFinite mustBe false + -undef mustBe undef + assert(undef != undef) + assert(undef eq undef) + + inputs foreach (_ + undef mustBe undef) + inputs foreach (_ - undef mustBe undef) + inputs foreach (_ / undef mustBe nan) + inputs foreach (_ / nan mustBe undef) + inputs foreach (_ * nan mustBe undef) + inputs foreach (undef + _ mustBe undef) + inputs foreach (undef - _ mustBe undef) + inputs foreach (undef / _ mustBe nan) + inputs filter (_.isFinite) foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + + inputs filterNot (_ eq undef) foreach (_ compareTo undef mustBe -1) + inputs filterNot (_ eq undef) foreach (undef compareTo _ mustBe 1) + undef compare undef mustBe 0 + + undef.toUnit(DAYS) mustBe nan + Duration.fromNanos(nan) mustBe undef + + + // test overflow protection + for (unit ← Seq(DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS, NANOSECONDS)) { + val x = unit.convert(Long.MaxValue, NANOSECONDS) + val dur = Duration(x, unit) + val mdur = Duration(-x, unit) + -mdur mustBe (dur) + intercept[IllegalArgumentException] { Duration(x + 10000000d, unit) } + intercept[IllegalArgumentException] { Duration(-x - 10000000d, unit) } + if (unit != NANOSECONDS) { + intercept[IllegalArgumentException] { Duration(x + 1, unit) } + intercept[IllegalArgumentException] { Duration(-x - 1, unit) } } + intercept[IllegalArgumentException] { dur + 1.day } + intercept[IllegalArgumentException] { mdur - 1.day } + intercept[IllegalArgumentException] { dur * 1.1 } + intercept[IllegalArgumentException] { mdur * 1.1 } + intercept[IllegalArgumentException] { dur * 2.1 } + intercept[IllegalArgumentException] { mdur * 2.1 } + intercept[IllegalArgumentException] { dur / 0.9 } + intercept[IllegalArgumentException] { mdur / 0.9 } + intercept[IllegalArgumentException] { dur / 0.4 } + intercept[IllegalArgumentException] { mdur / 0.4 } + Duration(x + unit.toString.toLowerCase) + Duration("-" + x + unit.toString.toLowerCase) + intercept[IllegalArgumentException] { Duration("%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + intercept[IllegalArgumentException] { Duration("-%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } } + intercept[IllegalArgumentException] { Duration.fromNanos(1e20) } + intercept[IllegalArgumentException] { Duration.fromNanos(-1e20) } + - { // test Deadline - val dead = 2.seconds.fromNow - val dead2 = 2 seconds fromNow - // view bounds vs. very local type inference vs. operator precedence: sigh - assert(dead.timeLeft > (1 second: Duration)) - assert(dead2.timeLeft > (1 second: Duration)) - Thread.sleep(1.second.toMillis) - assert(dead.timeLeft < (1 second: Duration)) - assert(dead2.timeLeft < (1 second: Duration)) - } + // test precision + 1.second + 1.millisecond mustBe 1001.milliseconds + 100000.days + 1.nanosecond mustBe 8640000000000000001L.nanoseconds + 1.5.seconds.toSeconds mustBe 1 + (-1.5).seconds.toSeconds mustBe -1 + - { // check statically retaining finite-ness - val d: FiniteDuration = 1.second * 2 / 1.4 mul 1.1 div 2.1 plus 3.seconds minus 1.millisecond min 1.second max 1.second - } + // test unit stability + 1000.millis.unit mustBe MILLISECONDS + (1000.millis + 0.days).unit mustBe MILLISECONDS + 1.second.unit mustBe SECONDS + (1.second + 1.millisecond).unit mustBe MILLISECONDS + + + // test Deadline + val dead = 2.seconds.fromNow + val dead2 = 2 seconds fromNow + // view bounds vs. very local type inference vs. operator precedence: sigh + assert(dead.timeLeft > (1 second: Duration)) + assert(dead2.timeLeft > (1 second: Duration)) + Thread.sleep(1.second.toMillis) + assert(dead.timeLeft < (1 second: Duration)) + assert(dead2.timeLeft < (1 second: Duration)) + + + // check statically retaining finite-ness + val finiteDuration: FiniteDuration = 1.second plus 3.seconds minus 1.millisecond min 1.second max 1.second + } -- cgit v1.2.3 From f41d3ade90c3cfee772b6475eca7350883b81e2c Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 7 Sep 2012 21:35:17 +0200 Subject: fix some one more issue in Duration - Inf / Zero == Inf - add some more missing test cases - clarify magic constant - move exception descriptions into proper @throws docs --- src/library/scala/concurrent/util/Duration.scala | 133 ++++++++++++++--------- test/files/jvm/duration-tck.scala | 18 ++- 2 files changed, 91 insertions(+), 60 deletions(-) (limited to 'test') diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index c0eccec4db..391549ef72 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -97,9 +97,9 @@ object Duration { * - the unit is NANOSECONDS * - and the length has an absolute value greater than 2^53 * - * Will throw an exception if the length was finite but the resulting duration cannot be expressed - * as a [[FiniteDuration]]. Infinite inputs (and NaN) are converted into [[Duration.Inf]], - * [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + * Infinite inputs (and NaN) are converted into [[Duration.Inf]], [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + * + * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] */ def apply(length: Double, unit: TimeUnit): Duration = fromNanos(unit.toNanos(1) * length) /** @@ -116,11 +116,15 @@ object Duration { */ def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit)) + // Double stores 52 bits mantissa, but there is an implied '1' in front, making the limit 2^53 + final val maxPreciseDouble = 9007199254740992d + /** * Parse String into Duration. Format is `""`, where * whitespace is allowed before, between and after the parts. Infinities are * designated by `"Inf"`, `"PlusInf"`, `"+Inf"` and `"-Inf"` or `"MinusInf"`. - * Throws exception if format is not parseable. + * + * @throws NumberFormatException if format is not parseable */ def apply(s: String): Duration = { val s1: String = s filterNot (_.isWhitespace) @@ -133,9 +137,9 @@ object Duration { case Some(unit) => val valueStr = s1 dropRight unitName.length val valueD = JDouble.parseDouble(valueStr) - if (valueD <= 9007199254740992d && valueD >= -9007199254740992d) Duration(valueD, unit) + if (valueD >= -maxPreciseDouble && valueD <= maxPreciseDouble) Duration(valueD, unit) else Duration(JLong.parseLong(valueStr), unit) - case _ => sys.error("format error " + s) + case _ => throw new NumberFormatException("format error " + s) } } } @@ -187,6 +191,8 @@ object Duration { * * The semantics of the resulting Duration objects matches the semantics of their Double * counterparts with respect to arithmetic operations. + * + * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] */ def fromNanos(nanos: Double): Duration = { if (nanos.isInfinite) @@ -207,10 +213,11 @@ object Duration { private val d_per_ns = h_per_ns * 24 /** - * Construct a finite duration from the given number of nanoseconds. This will throw an - * exception for `Long.MinValue` since that would lead to inconsistent behavior afterwards - * (cannot be negated). The result will have the coarsest possible time unit which can - * exactly express this duration. + * Construct a finite duration from the given number of nanoseconds. The + * result will have the coarsest possible time unit which can exactly express + * this duration. + * + * @throws IllegalArgumentException for `Long.MinValue` since that would lead to inconsistent behavior afterwards (cannot be negated) */ def fromNanos(nanos: Long): FiniteDuration = { if (nanos % d_per_ns == 0) Duration(nanos / d_per_ns, DAYS) @@ -269,8 +276,8 @@ object Duration { else if (factor < 0d) -this else this def /(factor: Double): Duration = - if (factor == 0d || factor.isNaN || factor.isInfinite) Undefined - else if (factor < 0d) -this + if (factor.isNaN || factor.isInfinite) Undefined + else if ((factor compare 0d) < 0) -this else this def /(other: Duration): Double = other match { case _: Infinite => Double.NaN @@ -314,10 +321,7 @@ object Duration { */ val MinusInf: Infinite = new Infinite { override def toString = "Duration.MinusInf" - def compare(other: Duration) = other match { - case x if x eq this => 0 - case _ => -1 - } + def compare(other: Duration) = if (other eq this) 0 else -1 def unary_- : Duration = Inf def toUnit(unit: TimeUnit): Double = Double.NegativeInfinity } @@ -335,9 +339,9 @@ object Duration { * - the unit is NANOSECONDS * - and the length has an absolute value greater than 2^53 * - * Will throw an exception if the length was finite but the resulting duration cannot be expressed - * as a [[FiniteDuration]]. Infinite inputs (and NaN) are converted into [[Duration.Inf]], - * [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + * Infinite inputs (and NaN) are converted into [[Duration.Inf]], [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. + * + * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] */ def create(length: Double, unit: TimeUnit): Duration = apply(length, unit) /** @@ -352,7 +356,8 @@ object Duration { * Parse String into Duration. Format is `""`, where * whitespace is allowed before, between and after the parts. Infinities are * designated by `"Inf"`, `"PlusInf"`, `"+Inf"` and `"-Inf"` or `"MinusInf"`. - * Throws exception if format is not parseable. + * + * @throws NumberFormatException if format is not parseable */ def create(s: String): Duration = apply(s) @@ -428,43 +433,63 @@ object Duration { * The default ordering is consistent with the ordering of Double numbers, which means that Undefined is * considered greater than all other durations, including [[Duration.Inf]]. * - * @define exc Invoking this method on a non-finite duration will result in an IllegalArgumentException. + * @define exc @throws IllegalArgumentException when invoked on a non-finite duration + * + * @define ovf @throws IllegalArgumentException in case of a finite overflow: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite durations takes place. */ sealed abstract class Duration extends Serializable with Ordered[Duration] { /** - * Obtain the length of this Duration measured in the unit obtained by the `unit` method. $exc + * Obtain the length of this Duration measured in the unit obtained by the `unit` method. + * + * $exc */ def length: Long /** - * Obtain the time unit in which the length of this duration is measured. $exc + * Obtain the time unit in which the length of this duration is measured. + * + * $exc */ def unit: TimeUnit /** - * Return the length of this duration measured in whole nanoseconds, rounding towards zero. $exc + * Return the length of this duration measured in whole nanoseconds, rounding towards zero. + * + * $exc */ def toNanos: Long /** - * Return the length of this duration measured in whole microseconds, rounding towards zero. $exc + * Return the length of this duration measured in whole microseconds, rounding towards zero. + * + * $exc */ def toMicros: Long /** - * Return the length of this duration measured in whole milliseconds, rounding towards zero. $exc + * Return the length of this duration measured in whole milliseconds, rounding towards zero. + * + * $exc */ def toMillis: Long /** - * Return the length of this duration measured in whole seconds, rounding towards zero. $exc + * Return the length of this duration measured in whole seconds, rounding towards zero. + * + * $exc */ def toSeconds: Long /** - * Return the length of this duration measured in whole minutes, rounding towards zero. $exc + * Return the length of this duration measured in whole minutes, rounding towards zero. + * + * $exc */ def toMinutes: Long /** - * Return the length of this duration measured in whole hours, rounding towards zero. $exc + * Return the length of this duration measured in whole hours, rounding towards zero. + * + * $exc */ def toHours: Long /** - * Return the length of this duration measured in whole days, rounding towards zero. $exc + * Return the length of this duration measured in whole days, rounding towards zero. + * + * $exc */ def toDays: Long /** @@ -478,31 +503,31 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { def toUnit(unit: TimeUnit): Double /** - * Return the sum of that duration and this. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite summands the semantics match those + * Return the sum of that duration and this. When involving non-finite summands the semantics match those * of Double. + * + * $ovf */ def +(other: Duration): Duration /** - * Return the difference of that duration and this. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite summands the semantics match those + * Return the difference of that duration and this. When involving non-finite summands the semantics match those * of Double. + * + * $ovf */ def -(other: Duration): Duration /** - * Return this duration multiplied by the scalar factor. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite factors the semantics match those + * Return this duration multiplied by the scalar factor. When involving non-finite factors the semantics match those * of Double. + * + * $ovf */ def *(factor: Double): Duration /** - * Return this duration divided by the scalar factor. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite factors the semantics match those + * Return this duration divided by the scalar factor. When involving non-finite factors the semantics match those * of Double. + * + * $ovf */ def /(factor: Double): Duration /** @@ -535,10 +560,10 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { // Java API /** - * Return this duration divided by the scalar factor. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite factors the semantics match those + * Return this duration divided by the scalar factor. When involving non-finite factors the semantics match those * of Double. + * + * $ovf */ def div(factor: Double) = this / factor /** @@ -551,17 +576,17 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { def lt(other: Duration) = this < other def lteq(other: Duration) = this <= other /** - * Return the difference of that duration and this. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite summands the semantics match those + * Return the difference of that duration and this. When involving non-finite summands the semantics match those * of Double. + * + * $ovf */ def minus(other: Duration) = this - other /** - * Return this duration multiplied by the scalar factor. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite factors the semantics match those + * Return this duration multiplied by the scalar factor. When involving non-finite factors the semantics match those * of Double. + * + * $ovf */ def mul(factor: Double) = this * factor /** @@ -569,10 +594,10 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { */ def neg() = -this /** - * Return the sum of that duration and this. In case of an overflow, an IllegalArgumentException - * is thrown: the range of a finite duration is +-(2^63-1)ns, and no conversion to infinite - * durations takes place. When involving non-finite summands the semantics match those + * Return the sum of that duration and this. When involving non-finite summands the semantics match those * of Double. + * + * $ovf */ def plus(other: Duration) = this + other } diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index aa1ac50078..87ffa196ca 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -88,6 +88,7 @@ object Test extends App { inputs filterNot (_.isFinite) foreach (x => x / zero mustBe x.toUnit(DAYS)) inputs filterNot (_.isFinite) foreach (_ * 0d mustBe undef) + inputs filterNot (_.isFinite) foreach (_ * -0d mustBe undef) inputs filterNot (_.isFinite) foreach (x => x * Double.PositiveInfinity mustBe x) inputs filterNot (_.isFinite) foreach (x => x * Double.NegativeInfinity mustBe -x) @@ -112,7 +113,13 @@ object Test extends App { inputs foreach (undef + _ mustBe undef) inputs foreach (undef - _ mustBe undef) inputs foreach (undef / _ mustBe nan) - inputs filter (_.isFinite) foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + undef / 1 mustBe undef + undef / nan mustBe undef + undef * 1 mustBe undef + undef * nan mustBe undef + inputs foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + inputs foreach (x => x / 0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / 0d)) + inputs foreach (x => x / -0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / -0d)) inputs filterNot (_ eq undef) foreach (_ compareTo undef mustBe -1) inputs filterNot (_ eq undef) foreach (undef compareTo _ mustBe 1) @@ -170,12 +177,11 @@ object Test extends App { // test Deadline val dead = 2.seconds.fromNow val dead2 = 2 seconds fromNow - // view bounds vs. very local type inference vs. operator precedence: sigh - assert(dead.timeLeft > (1 second: Duration)) - assert(dead2.timeLeft > (1 second: Duration)) + assert(dead.timeLeft > 1.second) + assert(dead2.timeLeft > 1.second) Thread.sleep(1.second.toMillis) - assert(dead.timeLeft < (1 second: Duration)) - assert(dead2.timeLeft < (1 second: Duration)) + assert(dead.timeLeft < 1.second) + assert(dead2.timeLeft < 1.second) // check statically retaining finite-ness -- cgit v1.2.3 From 73cb55a80dc65577e593f59a16098cf915527a1d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 8 Sep 2012 00:03:18 -0700 Subject: Fix for SI-6327, wrongness in Dynamic. --- .../scala/tools/nsc/typechecker/Typers.scala | 20 +++++++++++++------- test/files/run/t6327.check | 4 ++++ test/files/run/t6327.scala | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 test/files/run/t6327.check create mode 100644 test/files/run/t6327.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 21d61ff7b1..1beae1464a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3811,18 +3811,23 @@ trait Typers extends Modes with Adaptations with Tags { * - simplest solution: have two method calls * */ - def mkInvoke(cxTree: Tree, tree: Tree, qual: Tree, name: Name): Option[Tree] = + def mkInvoke(cxTree: Tree, tree: Tree, qual: Tree, name: Name): Option[Tree] = { + debuglog(s"mkInvoke($cxTree, $tree, $qual, $name)") acceptsApplyDynamicWithType(qual, name) map { tp => // tp eq NoType => can call xxxDynamic, but not passing any type args (unless specified explicitly by the user) // in scala-virtualized, when not NoType, tp is passed as type argument (for selection on a staged Struct) - // strip off type application -- we're not doing much with outer, so don't bother preserving cxTree's attributes etc - val (outer, explicitTargs) = cxTree match { - case TypeApply(fun, targs) => (fun, targs) - case Apply(TypeApply(fun, targs), args) => (Apply(fun, args), targs) - case t => (t, Nil) + // strip off type application -- we're not doing much with outer, + // so don't bother preserving cxTree's attributes etc + val cxTree1 = cxTree match { + case t: ValOrDefDef => t.rhs + case t => t + } + val (outer, explicitTargs) = cxTree1 match { + case TypeApply(fun, targs) => (fun, targs) + case Apply(TypeApply(fun, targs), args) => (Apply(fun, args), targs) + case t => (t, Nil) } - @inline def hasNamedArg(as: List[Tree]) = as.collectFirst{case AssignOrNamedArg(lhs, rhs) =>}.nonEmpty // note: context.tree includes at most one Apply node @@ -3847,6 +3852,7 @@ trait Typers extends Modes with Adaptations with Tags { atPos(qual.pos)(Apply(tappSel, List(Literal(Constant(name.decode))))) } + } } @inline final def deindentTyping() = context.typingIndentLevel -= 2 diff --git a/test/files/run/t6327.check b/test/files/run/t6327.check new file mode 100644 index 0000000000..f7bacac931 --- /dev/null +++ b/test/files/run/t6327.check @@ -0,0 +1,4 @@ +A +A +A +A diff --git a/test/files/run/t6327.scala b/test/files/run/t6327.scala new file mode 100644 index 0000000000..7683101f14 --- /dev/null +++ b/test/files/run/t6327.scala @@ -0,0 +1,22 @@ +import language._ + +object Test extends App { + + case class R[+T](s: String) { def x() = println(s) } + + // Implicits in contention; StringR is nested to avoid ambiguity + object R { implicit val StringR = R[String]("A") } + implicit val Default = R[Any]("B") + + class B() extends Dynamic { + def selectDynamic[T](f: String)(implicit r: R[T]): Unit = r.x() + } + + val b = new B() + + // These should all produce the same output, but they don't + b.selectDynamic[String]("baz") + b.baz[String] + val c = b.selectDynamic[String]("baz") + val d = b.baz[String] +} -- cgit v1.2.3 From 7059d568fdcad4d5b510966fce5dbc573f1aa797 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 8 Sep 2012 13:00:05 +0200 Subject: Makes getClass of a value class work. --- src/compiler/scala/tools/nsc/transform/Erasure.scala | 6 ++++-- src/reflect/scala/reflect/internal/Definitions.scala | 1 + test/files/run/getClassTest-valueClass.check | 2 ++ test/files/run/getClassTest-valueClass.scala | 10 ++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/files/run/getClassTest-valueClass.check create mode 100644 test/files/run/getClassTest-valueClass.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index d97fbf5daa..bfede7a690 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -326,7 +326,7 @@ abstract class Erasure extends AddInterfaces } // Methods on Any/Object which we rewrite here while we still know what // is a primitive and what arrived boxed. - private lazy val interceptedMethods = Set[Symbol](Any_##, Object_##, Any_getClass) ++ ( + private lazy val interceptedMethods = Set[Symbol](Any_##, Object_##, Any_getClass, AnyVal_getClass) ++ ( // Each value class has its own getClass for ultra-precise class object typing. ScalaValueClasses map (_.tpe member nme.getClass_) ) @@ -1069,9 +1069,11 @@ abstract class Erasure extends AddInterfaces case _ => global.typer.typed(gen.mkRuntimeCall(nme.hash_, List(qual))) } - } else if (isPrimitiveValueClass(qual.tpe.typeSymbol)) { + } else if (isPrimitiveValueClass(qual.tpe.typeSymbol)) { // Rewrite 5.getClass to ScalaRunTime.anyValClass(5) global.typer.typed(gen.mkRuntimeCall(nme.anyValClass, List(qual, typer.resolveClassTag(tree.pos, qual.tpe.widen)))) + } else if (fn.symbol == AnyVal_getClass) { + tree setSymbol Object_getClass } else { tree } diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index c21ebfe997..4e44b76607 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -277,6 +277,7 @@ trait Definitions extends api.StandardDefinitions { anyval }).asInstanceOf[ClassSymbol] lazy val AnyValTpe = definitions.AnyValClass.toTypeConstructor + def AnyVal_getClass = getMemberMethod(AnyValClass, nme.getClass_) // bottom types lazy val RuntimeNothingClass = getClassByName(fulltpnme.RuntimeNothing) diff --git a/test/files/run/getClassTest-valueClass.check b/test/files/run/getClassTest-valueClass.check new file mode 100644 index 0000000000..7608d92b4e --- /dev/null +++ b/test/files/run/getClassTest-valueClass.check @@ -0,0 +1,2 @@ +int +class V diff --git a/test/files/run/getClassTest-valueClass.scala b/test/files/run/getClassTest-valueClass.scala new file mode 100644 index 0000000000..05a116dfff --- /dev/null +++ b/test/files/run/getClassTest-valueClass.scala @@ -0,0 +1,10 @@ +class V(val x: Int) extends AnyVal + +object Test { + def main(args: Array[String]) = { + val v = new V(2) + val s: Any = 2 + println(2.getClass) + println(v.getClass) + } +} -- cgit v1.2.3 From c619f94a9cfbddc12c9c5df3affb4636f8982a0a Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 8 Sep 2012 18:37:59 +0200 Subject: SI-6331 Avoid typing an If tree with a constant type. The fast path in typedIf added in 8552740b avoided lubbing the if/else branch types if they are identical, but this fails to deconst the type. This could lead to the entire if expression being replaced by a constant. Also introduces a new tool in partest for nicer checkfiles. // in Test.scala trace(if (t) -0d else 0d) // in Test.check trace> if (Test.this.t) -0.0 else 0.0 res: Double = -0.0 --- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- src/partest/scala/tools/partest/package.scala | 27 +++++++++++++++++++ test/files/run/t6331b.check | 30 ++++++++++++++++++++++ test/files/run/t6331b.scala | 20 +++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6331b.check create mode 100644 test/files/run/t6331b.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9cf5d42e00..c878828aad 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4067,7 +4067,7 @@ trait Typers extends Modes with Adaptations with Tags { if ( opt.virtPatmat && !isPastTyper && thenp1.tpe.annotations.isEmpty && elsep1.tpe.annotations.isEmpty // annotated types need to be lubbed regardless (at least, continations break if you by pass them like this) && thenTp =:= elseTp - ) (thenp1.tpe, false) // use unpacked type + ) (thenp1.tpe.deconst, false) // use unpacked type. Important to deconst, as is done in ptOrLub, otherwise `if (???) 0 else 0` evaluates to 0 (SI-6331) // TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala else ptOrLub(thenp1.tpe :: elsep1.tpe :: Nil, pt) diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 08934ef143..49d3ed301c 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -73,4 +73,31 @@ package object partest { def isPartestDebug: Boolean = propOrEmpty("partest.debug") == "true" + + + import language.experimental.macros + + /** + * `trace("".isEmpty)` will return `true` and as a side effect print the following to standard out. + * {{{ + * trace> "".isEmpty + * res: Boolean = true + * + * }}} + * + * An alternative to [[scala.tools.partest.ReplTest]] that avoids the inconvenience of embedding + * test code in a string. + */ + def trace[A](a: A) = macro traceImpl[A] + + import scala.reflect.macros.Context + def traceImpl[A: c.AbsTypeTag](c: Context)(a: c.Expr[A]): c.Expr[A] = { + import c.universe._ + val exprCode = c.literal(show(a.tree)) + val exprType = c.literal(show(a.actualType)) + reify { + println(s"trace> ${exprCode.splice}\nres: ${exprType.splice} = ${a.splice}\n") + a.splice + } + } } diff --git a/test/files/run/t6331b.check b/test/files/run/t6331b.check new file mode 100644 index 0000000000..6ca09e3814 --- /dev/null +++ b/test/files/run/t6331b.check @@ -0,0 +1,30 @@ +trace> if (Test.this.t) + -0.0 +else + 0.0 +res: Double = -0.0 + +trace> if (Test.this.t) + 0.0 +else + -0.0 +res: Double = 0.0 + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + -0.0 +else + 0.0) +res: Any = class scala.NotImplementedError + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + 0.0 +else + 0.0) +res: Any = class scala.NotImplementedError + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + () +else + ()) +res: Any = class scala.NotImplementedError + diff --git a/test/files/run/t6331b.scala b/test/files/run/t6331b.scala new file mode 100644 index 0000000000..f966abea51 --- /dev/null +++ b/test/files/run/t6331b.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +import scala.tools.partest.trace +import scala.util.control.Exception._ + + +object Test extends App { + def intercept = allCatch.withApply(_.getClass) + val t: Boolean = true + trace(if (t) -0d else 0d) + trace(if (t) 0d else -0d) + trace(intercept(if (???) -0d else 0d)) + trace(intercept(if (???) 0d else 0d)) + trace(intercept(if (???) () else ())) +} -- cgit v1.2.3 From 815f60ff9c50d22a23fbc9d980570fb6941a7d71 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 8 Sep 2012 18:43:22 +0200 Subject: Refine equality of Constant types over floating point values. The constant types for 0d and -0d should not be equal. This is implemented by checking equality of the result of doubleToRawLongBits / floatToRawIntBits, which also correctly considers two NaNs of the same flavour to be equal. Followup to SI-6331. --- src/reflect/scala/reflect/internal/Constants.scala | 12 ++++- test/files/run/t6331.check | 23 ++++++++ test/files/run/t6331.scala | 63 ++++++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 test/files/run/t6331.check create mode 100644 test/files/run/t6331.scala (limited to 'test') diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index e5a543da46..4d512e3864 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -83,8 +83,16 @@ trait Constants extends api.Constants { */ override def equals(other: Any): Boolean = other match { case that: Constant => - this.tag == that.tag && - (this.value == that.value || this.isNaN && that.isNaN) + // Consider two NaNs to be identical, despite non-equality + // Consider -0d to be distinct from 0d, despite equality + import java.lang.Double.doubleToRawLongBits + import java.lang.Float.floatToRawIntBits + + this.tag == that.tag && ((value, that.value) match { + case (f1: Float, f2: Float) => floatToRawIntBits(f1) == floatToRawIntBits(f2) + case (d1: Double, d2: Double) => doubleToRawLongBits(d1) == doubleToRawLongBits(d2) + case (v1, v2) => v1 == v2 + }) case _ => false } diff --git a/test/files/run/t6331.check b/test/files/run/t6331.check new file mode 100644 index 0000000000..9bf3f7823a --- /dev/null +++ b/test/files/run/t6331.check @@ -0,0 +1,23 @@ + () == () + true == true + true != false + false != true + 0.toByte == 0.toByte + 0.toByte != 1.toByte + 0.toShort == 0.toShort + 0.toShort != 1.toShort + 0 == 0 + 0 != 1 + 0L == 0L + 0L != 1L + 0.0f == 0.0f + 0.0f != -0.0f + -0.0f != 0.0f + NaNf == NaNf + 0.0d == 0.0d + 0.0d != -0.0d + -0.0d != 0.0d + NaNd == NaNd + 0 != 0.0d + 0 != 0L + 0.0d != 0.0f diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala new file mode 100644 index 0000000000..e9ed96fad3 --- /dev/null +++ b/test/files/run/t6331.scala @@ -0,0 +1,63 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +// Test of Constant#equals, which must must account for floating point intricacies. +object Test extends DirectTest { + + override def code = "" + + override def show() { + val global = newCompiler() + import global._ + + def check(c1: Any, c2: Any): Unit = { + val equal = Constant(c1) == Constant(c2) + def show(a: Any) = "" + a + (a match { + case _: Byte => ".toByte" + case _: Short => ".toShort" + case _: Long => "L" + case _: Float => "f" + case _: Double => "d" + case _ => "" + }) + val op = if (equal) "==" else "!=" + println(f"${show(c1)}%12s $op ${show(c2)}") + } + + check((), ()) + + check(true, true) + check(true, false) + check(false, true) + + check(0.toByte, 0.toByte) + check(0.toByte, 1.toByte) + + check(0.toShort, 0.toShort) + check(0.toShort, 1.toShort) + + check(0, 0) + check(0, 1) + + check(0L, 0L) + check(0L, 1L) + + check(0f, 0f) + check(0f, -0f) + check(-0f, 0f) + check(Float.NaN, Float.NaN) + + check(0d, 0d) + check(0d, -0d) + check(-0d, 0d) + check(Double.NaN, Double.NaN) + + check(0, 0d) + check(0, 0L) + check(0d, 0f) + } +} -- cgit v1.2.3 From aedb8db47338637430672b145cfc11e8d89441b9 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 11:16:24 +0200 Subject: Test for consistency of Constant#{equals, hashCode}. For the examples I've constructed, they are consistent, but I put this down to good luck, rather than good management. The next commit will address this. --- test/files/run/t6331.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala index e9ed96fad3..4e43a7686e 100644 --- a/test/files/run/t6331.scala +++ b/test/files/run/t6331.scala @@ -15,7 +15,9 @@ object Test extends DirectTest { import global._ def check(c1: Any, c2: Any): Unit = { - val equal = Constant(c1) == Constant(c2) + val const1 = Constant(c1) + val const2 = Constant(c2) + val equal = const1 == const2 def show(a: Any) = "" + a + (a match { case _: Byte => ".toByte" case _: Short => ".toShort" @@ -26,6 +28,12 @@ object Test extends DirectTest { }) val op = if (equal) "==" else "!=" println(f"${show(c1)}%12s $op ${show(c2)}") + + val hash1 = const1.hashCode + val hash2 = const2.hashCode + val hashesEqual = hash1 == hash2 + val hashBroken = equal && !hashesEqual + if (hashBroken) println(f"$hash1%12s != $hash2 // hash codes differ for equal objects!!") } check((), ()) -- cgit v1.2.3 From b43b3b0ba8ac55ea9c1727b8a4c5e9ad5696fe6d Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 13:49:43 +0200 Subject: SI-6335 More precise location of the implicit class synthetic method. One approach would be to disallow an implicit class in a template that already has a member with the same name. But this commit doesn't do this; instead it uses `isSynthetic` to find the synthesized implicit conversion method from the potentially overloaded alternatives. --- .../scala/tools/nsc/typechecker/MethodSynthesis.scala | 4 ++-- test/files/pos/t6335.scala | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/files/pos/t6335.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 4f597f97c9..83740f1658 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -369,7 +369,7 @@ trait MethodSynthesis { } /** A synthetic method which performs the implicit conversion implied by - * the declaration of an implicit class. Yet to be written. + * the declaration of an implicit class. */ case class ImplicitClassWrapper(tree: ClassDef) extends DerivedFromClassDef { def completer(sym: Symbol): Type = ??? // not needed @@ -377,7 +377,7 @@ trait MethodSynthesis { def derivedSym: Symbol = { // Only methods will do! Don't want to pick up any stray // companion objects of the same name. - val result = enclClass.info decl name suchThat (_.isMethod) + val result = enclClass.info decl name suchThat (x => x.isMethod && x.isSynthetic) assert(result != NoSymbol, "not found: "+name+" in "+enclClass+" "+enclClass.info.decls) result } diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala new file mode 100644 index 0000000000..a39c4f27f5 --- /dev/null +++ b/test/files/pos/t6335.scala @@ -0,0 +1,11 @@ +object E { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } +} + +object Test { + import E._ + 0.xx +} -- cgit v1.2.3 From 6f78b501c226bd3c24c516801a23865531591ebe Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 14:10:53 +0200 Subject: More tests for SI-6335. --- test/files/neg/t6335.check | 9 +++++++++ test/files/neg/t6335.scala | 7 +++++++ test/files/pos/t6335.scala | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t6335.check create mode 100644 test/files/neg/t6335.scala (limited to 'test') diff --git a/test/files/neg/t6335.check b/test/files/neg/t6335.check new file mode 100644 index 0000000000..1727a05eb2 --- /dev/null +++ b/test/files/neg/t6335.check @@ -0,0 +1,9 @@ +t6335.scala:6: error: method Z is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class Z[A](val i: A) { def zz = i } + ^ +t6335.scala:3: error: method X is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class X(val x: Int) { def xx = x } + ^ +two errors found diff --git a/test/files/neg/t6335.scala b/test/files/neg/t6335.scala new file mode 100644 index 0000000000..5c41e81ef5 --- /dev/null +++ b/test/files/neg/t6335.scala @@ -0,0 +1,7 @@ +object ImplicitClass { + def X(i: Int) {} + implicit class X(val x: Int) { def xx = x } + + def Z[A](i: A) {} + implicit class Z[A](val i: A) { def zz = i } +} \ No newline at end of file diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala index a39c4f27f5..50e34092d1 100644 --- a/test/files/pos/t6335.scala +++ b/test/files/pos/t6335.scala @@ -1,11 +1,25 @@ -object E { +object E extends Z { def X = 3 implicit class X(val i: Int) { def xx = i } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 } object Test { import E._ 0.xx + + "".yy + + true.zz } -- cgit v1.2.3 From 24b0711f01dcb410ffd0454881f7a96073f92e16 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 16:59:43 +0200 Subject: SI-6276 Warn on def or val that trivially loops infinitely --- .../scala/tools/nsc/typechecker/RefChecks.scala | 13 ++++++++++ test/files/neg/override.check | 2 +- test/files/neg/override.scala | 2 +- test/files/neg/t6276.check | 13 ++++++++++ test/files/neg/t6276.flags | 1 + test/files/neg/t6276.scala | 29 ++++++++++++++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/t6276.check create mode 100644 test/files/neg/t6276.flags create mode 100644 test/files/neg/t6276.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 166bb2d18c..dd4f13fd7b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1197,6 +1197,18 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R case _ => } + // SI-6276 warn for `def foo = foo` or `val bar: X = bar`, which come up more frequently than you might think. + def checkInfiniteLoop(valOrDef: ValOrDefDef) { + val trivialInifiniteLoop = ( + !valOrDef.isErroneous + && !valOrDef.symbol.isValueParameter + && valOrDef.symbol.paramss.isEmpty + && valOrDef.rhs.hasSymbolWhich(_.accessedOrSelf == valOrDef.symbol) + ) + if (trivialInifiniteLoop) + unit.warning(valOrDef.rhs.pos, s"${valOrDef.symbol.fullLocationString} does nothing other than call itself recursively") + } + // Transformation ------------------------------------------------------------ /* Convert a reference to a case factory of type `tpe` to a new of the class it produces. */ @@ -1640,6 +1652,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R case ValDef(_, _, _, _) | DefDef(_, _, _, _, _, _) => checkDeprecatedOvers(tree) + checkInfiniteLoop(tree.asInstanceOf[ValOrDefDef]) if (settings.warnNullaryUnit.value) checkNullaryMethodReturnType(sym) if (settings.warnInaccessible.value) { diff --git a/test/files/neg/override.check b/test/files/neg/override.check index fc152cb3b1..8be98bf4d0 100644 --- a/test/files/neg/override.check +++ b/test/files/neg/override.check @@ -1,5 +1,5 @@ override.scala:9: error: overriding type T in trait A with bounds >: Int <: Int; type T in trait B with bounds >: String <: String has incompatible type - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} ^ one error found diff --git a/test/files/neg/override.scala b/test/files/neg/override.scala index 3e589b52e3..7975516061 100755 --- a/test/files/neg/override.scala +++ b/test/files/neg/override.scala @@ -6,7 +6,7 @@ trait X { trait Y extends X { trait B { type T >: String <: String } - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} n = "foo" } diff --git a/test/files/neg/t6276.check b/test/files/neg/t6276.check new file mode 100644 index 0000000000..8bd92cf293 --- /dev/null +++ b/test/files/neg/t6276.check @@ -0,0 +1,13 @@ +t6276.scala:4: error: method a does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:5: error: value b does nothing other than call itself recursively + val b: Any = b // warn + ^ +t6276.scala:10: error: method a does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:19: error: method a does nothing other than call itself recursively + def a = a // warn + ^ +four errors found diff --git a/test/files/neg/t6276.flags b/test/files/neg/t6276.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6276.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6276.scala b/test/files/neg/t6276.scala new file mode 100644 index 0000000000..8333618964 --- /dev/null +++ b/test/files/neg/t6276.scala @@ -0,0 +1,29 @@ +object Test { + def foo(a: Int, b: Int, c: Int) { + new { + def a: Any = a // warn + val b: Any = b // warn + } + + def method { + // method local + def a: Any = a // warn + } + + trait T { + def a: Any + } + + new T { + // inherited return type + def a = a // warn + } + + // no warnings below + new { + def a: Any = {println(""); a} + val b: Any = {println(""); b} + def c(i: Int): Any = c(i - 0) + } + } +} -- cgit v1.2.3 From ed723738e643035609efda49e6be689e4b0b0480 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Thu, 23 Aug 2012 11:25:01 -0700 Subject: SI-6278 fixed: synthetic implicit def must sort with its associated implicit class Add a case to the ad-hoc (or add-hack) addSynthetics to keep the trees close. This relies on naming convention, so changes in naming of the implicit def would require an update here. --- .../scala/tools/nsc/typechecker/Typers.scala | 6 +++++ test/files/pos/t6278-synth-def.scala | 30 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/files/pos/t6278-synth-def.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 21d61ff7b1..d055c6ec48 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2743,12 +2743,18 @@ trait Typers extends Modes with Adaptations with Tags { // this code by associating defaults and companion objects // with the original tree instead of the new symbol. def matches(stat: Tree, synt: Tree) = (stat, synt) match { + // synt is default arg for stat case (DefDef(_, statName, _, _, _, _), DefDef(mods, syntName, _, _, _, _)) => mods.hasDefaultFlag && syntName.toString.startsWith(statName.toString) + // synt is companion module case (ClassDef(_, className, _, _), ModuleDef(_, moduleName, _)) => className.toTermName == moduleName + // synt is implicit def for implicit class (#6278) + case (ClassDef(cmods, cname, _, _), DefDef(dmods, dname, _, _, _, _)) => + cmods.isImplicit && dmods.isImplicit && cname.toTermName == dname + case _ => false } diff --git a/test/files/pos/t6278-synth-def.scala b/test/files/pos/t6278-synth-def.scala new file mode 100644 index 0000000000..b8b660fbe3 --- /dev/null +++ b/test/files/pos/t6278-synth-def.scala @@ -0,0 +1,30 @@ + +package t6278 + +import language.implicitConversions + +object test { + def ok() { + class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + implicit def toFoo(i: Int): Foo = new Foo(i) + + val k = 1 + k foo println("k?") + val j = 2 + } + def nope() { + implicit class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + + val k = 1 + k foo println("k?") + //lazy + val j = 2 + } + def main(args: Array[String]) { + ok(); nope() + } +} -- cgit v1.2.3 From 3767a6a83efc74d34e9025f798eeb2a043e6df8d Mon Sep 17 00:00:00 2001 From: Roland Date: Mon, 10 Sep 2012 15:52:07 +0200 Subject: fix usage of Duration in Promise impl - correctly treat MinusInf and Undefined - don't toMillis in the timeout message (could be MinusInf) - also notice that Inf did not actually wait unbounded - and further notice that tryAwait swallows InterruptedException instead of bailing out early => changed to do so and added throws annotation - also removed some unused imports of Duration --- src/library/scala/concurrent/Awaitable.scala | 5 ++++ src/library/scala/concurrent/BlockContext.scala | 3 -- .../scala/concurrent/ExecutionContext.scala | 1 - src/library/scala/concurrent/Future.scala | 1 - .../concurrent/impl/ExecutionContextImpl.scala | 1 - src/library/scala/concurrent/impl/Promise.scala | 33 +++++++++++++++------ src/library/scala/concurrent/package.scala | 3 ++ test/files/jvm/scala-concurrent-tck.scala | 34 ++++++++++++++++++++++ 8 files changed, 66 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/src/library/scala/concurrent/Awaitable.scala b/src/library/scala/concurrent/Awaitable.scala index 99bdfbc5a9..2205dd9869 100644 --- a/src/library/scala/concurrent/Awaitable.scala +++ b/src/library/scala/concurrent/Awaitable.scala @@ -18,13 +18,18 @@ trait Awaitable[+T] { /** * Should throw [[scala.concurrent.TimeoutException]] if it times out * This method should not be called directly. + * + * @throws InterruptedException if the wait call was interrupted */ @throws(classOf[TimeoutException]) + @throws(classOf[InterruptedException]) def ready(atMost: Duration)(implicit permit: CanAwait): this.type /** * Throws exceptions if it cannot produce a T within the specified time. * This method should not be called directly. + * + * @throws InterruptedException if the wait call was interrupted */ @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): T diff --git a/src/library/scala/concurrent/BlockContext.scala b/src/library/scala/concurrent/BlockContext.scala index 640560a174..83333a9e94 100644 --- a/src/library/scala/concurrent/BlockContext.scala +++ b/src/library/scala/concurrent/BlockContext.scala @@ -8,9 +8,6 @@ package scala.concurrent -import java.lang.Thread -import scala.concurrent.util.Duration - /** * A context to be notified by `scala.concurrent.blocking` when * a thread is about to block. In effect this trait provides diff --git a/src/library/scala/concurrent/ExecutionContext.scala b/src/library/scala/concurrent/ExecutionContext.scala index 1be6050303..844ec14241 100644 --- a/src/library/scala/concurrent/ExecutionContext.scala +++ b/src/library/scala/concurrent/ExecutionContext.scala @@ -10,7 +10,6 @@ package scala.concurrent import java.util.concurrent.{ ExecutorService, Executor } -import scala.concurrent.util.Duration import scala.annotation.implicitNotFound import scala.util.Try diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index bc0b437a33..a5d9cdd5d1 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -16,7 +16,6 @@ import java.lang.{ Iterable => JIterable } import java.util.{ LinkedList => JLinkedList } import java.util.concurrent.atomic.{ AtomicReferenceFieldUpdater, AtomicInteger, AtomicBoolean } -import scala.concurrent.util.Duration import scala.util.control.NonFatal import scala.Option import scala.util.{Try, Success, Failure} diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 875a558887..c517a05a81 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -14,7 +14,6 @@ import java.util.concurrent.{ LinkedBlockingQueue, Callable, Executor, ExecutorS import java.util.Collection import scala.concurrent.forkjoin._ import scala.concurrent.{ BlockContext, ExecutionContext, Awaitable, CanAwait, ExecutionContextExecutor, ExecutionContextExecutorService } -import scala.concurrent.util.Duration import scala.util.control.NonFatal diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index b19bed004b..35aac974ec 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -65,29 +65,44 @@ private[concurrent] object Promise { protected final def tryAwait(atMost: Duration): Boolean = { @tailrec def awaitUnsafe(waitTimeNanos: Long): Boolean = { - if (value.isEmpty && waitTimeNanos > 0) { + if (!isCompleted && waitTimeNanos > 0) { val ms = NANOSECONDS.toMillis(waitTimeNanos) val ns = (waitTimeNanos % 1000000l).toInt // as per object.wait spec val start = System.nanoTime() - try { - synchronized { - if (!isCompleted) wait(ms, ns) // previously - this was a `while`, ending up in an infinite loop - } - } catch { - case e: InterruptedException => + synchronized { + if (!isCompleted) wait(ms, ns) // previously - this was a `while`, ending up in an infinite loop } awaitUnsafe(waitTimeNanos - (System.nanoTime() - start)) } else isCompleted } - awaitUnsafe(if (atMost.isFinite) atMost.toNanos else Long.MaxValue) + @tailrec + def awaitUnbounded(): Boolean = { + if (isCompleted) true + else { + synchronized { + if (!isCompleted) wait() + } + awaitUnbounded() + } + } + + if (atMost <= Duration.Zero) + isCompleted + else if (atMost eq Duration.Undefined) + throw new IllegalArgumentException("cannot wait for Undefined period") + else if (atMost == Duration.Inf) + awaitUnbounded() + else + awaitUnsafe(atMost.toNanos) } @throws(classOf[TimeoutException]) + @throws(classOf[InterruptedException]) def ready(atMost: Duration)(implicit permit: CanAwait): this.type = if (isCompleted || tryAwait(atMost)) this - else throw new TimeoutException("Futures timed out after [" + atMost.toMillis + "] milliseconds") + else throw new TimeoutException("Futures timed out after [" + atMost + "]") @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): T = diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala index a2ef42fac8..3681109653 100644 --- a/src/library/scala/concurrent/package.scala +++ b/src/library/scala/concurrent/package.scala @@ -74,8 +74,10 @@ package concurrent { * @param awaitable the `Awaitable` on which `ready` is to be called * @param atMost the maximum timeout for which to wait * @return the result of `awaitable.ready` which is defined to be the awaitable itself. + * @throws InterruptedException if the wait call was interrupted */ @throws(classOf[TimeoutException]) + @throws(classOf[InterruptedException]) def ready[T](awaitable: Awaitable[T], atMost: Duration): awaitable.type = blocking(awaitable.ready(atMost)(AwaitPermission)) @@ -87,6 +89,7 @@ package concurrent { * @param awaitable the `Awaitable` on which `result` is to be called * @param atMost the maximum timeout for which to wait * @return the result of `awaitable.result` + * @throws InterruptedException if the wait call was interrupted */ @throws(classOf[Exception]) def result[T](awaitable: Awaitable[T], atMost: Duration): T = diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index ffb5608fd2..a60f3c8a63 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -11,6 +11,7 @@ import scala.concurrent.{ import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } import scala.concurrent.util.Duration +import scala.reflect.{ classTag, ClassTag } trait TestBase { @@ -19,6 +20,14 @@ trait TestBase { body(() => sv put true) sv.take(2000) } + + def intercept[T <: Exception : ClassTag](code: => Unit): Unit = + try { + code + assert(false, "did not throw " + classTag[T]) + } catch { + case ex: Exception if classTag[T].runtimeClass isInstance ex => + } // def assert(cond: => Boolean) { // try { @@ -663,6 +672,29 @@ trait FutureProjections extends TestBase { case nsee: NoSuchElementException => done() } } + + def testAwaitPositiveDuration(): Unit = once { done => + val p = Promise[Int]() + val f = p.future + future { + intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) } + p.success(0) + Await.ready(f, Duration.Zero) + Await.ready(f, Duration(500, "ms")) + Await.ready(f, Duration.Inf) + done() + } onFailure { case x => throw x } + } + + def testAwaitNegativeDuration(): Unit = once { done => + val f = Promise().future + future { + intercept[TimeoutException] { Await.ready(f, Duration.Zero) } + intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) } + intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) } + done() + } onFailure { case x => throw x } + } testFailedFailureOnComplete() testFailedFailureOnSuccess() @@ -670,6 +702,8 @@ trait FutureProjections extends TestBase { testFailedSuccessOnFailure() testFailedFailureAwait() testFailedSuccessAwait() + testAwaitPositiveDuration() + testAwaitNegativeDuration() } -- cgit v1.2.3 From e3b0c7abbf637dacce7bcd7b69d5655820e8e714 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Tue, 31 Jul 2012 01:02:07 +0200 Subject: SI-6162 Adds @deprecatedInheritance/@deprecatedOverriding These annotations are meant to warn from inheriting a class or from overriding a member, due to the reasons given in `msg`. The naming and placement of the methods is in line with @deprecated and @deprecatedName. --- .../scala/tools/nsc/typechecker/RefChecks.scala | 11 +++++++++++ .../scala/tools/nsc/typechecker/Typers.scala | 9 +++++++++ src/library/scala/deprecatedInheritance.scala | 20 ++++++++++++++++++++ src/library/scala/deprecatedOverriding.scala | 19 +++++++++++++++++++ src/reflect/scala/reflect/internal/Definitions.scala | 2 ++ src/reflect/scala/reflect/internal/Symbols.scala | 12 ++++++++++++ test/files/neg/t6162-inheritance.check | 4 ++++ test/files/neg/t6162-inheritance.flags | 1 + test/files/neg/t6162-inheritance.scala | 4 ++++ test/files/neg/t6162-overriding.check | 4 ++++ test/files/neg/t6162-overriding.flags | 1 + test/files/neg/t6162-overriding.scala | 8 ++++++++ 12 files changed, 95 insertions(+) create mode 100644 src/library/scala/deprecatedInheritance.scala create mode 100644 src/library/scala/deprecatedOverriding.scala create mode 100644 test/files/neg/t6162-inheritance.check create mode 100644 test/files/neg/t6162-inheritance.flags create mode 100644 test/files/neg/t6162-inheritance.scala create mode 100644 test/files/neg/t6162-overriding.check create mode 100644 test/files/neg/t6162-overriding.flags create mode 100644 test/files/neg/t6162-overriding.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 166bb2d18c..919250c562 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -430,6 +430,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R overrideError("cannot override a macro") } else { checkOverrideTypes() + checkOverrideDeprecated() if (settings.warnNullaryOverride.value) { if (other.paramss.isEmpty && !member.paramss.isEmpty) { unit.warning(member.pos, "non-nullary method overrides nullary method") @@ -508,6 +509,16 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } } } + + def checkOverrideDeprecated() { + if (other.hasDeprecatedOverridingAnnotation) { + val msg = + member.toString + member.locationString + " overrides " + other.toString + other.locationString + + ", but overriding this member is deprecated" + + other.deprecatedOverridingMessage.map(": " + _).getOrElse(".") + unit.deprecationWarning(member.pos, msg) + } + } } val opc = new overridingPairs.Cursor(clazz) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9cf5d42e00..df97e451d1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1577,6 +1577,15 @@ trait Typers extends Modes with Adaptations with Tags { if (psym.isFinal) pending += ParentFinalInheritanceError(parent, psym) + if (psym.hasDeprecatedInheritanceAnnotation) { + val sym = selfType.typeSymbol + val msg = + sym.toString + sym.locationString + " inherits from " + psym.toString + psym.locationString + + ", but inheriting from that class is deprecated" + + psym.deprecatedInheritanceMessage.map(": " + _).getOrElse(".") + unit.deprecationWarning(sym.pos, msg) + } + if (psym.isSealed && !phase.erasedTypes) if (context.unit.source.file == psym.sourceFile) psym addChild context.owner diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala new file mode 100644 index 0000000000..c461f6737c --- /dev/null +++ b/src/library/scala/deprecatedInheritance.scala @@ -0,0 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2012, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +/** An annotation that designates that inheriting from a class is deprecated. + * + * This is usually done to warn about a non-final class being made final in a future version. + * Sub-classing such a class then generates a warning. + * + * @param message the message to print during compilation if the class was sub-classed + * @param since a string identifying the first version in which inheritance was deprecated + * @since 2.10 + */ +class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file diff --git a/src/library/scala/deprecatedOverriding.scala b/src/library/scala/deprecatedOverriding.scala new file mode 100644 index 0000000000..9048d5d32d --- /dev/null +++ b/src/library/scala/deprecatedOverriding.scala @@ -0,0 +1,19 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2012, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +/** An annotation that designates that overriding a member is deprecated. + * + * Overriding such a member in a sub-class then generates a warning. + * + * @param message the message to print during compilation if the member was overridden + * @param since a string identifying the first version in which overriding was deprecated + * @since 2.10 + */ +class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index c21ebfe997..556fcee64f 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -940,6 +940,8 @@ trait Definitions extends api.StandardDefinitions { lazy val CloneableAttr = requiredClass[scala.annotation.cloneable] lazy val DeprecatedAttr = requiredClass[scala.deprecated] lazy val DeprecatedNameAttr = requiredClass[scala.deprecatedName] + lazy val DeprecatedInheritanceAttr = requiredClass[scala.deprecatedInheritance] + lazy val DeprecatedOverridingAttr = requiredClass[scala.deprecatedOverriding] lazy val NativeAttr = requiredClass[scala.native] lazy val RemoteAttr = requiredClass[scala.remote] lazy val ScalaInlineClass = requiredClass[scala.inline] diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 3548657c04..e75079a6ff 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -697,6 +697,18 @@ trait Symbols extends api.Symbols { self: SymbolTable => def deprecationMessage = getAnnotation(DeprecatedAttr) flatMap (_ stringArg 0) def deprecationVersion = getAnnotation(DeprecatedAttr) flatMap (_ stringArg 1) def deprecatedParamName = getAnnotation(DeprecatedNameAttr) flatMap (_ symbolArg 0) + def hasDeprecatedInheritanceAnnotation + = hasAnnotation(DeprecatedInheritanceAttr) + def deprecatedInheritanceMessage + = getAnnotation(DeprecatedInheritanceAttr) flatMap (_ stringArg 0) + def deprecatedInheritanceVersion + = getAnnotation(DeprecatedInheritanceAttr) flatMap (_ stringArg 1) + def hasDeprecatedOverridingAnnotation + = hasAnnotation(DeprecatedOverridingAttr) + def deprecatedOverridingMessage + = getAnnotation(DeprecatedOverridingAttr) flatMap (_ stringArg 0) + def deprecatedOverridingVersion + = getAnnotation(DeprecatedOverridingAttr) flatMap (_ stringArg 1) // !!! when annotation arguments are not literal strings, but any sort of // assembly of strings, there is a fair chance they will turn up here not as diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check new file mode 100644 index 0000000000..69112d7f86 --- /dev/null +++ b/test/files/neg/t6162-inheritance.check @@ -0,0 +1,4 @@ +t6162-inheritance.scala:4: error: class SubFoo inherits from class Foo, but inheriting from that class is deprecated: `Foo` will be made final in a future version. +class SubFoo extends Foo + ^ +one error found \ No newline at end of file diff --git a/test/files/neg/t6162-inheritance.flags b/test/files/neg/t6162-inheritance.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-inheritance.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation \ No newline at end of file diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala new file mode 100644 index 0000000000..67bd4466c3 --- /dev/null +++ b/test/files/neg/t6162-inheritance.scala @@ -0,0 +1,4 @@ +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +class SubFoo extends Foo \ No newline at end of file diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check new file mode 100644 index 0000000000..14221ddc63 --- /dev/null +++ b/test/files/neg/t6162-overriding.check @@ -0,0 +1,4 @@ +t6162-overriding.scala:7: error: method bar in class SubBar overrides method bar in class Bar, but overriding this member is deprecated: `bar` will be made private in a future version. + override def bar = 43 + ^ +one error found diff --git a/test/files/neg/t6162-overriding.flags b/test/files/neg/t6162-overriding.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-overriding.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation \ No newline at end of file diff --git a/test/files/neg/t6162-overriding.scala b/test/files/neg/t6162-overriding.scala new file mode 100644 index 0000000000..4907dbb075 --- /dev/null +++ b/test/files/neg/t6162-overriding.scala @@ -0,0 +1,8 @@ +class Bar { + @deprecatedOverriding("`bar` will be made private in a future version.", "2.10.0") + def bar = 42 +} + +class SubBar extends Bar { + override def bar = 43 +} \ No newline at end of file -- cgit v1.2.3 From 028de5d78225d3eb4d41d87bdbe56b7631ef76d1 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 10 Sep 2012 23:25:40 +0200 Subject: Rescues @deprecated{Inheritance, Overriding} While they ought to be generalized to aribirary modifier changes before being offered in the standard library, the opportunity to use them in 2.10 is too important to pass up. So for now, they're private[scala]. En route: - made the error messages more concise - fix positioning of inheritance error - improve test coverage --- .../scala/tools/nsc/typechecker/RefChecks.scala | 6 ++---- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 +++------ src/library/scala/deprecatedInheritance.scala | 4 +++- src/library/scala/deprecatedOverriding.scala | 4 +++- test/files/neg/t6162-inheritance.check | 10 ++++++++-- test/files/neg/t6162-inheritance.scala | 17 ++++++++++++++++- test/files/neg/t6162-overriding.check | 7 +++++-- test/files/neg/t6162-overriding.scala | 11 ++++++++++- 8 files changed, 50 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 919250c562..b9ff04c9df 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -512,10 +512,8 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R def checkOverrideDeprecated() { if (other.hasDeprecatedOverridingAnnotation) { - val msg = - member.toString + member.locationString + " overrides " + other.toString + other.locationString + - ", but overriding this member is deprecated" + - other.deprecatedOverridingMessage.map(": " + _).getOrElse(".") + val suffix = other.deprecatedOverridingMessage map (": " + _) getOrElse "" + val msg = s"overriding ${other.fullLocationString} is deprecated$suffix" unit.deprecationWarning(member.pos, msg) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index df97e451d1..3913c4f815 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1578,12 +1578,9 @@ trait Typers extends Modes with Adaptations with Tags { pending += ParentFinalInheritanceError(parent, psym) if (psym.hasDeprecatedInheritanceAnnotation) { - val sym = selfType.typeSymbol - val msg = - sym.toString + sym.locationString + " inherits from " + psym.toString + psym.locationString + - ", but inheriting from that class is deprecated" + - psym.deprecatedInheritanceMessage.map(": " + _).getOrElse(".") - unit.deprecationWarning(sym.pos, msg) + val suffix = psym.deprecatedInheritanceMessage map (": " + _) getOrElse "" + val msg = s"inheritance from ${psym.fullLocationString} is deprecated$suffix" + unit.deprecationWarning(parent.pos, msg) } if (psym.isSealed && !phase.erasedTypes) diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala index c461f6737c..4dd847c7b2 100644 --- a/src/library/scala/deprecatedInheritance.scala +++ b/src/library/scala/deprecatedInheritance.scala @@ -16,5 +16,7 @@ package scala * @param message the message to print during compilation if the class was sub-classed * @param since a string identifying the first version in which inheritance was deprecated * @since 2.10 + * @see [[scala.deprecatedInheritance]] */ -class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file +private[scala] // for now, this needs to be generalized to communicate other modifier deltas +class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation diff --git a/src/library/scala/deprecatedOverriding.scala b/src/library/scala/deprecatedOverriding.scala index 9048d5d32d..566cb59431 100644 --- a/src/library/scala/deprecatedOverriding.scala +++ b/src/library/scala/deprecatedOverriding.scala @@ -15,5 +15,7 @@ package scala * @param message the message to print during compilation if the member was overridden * @param since a string identifying the first version in which overriding was deprecated * @since 2.10 + * @see [[scala.deprecatedInheritance]] */ -class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation \ No newline at end of file +private[scala] // for the same reasons as deprecatedInheritance +class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check index 69112d7f86..a7d3cc3238 100644 --- a/test/files/neg/t6162-inheritance.check +++ b/test/files/neg/t6162-inheritance.check @@ -1,4 +1,10 @@ -t6162-inheritance.scala:4: error: class SubFoo inherits from class Foo, but inheriting from that class is deprecated: `Foo` will be made final in a future version. +t6162-inheritance.scala:6: error: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. class SubFoo extends Foo + ^ +t6162-inheritance.scala:11: error: inheritance from trait T in package t6126 is deprecated +object SubT extends T + ^ +t6162-inheritance.scala:17: error: inheritance from trait S in package t6126 is deprecated + new S { ^ -one error found \ No newline at end of file +three errors found diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala index 67bd4466c3..7b47b9285a 100644 --- a/test/files/neg/t6162-inheritance.scala +++ b/test/files/neg/t6162-inheritance.scala @@ -1,4 +1,19 @@ +package scala.t6126 + @deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") class Foo -class SubFoo extends Foo \ No newline at end of file +class SubFoo extends Foo + +@deprecatedInheritance() +trait T + +object SubT extends T + +@deprecatedInheritance() +trait S + +object O { + new S { + } +} diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check index 14221ddc63..e774888d36 100644 --- a/test/files/neg/t6162-overriding.check +++ b/test/files/neg/t6162-overriding.check @@ -1,4 +1,7 @@ -t6162-overriding.scala:7: error: method bar in class SubBar overrides method bar in class Bar, but overriding this member is deprecated: `bar` will be made private in a future version. +t6162-overriding.scala:14: error: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. override def bar = 43 ^ -one error found +t6162-overriding.scala:15: error: overriding method baz in class Bar is deprecated + override def baz = 43 + ^ +two errors found diff --git a/test/files/neg/t6162-overriding.scala b/test/files/neg/t6162-overriding.scala index 4907dbb075..4cab0c2dee 100644 --- a/test/files/neg/t6162-overriding.scala +++ b/test/files/neg/t6162-overriding.scala @@ -1,8 +1,17 @@ +package scala.t6162 + class Bar { @deprecatedOverriding("`bar` will be made private in a future version.", "2.10.0") def bar = 42 + + @deprecatedOverriding() + def baz = 42 + + def baz(a: Any) = 0 } class SubBar extends Bar { override def bar = 43 -} \ No newline at end of file + override def baz = 43 + override def baz(a: Any) = 43 // okay +} -- cgit v1.2.3 From 674e0f80016dd70cd04c533daceeaa12161dae17 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 4 Sep 2012 11:01:44 -0400 Subject: Fix t6114 - ++ on JList wrapper modifies underlying collection. We solve this by overriding clone for JListWrapper to actually do a full clone. Note: This fix may need to be included other places, *but* we're not sure we've cloned the collection sensibly. I.e. is ArrayList a good default? --- .../scala/collection/convert/Wrappers.scala | 7 +++ test/files/run/t6114.scala | 61 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/files/run/t6114.scala (limited to 'test') diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 75707b69b0..7c97972c48 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -96,6 +96,9 @@ private[collection] trait Wrappers { def remove(i: Int) = underlying.remove(i) def clear() = underlying.clear() def result = this + // Note: Clone cannot just call underlying.clone because in Java, only specific collections + // expose clone methods. Generically, they're protected. + override def clone(): JListWrapper[A] = JListWrapper(new ju.ArrayList[A](underlying)) } class SetWrapper[A](underlying: Set[A]) extends ju.AbstractSet[A] { @@ -149,6 +152,10 @@ private[collection] trait Wrappers { override def clear() = underlying.clear() override def empty = JSetWrapper(new ju.HashSet[A]) + // Note: Clone cannot just call underlying.clone because in Java, only specific collections + // expose clone methods. Generically, they're protected. + override def clone() = + new JSetWrapper[A](new ju.LinkedHashSet[A](underlying)) } class MapWrapper[A, B](underlying: Map[A, B]) extends ju.AbstractMap[A, B] { self => diff --git a/test/files/run/t6114.scala b/test/files/run/t6114.scala new file mode 100644 index 0000000000..cb880ece00 --- /dev/null +++ b/test/files/run/t6114.scala @@ -0,0 +1,61 @@ +object Test extends App { + def testList = { + val list = new java.util.ArrayList[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + val raw = list.asScala + val cloned = raw.clone + list.add(1) + assert(raw != cloned) + } + def testSet = { + val set = new java.util.HashSet[Int] + set.add(1) + set.add(2) + set.add(3) + import scala.collection.JavaConverters._ + val next = set.asScala ++ Set(4,5,6) + assert(next != set.asScala) + + val raw = set.asScala + val cloned = raw.clone + set.add(4) + assert(raw != cloned) + } + def testMap = { + val map = new java.util.HashMap[Int,Int] + map.put(1,1) + map.put(2,2) + map.put(3,3) + import scala.collection.JavaConverters._ + val next = map.asScala ++ Map(4->4,5->5,6->6) + assert(next != map.asScala) + + val raw = map.asScala + val cloned = raw.clone + map.put(4,4) + assert(raw != cloned) + } + + def testCollection = { + val list: java.util.Collection[Int] = new java.util.ArrayDeque[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + // Note: Clone is hidden at this level, so no overriden cloning. + } + + testList + testSet + testMap + testCollection +} -- cgit v1.2.3 From fbdf71f50f8d25f940fbf24d0106d52a4857d305 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 11 Sep 2012 17:13:28 +0200 Subject: Disable test t2868 it keeps failing randomly, e.g. http://scala-webapps.epfl.ch/artifacts/e3b0c7abbf637dacce7bcd7b69d5655820e8e714/buildLog.txt --- test/files/pos/t2868.cmds | 3 --- test/files/pos/t2868/Jann.java | 5 ----- test/files/pos/t2868/Nest.java | 3 --- test/files/pos/t2868/pick_1.scala | 7 ------- test/files/pos/t2868/t2868_src_2.scala | 6 ------ test/flaky/pos/t2868.cmds | 3 +++ test/flaky/pos/t2868/Jann.java | 5 +++++ test/flaky/pos/t2868/Nest.java | 3 +++ test/flaky/pos/t2868/pick_1.scala | 7 +++++++ test/flaky/pos/t2868/t2868_src_2.scala | 6 ++++++ 10 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 test/files/pos/t2868.cmds delete mode 100644 test/files/pos/t2868/Jann.java delete mode 100644 test/files/pos/t2868/Nest.java delete mode 100644 test/files/pos/t2868/pick_1.scala delete mode 100644 test/files/pos/t2868/t2868_src_2.scala create mode 100644 test/flaky/pos/t2868.cmds create mode 100644 test/flaky/pos/t2868/Jann.java create mode 100644 test/flaky/pos/t2868/Nest.java create mode 100644 test/flaky/pos/t2868/pick_1.scala create mode 100644 test/flaky/pos/t2868/t2868_src_2.scala (limited to 'test') diff --git a/test/files/pos/t2868.cmds b/test/files/pos/t2868.cmds deleted file mode 100644 index ed8124a9e0..0000000000 --- a/test/files/pos/t2868.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Jann.java Nest.java -scalac pick_1.scala -scalac test_2.scala diff --git a/test/files/pos/t2868/Jann.java b/test/files/pos/t2868/Jann.java deleted file mode 100644 index f5b68de7b0..0000000000 --- a/test/files/pos/t2868/Jann.java +++ /dev/null @@ -1,5 +0,0 @@ -public @interface Jann { - public String str(); - public Nest inn(); - public int[] arr(); -} diff --git a/test/files/pos/t2868/Nest.java b/test/files/pos/t2868/Nest.java deleted file mode 100644 index 53652291ad..0000000000 --- a/test/files/pos/t2868/Nest.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface Nest { - public int value(); -} diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala deleted file mode 100644 index a211687432..0000000000 --- a/test/files/pos/t2868/pick_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -class ann(s: String) extends annotation.StaticAnnotation -class pick { - final val s = "bang!" - @ann("bang!") def foo = 1 - @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def bar = 2 - @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def baz = 3 -} diff --git a/test/files/pos/t2868/t2868_src_2.scala b/test/files/pos/t2868/t2868_src_2.scala deleted file mode 100644 index f11ef0fae2..0000000000 --- a/test/files/pos/t2868/t2868_src_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class test { - val l = (new pick).s - val u = (new pick).foo - val c = (new pick).bar - val k = (new pick).baz -} diff --git a/test/flaky/pos/t2868.cmds b/test/flaky/pos/t2868.cmds new file mode 100644 index 0000000000..ed8124a9e0 --- /dev/null +++ b/test/flaky/pos/t2868.cmds @@ -0,0 +1,3 @@ +javac Jann.java Nest.java +scalac pick_1.scala +scalac test_2.scala diff --git a/test/flaky/pos/t2868/Jann.java b/test/flaky/pos/t2868/Jann.java new file mode 100644 index 0000000000..f5b68de7b0 --- /dev/null +++ b/test/flaky/pos/t2868/Jann.java @@ -0,0 +1,5 @@ +public @interface Jann { + public String str(); + public Nest inn(); + public int[] arr(); +} diff --git a/test/flaky/pos/t2868/Nest.java b/test/flaky/pos/t2868/Nest.java new file mode 100644 index 0000000000..53652291ad --- /dev/null +++ b/test/flaky/pos/t2868/Nest.java @@ -0,0 +1,3 @@ +public @interface Nest { + public int value(); +} diff --git a/test/flaky/pos/t2868/pick_1.scala b/test/flaky/pos/t2868/pick_1.scala new file mode 100644 index 0000000000..a211687432 --- /dev/null +++ b/test/flaky/pos/t2868/pick_1.scala @@ -0,0 +1,7 @@ +class ann(s: String) extends annotation.StaticAnnotation +class pick { + final val s = "bang!" + @ann("bang!") def foo = 1 + @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def bar = 2 + @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def baz = 3 +} diff --git a/test/flaky/pos/t2868/t2868_src_2.scala b/test/flaky/pos/t2868/t2868_src_2.scala new file mode 100644 index 0000000000..f11ef0fae2 --- /dev/null +++ b/test/flaky/pos/t2868/t2868_src_2.scala @@ -0,0 +1,6 @@ +class test { + val l = (new pick).s + val u = (new pick).foo + val c = (new pick).bar + val k = (new pick).baz +} -- cgit v1.2.3 From ad6c261eafbe72e014d005d0452c8a628a07f123 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 11 Sep 2012 17:58:35 +0200 Subject: improve docs and Promise impl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scaladoc the exceptions thrown by Await.* and Awaitable.* - move intercept[Exception] into partest’s TestUtil object - improve Promise.tryAwait implementation following Viktor’s comments and make use of Deadline to avoid calling System.nanoTime too often --- src/library/scala/concurrent/Awaitable.scala | 22 +++++++++++++--- src/library/scala/concurrent/impl/Promise.scala | 30 ++++++++++------------ src/library/scala/concurrent/package.scala | 34 ++++++++++++++++--------- src/partest/scala/tools/partest/TestUtil.scala | 12 ++++++++- test/files/jvm/scala-concurrent-tck.scala | 9 +------ 5 files changed, 65 insertions(+), 42 deletions(-) (limited to 'test') diff --git a/src/library/scala/concurrent/Awaitable.scala b/src/library/scala/concurrent/Awaitable.scala index 2205dd9869..655115349a 100644 --- a/src/library/scala/concurrent/Awaitable.scala +++ b/src/library/scala/concurrent/Awaitable.scala @@ -16,20 +16,34 @@ import scala.concurrent.util.Duration trait Awaitable[+T] { /** - * Should throw [[scala.concurrent.TimeoutException]] if it times out + * Await the "resolved" state of this Awaitable. * This method should not be called directly. * - * @throws InterruptedException if the wait call was interrupted + * @param atMost + * maximum wait time, which may be negative (no waiting is done), + * [[Duration.Inf]] for unbounded waiting, or a finite positive + * duration + * @return the Awaitable itself + * @throws InterruptedException if the wait call was interrupted + * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready + * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]] */ @throws(classOf[TimeoutException]) @throws(classOf[InterruptedException]) def ready(atMost: Duration)(implicit permit: CanAwait): this.type /** - * Throws exceptions if it cannot produce a T within the specified time. + * Await and return the result of this Awaitable, which is either of type T or a thrown exception (any Throwable). * This method should not be called directly. * - * @throws InterruptedException if the wait call was interrupted + * @param atMost + * maximum wait time, which may be negative (no waiting is done), + * [[Duration.Inf]] for unbounded waiting, or a finite positive + * duration + * @return the value if the Awaitable was successful within the specific maximum wait time + * @throws InterruptedException if the wait call was interrupted + * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready + * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]] */ @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): T diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index 35aac974ec..f7ab85dc0c 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -12,7 +12,7 @@ package scala.concurrent.impl import java.util.concurrent.TimeUnit.NANOSECONDS import scala.concurrent.{ ExecutionContext, CanAwait, OnCompleteRunnable, TimeoutException, ExecutionException } -import scala.concurrent.util.Duration +import scala.concurrent.util.{ Duration, Deadline } import scala.annotation.tailrec import scala.util.control.NonFatal import scala.util.{ Try, Success, Failure } @@ -64,16 +64,14 @@ private[concurrent] object Promise { protected final def tryAwait(atMost: Duration): Boolean = { @tailrec - def awaitUnsafe(waitTimeNanos: Long): Boolean = { - if (!isCompleted && waitTimeNanos > 0) { - val ms = NANOSECONDS.toMillis(waitTimeNanos) - val ns = (waitTimeNanos % 1000000l).toInt // as per object.wait spec - val start = System.nanoTime() - synchronized { - if (!isCompleted) wait(ms, ns) // previously - this was a `while`, ending up in an infinite loop - } + def awaitUnsafe(deadline: Deadline, nextWait: Duration): Boolean = { + if (!isCompleted && nextWait > Duration.Zero) { + val ms = nextWait.toMillis + val ns = (nextWait.toNanos % 1000000l).toInt // as per object.wait spec + + synchronized { if (!isCompleted) wait(ms, ns) } - awaitUnsafe(waitTimeNanos - (System.nanoTime() - start)) + awaitUnsafe(deadline, deadline.timeLeft) } else isCompleted } @@ -81,21 +79,19 @@ private[concurrent] object Promise { def awaitUnbounded(): Boolean = { if (isCompleted) true else { - synchronized { - if (!isCompleted) wait() - } + synchronized { if (!isCompleted) wait() } awaitUnbounded() } } - if (atMost <= Duration.Zero) - isCompleted - else if (atMost eq Duration.Undefined) + if (atMost eq Duration.Undefined) throw new IllegalArgumentException("cannot wait for Undefined period") + else if (atMost <= Duration.Zero) + isCompleted else if (atMost == Duration.Inf) awaitUnbounded() else - awaitUnsafe(atMost.toNanos) + awaitUnsafe(atMost.fromNow, atMost) } @throws(classOf[TimeoutException]) diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala index 3681109653..1d06341d4d 100644 --- a/src/library/scala/concurrent/package.scala +++ b/src/library/scala/concurrent/package.scala @@ -67,14 +67,19 @@ package concurrent { */ object Await { /** + * Await the "resolved" state of this Awaitable. * Invokes ready() on the awaitable, properly wrapped by a call to `scala.concurrent.blocking`. - * ready() blocks until the awaitable has completed or the timeout expires. * - * Throws a TimeoutException if the timeout expires, as that is in the contract of `Awaitable.ready`. - * @param awaitable the `Awaitable` on which `ready` is to be called - * @param atMost the maximum timeout for which to wait - * @return the result of `awaitable.ready` which is defined to be the awaitable itself. - * @throws InterruptedException if the wait call was interrupted + * @param awaitable + * the `Awaitable` on which `ready` is to be called + * @param atMost + * maximum wait time, which may be negative (no waiting is done), + * [[Duration.Inf]] for unbounded waiting, or a finite positive + * duration + * @return the awaitable itself + * @throws InterruptedException if the wait call was interrupted + * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready + * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]] */ @throws(classOf[TimeoutException]) @throws(classOf[InterruptedException]) @@ -82,14 +87,19 @@ package concurrent { blocking(awaitable.ready(atMost)(AwaitPermission)) /** + * Await and return the result of this Awaitable, which is either of type T or a thrown exception (any Throwable). * Invokes result() on the awaitable, properly wrapped by a call to `scala.concurrent.blocking`. - * result() blocks until the awaitable has completed or the timeout expires. * - * Throws a TimeoutException if the timeout expires, or any exception thrown by `Awaitable.result`. - * @param awaitable the `Awaitable` on which `result` is to be called - * @param atMost the maximum timeout for which to wait - * @return the result of `awaitable.result` - * @throws InterruptedException if the wait call was interrupted + * @param awaitable + * the `Awaitable` on which `result` is to be called + * @param atMost + * maximum wait time, which may be negative (no waiting is done), + * [[Duration.Inf]] for unbounded waiting, or a finite positive + * duration + * @return the value if the Awaitable was successful within the specific maximum wait time + * @throws InterruptedException if the wait call was interrupted + * @throws TimeoutException if after waiting for the specified time this Awaitable is still not ready + * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]] */ @throws(classOf[Exception]) def result[T](awaitable: Awaitable[T], atMost: Duration): T = diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index b86a8e2c7f..146e6fc69f 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -1,5 +1,7 @@ package scala.tools.partest +import reflect.{ classTag, ClassTag } + trait TestUtil { /** Given function and block of code, evaluates code block, * calls function with nanoseconds elapsed, and returns block result. @@ -29,8 +31,16 @@ trait TestUtil { assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) } + + def intercept[T <: Exception : ClassTag](code: => Unit): Unit = + try { + code + assert(false, "did not throw " + classTag[T]) + } catch { + case ex: Exception if classTag[T].runtimeClass isInstance ex => + } } object TestUtil extends TestUtil { -} \ No newline at end of file +} diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index a60f3c8a63..0e76b711de 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -12,6 +12,7 @@ import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } import scala.concurrent.util.Duration import scala.reflect.{ classTag, ClassTag } +import scala.tools.partest.TestUtil.intercept trait TestBase { @@ -21,14 +22,6 @@ trait TestBase { sv.take(2000) } - def intercept[T <: Exception : ClassTag](code: => Unit): Unit = - try { - code - assert(false, "did not throw " + classTag[T]) - } catch { - case ex: Exception if classTag[T].runtimeClass isInstance ex => - } - // def assert(cond: => Boolean) { // try { // Predef.assert(cond) -- cgit v1.2.3 From 4a476e775fe7d3a126a42a5127c31e09b9117393 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 11 Sep 2012 20:37:43 +0200 Subject: two more minor cleanups to Duration - copy partest TestUtil.intercept change from PR 1279 branch - add comment on non-obvious match cases --- src/library/scala/concurrent/util/Duration.scala | 4 ++-- src/partest/scala/tools/partest/TestUtil.scala | 12 +++++++++++- test/files/jvm/duration-tck.scala | 7 +------ 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index 6d44c93bc2..8fd47630cb 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -306,8 +306,8 @@ object Duration { val Inf: Infinite = new Infinite { override def toString = "Duration.Inf" def compare(other: Duration) = other match { - case x if x eq Undefined => -1 - case x if x eq this => 0 + case x if x eq Undefined => -1 // Undefined != Undefined + case x if x eq this => 0 // `case Inf` will include null checks in the byte code case _ => 1 } def unary_- : Duration = MinusInf diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index b86a8e2c7f..146e6fc69f 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -1,5 +1,7 @@ package scala.tools.partest +import reflect.{ classTag, ClassTag } + trait TestUtil { /** Given function and block of code, evaluates code block, * calls function with nanoseconds elapsed, and returns block result. @@ -29,8 +31,16 @@ trait TestUtil { assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) } + + def intercept[T <: Exception : ClassTag](code: => Unit): Unit = + try { + code + assert(false, "did not throw " + classTag[T]) + } catch { + case ex: Exception if classTag[T].runtimeClass isInstance ex => + } } object TestUtil extends TestUtil { -} \ No newline at end of file +} diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index 87ffa196ca..0947e84004 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -6,6 +6,7 @@ import scala.concurrent.util._ import duration._ import scala.reflect._ import java.util.concurrent.TimeUnit._ +import scala.tools.partest.TestUtil.intercept object Test extends App { @@ -19,12 +20,6 @@ object Test extends App { } } - def intercept[T <: Exception : ClassTag](code: => Unit) = - try { code; assert(false, "did not throw expected exception " + classTag[T]) } - catch { - case ex: Exception => if (classTag[T].runtimeClass isAssignableFrom ex.getClass) () else throw ex - } - val zero = 0 seconds val one = 1 second val two = one + one -- cgit v1.2.3 From 1776337253744482b7116326413de5e260a5984e Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 11 Sep 2012 22:03:58 +0200 Subject: Avoid spurious warning for `def foo = x.foo`. Followup to SI-6276. --- .../scala/tools/nsc/typechecker/RefChecks.scala | 7 ++++++- test/files/neg/t6276.check | 16 +++++++++++----- test/files/neg/t6276.scala | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index f1f2794a95..d515934c58 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1208,11 +1208,16 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R // SI-6276 warn for `def foo = foo` or `val bar: X = bar`, which come up more frequently than you might think. def checkInfiniteLoop(valOrDef: ValOrDefDef) { + def callsSelf = valOrDef.rhs match { + case t @ (Ident(_) | Select(This(_), _)) => + t hasSymbolWhich (_.accessedOrSelf == valOrDef.symbol) + case _ => false + } val trivialInifiniteLoop = ( !valOrDef.isErroneous && !valOrDef.symbol.isValueParameter && valOrDef.symbol.paramss.isEmpty - && valOrDef.rhs.hasSymbolWhich(_.accessedOrSelf == valOrDef.symbol) + && callsSelf ) if (trivialInifiniteLoop) unit.warning(valOrDef.rhs.pos, s"${valOrDef.symbol.fullLocationString} does nothing other than call itself recursively") diff --git a/test/files/neg/t6276.check b/test/files/neg/t6276.check index 8bd92cf293..0b3dfa5531 100644 --- a/test/files/neg/t6276.check +++ b/test/files/neg/t6276.check @@ -1,13 +1,19 @@ -t6276.scala:4: error: method a does nothing other than call itself recursively +t6276.scala:4: error: method a in class C does nothing other than call itself recursively def a: Any = a // warn ^ -t6276.scala:5: error: value b does nothing other than call itself recursively +t6276.scala:5: error: value b in class C does nothing other than call itself recursively val b: Any = b // warn ^ -t6276.scala:10: error: method a does nothing other than call itself recursively +t6276.scala:7: error: method c in class C does nothing other than call itself recursively + def c: Any = this.c // warn + ^ +t6276.scala:8: error: method d in class C does nothing other than call itself recursively + def d: Any = C.this.d // warn + ^ +t6276.scala:13: error: method a does nothing other than call itself recursively def a: Any = a // warn ^ -t6276.scala:19: error: method a does nothing other than call itself recursively +t6276.scala:22: error: method a does nothing other than call itself recursively def a = a // warn ^ -four errors found +6 errors found diff --git a/test/files/neg/t6276.scala b/test/files/neg/t6276.scala index 8333618964..bd0a473f71 100644 --- a/test/files/neg/t6276.scala +++ b/test/files/neg/t6276.scala @@ -1,8 +1,11 @@ object Test { def foo(a: Int, b: Int, c: Int) { - new { + class C { def a: Any = a // warn val b: Any = b // warn + + def c: Any = this.c // warn + def d: Any = C.this.d // warn } def method { @@ -25,5 +28,17 @@ object Test { val b: Any = {println(""); b} def c(i: Int): Any = c(i - 0) } + + class D { + def other: D = null + def foo: Any = other.foo + } + + class E { + def foo: Any = 0 + class D extends E { + override def foo: Any = E.this.foo + } + } } } -- cgit v1.2.3 From a2c870569c124cbf090f7c85cea3269d95ff4170 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 8 Sep 2012 14:44:21 -0700 Subject: Fix for SI-6340, error message regression. --- .../scala/tools/nsc/typechecker/Namers.scala | 1 - test/files/neg/t6340.check | 10 ++++++++++ test/files/neg/t6340.scala | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t6340.check create mode 100644 test/files/neg/t6340.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 62f01b8afa..161df00220 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -496,7 +496,6 @@ trait Namers extends MethodSynthesis { // for Java code importing Scala objects if (!nme.isModuleName(from) || isValid(nme.stripModuleSuffix(from))) { typer.TyperErrorGen.NotAMemberError(tree, expr, from) - typer.infer.setError(tree) } } // Setting the position at the import means that if there is diff --git a/test/files/neg/t6340.check b/test/files/neg/t6340.check new file mode 100644 index 0000000000..f18b8c3f4b --- /dev/null +++ b/test/files/neg/t6340.check @@ -0,0 +1,10 @@ +t6340.scala:11: error: value D is not a member of object Foo + import Foo.{ A, B, C, D, E, X, Y, Z } + ^ +t6340.scala:16: error: not found: type D + val d = new D + ^ +t6340.scala:17: error: not found: type W + val w = new W + ^ +three errors found diff --git a/test/files/neg/t6340.scala b/test/files/neg/t6340.scala new file mode 100644 index 0000000000..8934d5c15d --- /dev/null +++ b/test/files/neg/t6340.scala @@ -0,0 +1,21 @@ +object Foo { + class A + class B + class C + class X + class Y + class Z +} + +object Test { + import Foo.{ A, B, C, D, E, X, Y, Z } + + val a = new A + val b = new B + val c = new C + val d = new D + val w = new W + val x = new X + val y = new Y + val z = new Z +} -- cgit v1.2.3 From 300803606ebca352955e945cf468a0c2bfc83b9c Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 12 Sep 2012 11:58:23 +0200 Subject: restrict Deadline to finite durations (would have to throw otherwise) --- src/library/scala/concurrent/util/Duration.scala | 19 ++++++++++--------- test/files/neg/deadline-inf-illegal.check | 15 +++++++++++++++ test/files/neg/deadline-inf-illegal.scala | 8 ++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 test/files/neg/deadline-inf-illegal.check create mode 100644 test/files/neg/deadline-inf-illegal.scala (limited to 'test') diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index d466d2978f..1a4bc1323d 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -28,26 +28,26 @@ import language.implicitConversions * does not take into account changes to the system clock (such as leap * seconds). */ -case class Deadline private (time: Duration) extends Ordered[Deadline] { +case class Deadline private (time: FiniteDuration) extends Ordered[Deadline] { /** * Return a deadline advanced (i.e. moved into the future) by the given duration. */ - def +(other: Duration): Deadline = copy(time = time + other) + def +(other: FiniteDuration): Deadline = copy(time = time + other) /** * Return a deadline moved backwards (i.e. towards the past) by the given duration. */ - def -(other: Duration): Deadline = copy(time = time - other) + def -(other: FiniteDuration): Deadline = copy(time = time - other) /** * Calculate time difference between this and the other deadline, where the result is directed (i.e. may be negative). */ - def -(other: Deadline): Duration = time - other.time + def -(other: Deadline): FiniteDuration = time - other.time /** * Calculate time difference between this duration and now; the result is negative if the deadline has passed. * * '''''Note that on some systems this operation is costly because it entails a system call.''''' * Check `System.nanoTime` for your platform. */ - def timeLeft: Duration = this - Deadline.now + def timeLeft: FiniteDuration = this - Deadline.now /** * Determine whether the deadline still lies in the future at the point where this method is called. * @@ -552,10 +552,6 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { * Return the larger of this and that duration as determined by the natural ordering. */ def max(other: Duration): Duration = if (this > other) this else other - /** - * Construct a [[Deadline]] from this duration by adding it to the current instant `Duration.now`. - */ - def fromNow: Deadline = Deadline.now + this // Java API @@ -655,6 +651,11 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio def toDays = unit.toDays(length) def toUnit(u: TimeUnit) = toNanos.toDouble / NANOSECONDS.convert(1, u) + /** + * Construct a [[Deadline]] from this duration by adding it to the current instant `Deadline.now`. + */ + def fromNow: Deadline = Deadline.now + this + private[this] def unitString = timeUnitName(unit) + ( if (length == 1) "" else "s" ) override def toString = "" + length + " " + unitString diff --git a/test/files/neg/deadline-inf-illegal.check b/test/files/neg/deadline-inf-illegal.check new file mode 100644 index 0000000000..2b9b25e48e --- /dev/null +++ b/test/files/neg/deadline-inf-illegal.check @@ -0,0 +1,15 @@ +deadline-inf-illegal.scala:5: error: value fromNow is not a member of scala.concurrent.util.Duration + d.fromNow + ^ +deadline-inf-illegal.scala:6: error: type mismatch; + found : scala.concurrent.util.Duration + required: scala.concurrent.util.FiniteDuration + Deadline.now + d + ^ +deadline-inf-illegal.scala:7: error: overloaded method value - with alternatives: + (other: scala.concurrent.util.Deadline)scala.concurrent.util.FiniteDuration + (other: scala.concurrent.util.FiniteDuration)scala.concurrent.util.Deadline + cannot be applied to (scala.concurrent.util.Duration) + Deadline.now - d + ^ +three errors found diff --git a/test/files/neg/deadline-inf-illegal.scala b/test/files/neg/deadline-inf-illegal.scala new file mode 100644 index 0000000000..161089bfee --- /dev/null +++ b/test/files/neg/deadline-inf-illegal.scala @@ -0,0 +1,8 @@ +import concurrent.util.{ Deadline, Duration } + +class T { + val d: Duration = Duration.Zero + d.fromNow + Deadline.now + d + Deadline.now - d +} -- cgit v1.2.3 From fdcda3313da5415b62bff9341081dd266ca76cb3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 11 Sep 2012 13:44:40 -0400 Subject: Fixes SI-6268. Review by @paulp and @lrytz. This reverts a refactoring from https://github.com/scala/scala/commit/963aabbeb4 MultiString settings would not properly write an unparse string that could be reparsed, leading to failures when forking scalac in ant. Specifically, if a setting was empty, it was getting added to the unparse string and causing scalac to fail. This at least reverts to previous behavior (also more correct for multiple values). Whatever we do here has to work with the @file style argument reading and can't place empty options on the command line. Also, This assumes there are tests around the behvior the REPL needs. Note: The test is not automated yet, so unfortunately, we need to improve ANT testing capabilities to prevent regressons --- .../scala/tools/nsc/settings/MutableSettings.scala | 2 +- test/ant/test-basic/build.xml | 33 ++++++++++++++++++++++ test/ant/test-basic/src/test-1.scala | 0 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/ant/test-basic/build.xml create mode 100644 test/ant/test-basic/src/test-1.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index 116eed0f31..2ff81ae603 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -536,7 +536,7 @@ class MutableSettings(val errorFn: String => Unit) } override def tryToSetColon(args: List[String]) = tryToSet(args) override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(',').toList) - def unparse: List[String] = name :: value + def unparse: List[String] = value map (name + ":" + _) withHelpSyntax(name + ":<" + arg + ">") } diff --git a/test/ant/test-basic/build.xml b/test/ant/test-basic/build.xml new file mode 100644 index 0000000000..acc210806f --- /dev/null +++ b/test/ant/test-basic/build.xml @@ -0,0 +1,33 @@ + + + + Super simple test for Scala + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/ant/test-basic/src/test-1.scala b/test/ant/test-basic/src/test-1.scala new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3 From 9568dc9d1a8e69812f4ec0b72a11a38edaa51f2a Mon Sep 17 00:00:00 2001 From: Paolo Giarrusso Date: Wed, 5 Sep 2012 02:53:26 +0200 Subject: SI-6306 Remove incorrect eta-expansion optimization in Uncurry Fix SI-6306 by removing the offending code. Moreover, clarify comment and add testcase. This pattern match only matches on testcases triggering SI-6306; the transformation it performs in that case is unsafe. The intended optimization is to undo eta-expansion of nullary functions, that is, transform `() => foo()` to `foo`. But that's only valid when `foo` is an instance of `Function0`, so the optimization is unsafe. Moreover, the pattern match will fail because at the end of typer that code has become `() => foo.apply()`, and `isExprSafeToInline(foo.apply)` always (correctly) fails the isExprSafeToInline test. The pattern match should thus be different - this code was dead even when it was introduced (45bcd02f6ba099277bedbf83ec2bda07435c7797), since it was not invoked either when building the compiler or when compiling function attempt2() in the included testcase. Thanks to all commenters on SI-6306 and https://github.com/scala/scala/pull/1255, in particular to Jason Zaugg for diagnosing the underlying fault and Lukas Rytz for understanding the goal of the code. --- .../scala/tools/nsc/transform/UnCurry.scala | 5 ---- src/reflect/scala/reflect/internal/TreeInfo.scala | 2 +- test/files/run/pure-args-byname-noinline.check | 12 ++++++++ test/files/run/pure-args-byname-noinline.scala | 33 ++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 test/files/run/pure-args-byname-noinline.check create mode 100644 test/files/run/pure-args-byname-noinline.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 181463657b..f961685dd4 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -212,11 +212,6 @@ abstract class UnCurry extends InfoTransform /** Undo eta expansion for parameterless and nullary methods */ def deEta(fun: Function): Tree = fun match { - case Function(List(), Apply(expr, List())) if treeInfo.isExprSafeToInline(expr) => - if (expr hasSymbolWhich (_.isLazy)) - fun - else - expr case Function(List(), expr) if isByNameRef(expr) => noApply += expr expr diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 3a930a195b..6ef4c3f660 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -67,7 +67,7 @@ abstract class TreeInfo { /** Is tree an expression which can be inlined without affecting program semantics? * - * Note that this is not called "isExprSafeToInline" since purity (lack of side-effects) + * Note that this is not called "isExprPure" since purity (lack of side-effects) * is not the litmus test. References to modules and lazy vals are side-effecting, * both because side-effecting code may be executed and because the first reference * takes a different code path than all to follow; but they are safe to inline diff --git a/test/files/run/pure-args-byname-noinline.check b/test/files/run/pure-args-byname-noinline.check new file mode 100644 index 0000000000..a39c61eb64 --- /dev/null +++ b/test/files/run/pure-args-byname-noinline.check @@ -0,0 +1,12 @@ +2 +2 +2 +2 +List(1) +List() + +1 +1 +1 +1 +1 diff --git a/test/files/run/pure-args-byname-noinline.scala b/test/files/run/pure-args-byname-noinline.scala new file mode 100644 index 0000000000..5c5c8a7eb6 --- /dev/null +++ b/test/files/run/pure-args-byname-noinline.scala @@ -0,0 +1,33 @@ +object Test { + //Were affected by SI-6306 + def f[A](a: =>A) = println(a.toString) + def f1[A <: AnyVal](a: =>A) = println(a.toString) + def f1a[A <: AnyVal](a: =>A) = println(a.##) + def f2[A <: AnyRef](a: =>A) = println(a.toString) + def f2a[A <: String](a: =>A) = println(a.toString) + //Works + def f3[A](a: =>Seq[A]) = println(a.toString) + + def foo() = println(2) + def client(f: () => Unit) = {f(); f()} + def attempt2() { + val bar: () => Unit = foo _ + //The code causing SI-6306 was supposed to optimize code like this: + client(() => bar ()) + //to: + client(bar) + } + def main(args: Array[String]) { + attempt2() + f3(Seq(1)) + f3(Seq()) + f("") + f((1).toString) + f((1).##) + f1((1).##) + f2((1).toString) + f2a((1).toString) + } +} + +// vim: set ts=8 sw=2 et: -- cgit v1.2.3 From 6fbb4ac42a3fa00689a6c3bbde2be273b7c36b2d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 12 Sep 2012 12:02:07 -0700 Subject: Fix for SI-6367, exponential time in inference. This pathology is not new - it can be witnessed in 2.9, where compiling the test case enclosed with this ticket with -Yinfer-debug will print a line with (pinky to lips) one million type parameters. 1048576 actually, aka 2^20. But in 2.9 we were somehow getting away with creating the list, presumably by not spending much time looking at it. Somewhere between there and M1, that changed. I cut it off at the knees - don't create a list of one million upper bound constraints when 1 will suffice. It would not be too surprising if this proves to be a boon for performance. --- src/reflect/scala/reflect/internal/Types.scala | 30 +++++++++++++---------- test/files/pos/t6367.scala | 34 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 test/files/pos/t6367.scala (limited to 'test') diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index df44cf234e..29f7b53154 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3935,13 +3935,15 @@ trait Types extends api.Types { self: SymbolTable => def avoidWiden: Boolean = avoidWidening def addLoBound(tp: Type, isNumericBound: Boolean = false) { - if (isNumericBound && isNumericValueType(tp)) { - if (numlo == NoType || isNumericSubType(numlo, tp)) - numlo = tp - else if (!isNumericSubType(tp, numlo)) - numlo = numericLoBound + if (!lobounds.contains(tp)) { + if (isNumericBound && isNumericValueType(tp)) { + if (numlo == NoType || isNumericSubType(numlo, tp)) + numlo = tp + else if (!isNumericSubType(tp, numlo)) + numlo = numericLoBound + } + else lobounds ::= tp } - else lobounds ::= tp } def checkWidening(tp: Type) { @@ -3953,14 +3955,16 @@ trait Types extends api.Types { self: SymbolTable => } def addHiBound(tp: Type, isNumericBound: Boolean = false) { - checkWidening(tp) - if (isNumericBound && isNumericValueType(tp)) { - if (numhi == NoType || isNumericSubType(tp, numhi)) - numhi = tp - else if (!isNumericSubType(numhi, tp)) - numhi = numericHiBound + if (!hibounds.contains(tp)) { + checkWidening(tp) + if (isNumericBound && isNumericValueType(tp)) { + if (numhi == NoType || isNumericSubType(tp, numhi)) + numhi = tp + else if (!isNumericSubType(numhi, tp)) + numhi = numericHiBound + } + else hibounds ::= tp } - else hibounds ::= tp } def isWithinBounds(tp: Type): Boolean = diff --git a/test/files/pos/t6367.scala b/test/files/pos/t6367.scala new file mode 100644 index 0000000000..1214be7418 --- /dev/null +++ b/test/files/pos/t6367.scala @@ -0,0 +1,34 @@ +package play.api.libs.json.util + +trait FunctionalCanBuild[M[_]]{ + def apply[A,B](ma:M[A], mb:M[B]):M[A ~ B] +} + +trait Variant[M[_]] + +trait Functor[M[_]] extends Variant[M]{ + def fmap[A,B](m:M[A], f: A => B): M[B] +} + +case class ~[A,B](_1:A,_2:B) + +class FunctionalBuilder[M[_]](canBuild:FunctionalCanBuild[M]){ + class CanBuild20[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20]( + m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19], + m2:M[A20] + ) { + + def ~[A21](m3:M[A21]) = new CanBuild21(canBuild(m1,m2),m3) + + def apply[B](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => B)(implicit fu:Functor[M]): M[B] = + fu.fmap[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20, B]( + canBuild(m1, m2), + { case a1 ~ a2 ~ a3 ~ a4 ~ a5 ~ a6 ~ a7 ~ a8 ~ a9 ~ a10 ~ a11 ~ a12 ~ a13 ~ a14 ~ a15 ~ a16 ~ a17 ~ a18 ~ a19 ~ a20 => + f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) } + ) + } + + class CanBuild21[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21](m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20], m2:M[A21]){ + } + +} -- cgit v1.2.3 From 7a44282d130937e0f6f6c8d19bea08f466a0d2e9 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 10 Sep 2012 07:37:40 -0700 Subject: Test case for a bug fixed in M7. --- test/files/pos/z1720.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/files/pos/z1720.scala (limited to 'test') diff --git a/test/files/pos/z1720.scala b/test/files/pos/z1720.scala new file mode 100644 index 0000000000..7394d428c1 --- /dev/null +++ b/test/files/pos/z1720.scala @@ -0,0 +1,16 @@ +package test + +class Thing { + def info: Info[this.type] = InfoRepository.getInfo(this) + def info2: Info[this.type] = { + def self: this.type = this + InfoRepository.getInfo(self) + } +} + +trait Info[T] +case class InfoImpl[T](thing: T) extends Info[T] + +object InfoRepository { + def getInfo(t: Thing): Info[t.type] = InfoImpl(t) +} -- cgit v1.2.3 From 1806830ec802feea0b89f1a71e0dc15c1507b965 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 11 Sep 2012 10:00:14 -0700 Subject: Pending test for SI-3943 --- test/pending/pos/t3943/Outer_1.java | 14 ++++++++++++++ test/pending/pos/t3943/test_2.scala | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/pending/pos/t3943/Outer_1.java create mode 100644 test/pending/pos/t3943/test_2.scala (limited to 'test') diff --git a/test/pending/pos/t3943/Outer_1.java b/test/pending/pos/t3943/Outer_1.java new file mode 100644 index 0000000000..56c8cc7f85 --- /dev/null +++ b/test/pending/pos/t3943/Outer_1.java @@ -0,0 +1,14 @@ +public class Outer_1 { + abstract class Inner { + abstract public void foo(E e); + } +} + +class Child extends Outer_1 { + // the implicit prefix for Inner is Outer instead of Outer + public Inner getInner() { + return new Inner() { + public void foo(String e) { System.out.println("meh "+e); } + }; + } +} diff --git a/test/pending/pos/t3943/test_2.scala b/test/pending/pos/t3943/test_2.scala new file mode 100644 index 0000000000..a19db8b226 --- /dev/null +++ b/test/pending/pos/t3943/test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + val x: Child = new Child + x.getInner.foo("meh") +// ^ +// error: type mismatch; +// found : java.lang.String("meh") +// required: E +} -- cgit v1.2.3 From f5e71796d5b964026f5723318d29be5b189b442e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 12 Sep 2012 16:54:49 -0700 Subject: Better error message for pattern arity errors. Because friends don't tell friends: "wrong number of arguments for " --- .../scala/tools/nsc/transform/Erasure.scala | 2 +- .../tools/nsc/transform/SpecializeTypes.scala | 4 ++-- .../tools/nsc/typechecker/ContextErrors.scala | 7 ++----- .../tools/nsc/typechecker/TypeDiagnostics.scala | 23 +++++++++++++++++++--- .../scala/tools/nsc/typechecker/Typers.scala | 4 ++-- test/files/neg/names-defaults-neg.check | 2 +- test/files/neg/wrong-args-for-none.check | 4 ++++ test/files/neg/wrong-args-for-none.scala | 6 ++++++ 8 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 test/files/neg/wrong-args-for-none.check create mode 100644 test/files/neg/wrong-args-for-none.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index ae1a2c7e8e..37e452dc6a 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -959,7 +959,7 @@ abstract class Erasure extends AddInterfaces case TypeApply(sel @ Select(qual, name), List(targ)) => if (qual.tpe != null && isPrimitiveValueClass(qual.tpe.typeSymbol) && targ.tpe != null && targ.tpe <:< AnyRefClass.tpe) unit.error(sel.pos, "isInstanceOf cannot test if value types are references.") - + def mkIsInstanceOf(q: () => Tree)(tp: Type): Tree = Apply( TypeApply( diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 5097ecc3fe..86cdc59303 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1474,13 +1474,13 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case Select(qual, name) => def transformSelect = { qual match { - case _: Super if illegalSpecializedInheritance(currentClass) => + case _: Super if illegalSpecializedInheritance(currentClass) => val pos = tree.pos debuglog(pos.source.file.name+":"+pos.line+": not specializing call to super inside illegal specialized inheritance class.") debuglog(pos.lineContent) tree case _ => - + debuglog("specializing Select %s [tree.tpe: %s]".format(symbol.defString, tree.tpe)) //log("!!! select " + tree + " -> " + symbol.info + " specTypeVars: " + specializedTypeVars(symbol.info)) diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index b7195b0349..49ace019b9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -470,9 +470,6 @@ trait ContextErrors { def NamedAndDefaultArgumentsNotSupportedForMacros(tree: Tree, fun: Tree) = NormalTypeError(tree, "macros application do not support named and/or default arguments") - def WrongNumberOfArgsError(tree: Tree, fun: Tree) = - NormalTypeError(tree, "wrong number of arguments for "+ treeSymTypeMsg(fun)) - def TooManyArgsNamesDefaultsError(tree: Tree, fun: Tree) = NormalTypeError(tree, "too many arguments for "+treeSymTypeMsg(fun)) @@ -512,8 +509,8 @@ trait ContextErrors { def TooManyArgsPatternError(fun: Tree) = NormalTypeError(fun, "too many arguments for unapply pattern, maximum = "+definitions.MaxTupleArity) - def WrongNumberArgsPatternError(tree: Tree, fun: Tree) = - NormalTypeError(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) + def WrongNumberOfArgsError(tree: Tree, fun: Tree) = + NormalTypeError(tree, "wrong number of arguments for "+ treeSymTypeMsg(fun)) def ApplyWithoutArgsError(tree: Tree, fun: Tree) = NormalTypeError(tree, fun.tpe+" does not take parameters") diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index f8a5c401df..e5c0f5767c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -59,6 +59,19 @@ trait TypeDiagnostics { * the map, the addendum should also be printed. */ private var addendums = perRunCaches.newMap[Position, () => String]() + private var isTyperInPattern = false + + /** Devising new ways of communicating error info out of + * desperation to work on error messages. This is used + * by typedPattern to wrap its business so we can generate + * a sensible error message when things go south. + */ + def typingInPattern[T](body: => T): T = { + val saved = isTyperInPattern + isTyperInPattern = true + try body + finally isTyperInPattern = saved + } def setAddendum(pos: Position, msg: () => String) = if (pos != NoPosition) @@ -138,13 +151,17 @@ trait TypeDiagnostics { def hasParams = tree.tpe.paramSectionCount > 0 def preResultString = if (hasParams) ": " else " of type " - def nullMessage = "expression of type " + tree.tpe - def overloadedMessage = "overloaded method " + sym + " with alternatives:\n" + alternativesString(tree) + def patternMessage = "pattern " + tree.tpe.finalResultType + valueParamsString(tree.tpe) + def exprMessage = "expression of type " + tree.tpe + def overloadedMessage = s"overloaded method $sym with alternatives:\n" + alternativesString(tree) def moduleMessage = "" + sym def defaultMessage = moduleMessage + preResultString + tree.tpe def applyMessage = defaultMessage + tree.symbol.locationString - if (sym == null) nullMessage + if ((sym eq null) || (sym eq NoSymbol)) { + if (isTyperInPattern) patternMessage + else exprMessage + } else if (sym.isOverloaded) overloadedMessage else if (sym.isModule) moduleMessage else if (sym.name == nme.apply) applyMessage diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d90141b732..73ccdeec2c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3237,7 +3237,7 @@ trait Typers extends Modes with Adaptations with Tags { val nbSubPats = args.length val (formals, formalsExpanded) = extractorFormalTypes(resTp, nbSubPats, fun1.symbol) - if (formals == null) duplErrorTree(WrongNumberArgsPatternError(tree, fun)) + if (formals == null) duplErrorTree(WrongNumberOfArgsError(tree, fun)) else { val args1 = typedArgs(args, mode, formals, formalsExpanded) // This used to be the following (failing) assert: @@ -5452,7 +5452,7 @@ trait Typers extends Modes with Adaptations with Tags { // as a compromise, context.enrichmentEnabled tells adaptToMember to go ahead and enrich, // but arbitrary conversions (in adapt) are disabled // TODO: can we achieve the pattern matching bit of the string interpolation SIP without this? - context.withImplicitsDisabledAllowEnrichment(typed(tree, PATTERNmode, pt)) + typingInPattern(context.withImplicitsDisabledAllowEnrichment(typed(tree, PATTERNmode, pt))) } /** Types a (fully parameterized) type tree */ diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 2809350855..f3c45a6aa0 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -76,7 +76,7 @@ and method f in object t8 of type (a: Int, b: Object)String match argument types (a: Int,b: String) and expected result type Any println(t8.f(a = 0, b = "1")) // ambigous reference ^ -names-defaults-neg.scala:69: error: wrong number of arguments for : (x: Int, y: String)A1 +names-defaults-neg.scala:69: error: wrong number of arguments for pattern A1(x: Int,y: String) A1() match { case A1(_) => () } ^ names-defaults-neg.scala:76: error: no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])T[T[List[T[X forSome { type X }]]]] exist so that it can be applied to arguments (List[Int]) diff --git a/test/files/neg/wrong-args-for-none.check b/test/files/neg/wrong-args-for-none.check new file mode 100644 index 0000000000..d3b2d572ab --- /dev/null +++ b/test/files/neg/wrong-args-for-none.check @@ -0,0 +1,4 @@ +wrong-args-for-none.scala:5: error: wrong number of arguments for pattern Test.Foo(x: Int,y: Int) + def f(x: Any) = x match { case Bar(Foo(5)) => } + ^ +one error found diff --git a/test/files/neg/wrong-args-for-none.scala b/test/files/neg/wrong-args-for-none.scala new file mode 100644 index 0000000000..1caa4782a3 --- /dev/null +++ b/test/files/neg/wrong-args-for-none.scala @@ -0,0 +1,6 @@ +object Test { + case class Foo(x: Int, y: Int) + case class Bar(x: AnyRef) + + def f(x: Any) = x match { case Bar(Foo(5)) => } +} -- cgit v1.2.3 From 7861ed6886ecf827907a6b48f0628395f199f49b Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 12 Sep 2012 10:46:45 -0400 Subject: Fixes SI-6259. Unable to use typeOf in super call of top-level object. This works around the issue of the inability to use classOf for top-level object classes by inventing a new anonymous class and instantiating it just to grab its class. Since the class is a nested type of the top-level object it'll be in the same classloader unless some kind of evil behavior is afoot. This patch should be undone if ever SI-2453 ever gets fixed, or we wind up with a direct way to grab the class of an object. --- src/compiler/scala/reflect/reify/package.scala | 20 +++++- test/files/pos/t6259.scala | 47 ++++++++++++++ .../run/toolbox_typecheck_macrosdisabled.check | 73 ++++++++++++---------- .../run/toolbox_typecheck_macrosdisabled.scala | 6 +- .../run/toolbox_typecheck_macrosdisabled2.check | 73 ++++++++++++---------- .../run/toolbox_typecheck_macrosdisabled2.scala | 4 ++ 6 files changed, 156 insertions(+), 67 deletions(-) create mode 100644 test/files/pos/t6259.scala (limited to 'test') diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index a253effc1c..fab5699da6 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -26,7 +26,14 @@ package object reify { private[reify] def mkDefaultMirrorRef(global: Global)(universe: global.Tree, typer0: global.analyzer.Typer): global.Tree = { import global._ import definitions._ - val enclosingErasure = reifyEnclosingRuntimeClass(global)(typer0) + val enclosingErasure = { + val rClassTree = reifyEnclosingRuntimeClass(global)(typer0) + // HACK around SI-6259 + // If we're in the constructor of an object or others don't have easy access to `this`, we have no good way to grab + // the class of that object. Instead, we construct an anonymous class and grab his class file, assuming + // this is enough to get the correct class loadeer for the class we *want* a mirror for, the object itself. + rClassTree orElse Apply(Select(treeBuilder.makeAnonymousNew(Nil), sn.GetClass), Nil) + } // JavaUniverse is defined in scala-reflect.jar, so we must be very careful in case someone reifies stuff having only scala-library.jar on the classpath val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.toTypeConstructor if (isJavaUniverse && !enclosingErasure.isEmpty) Apply(Select(universe, nme.runtimeMirror), List(Select(enclosingErasure, sn.GetClassLoader))) @@ -61,6 +68,8 @@ package object reify { } } + // Note: If current context is inside the constructor of an object or otherwise not inside + // a class/object body, this will return an EmptyTree. def reifyEnclosingRuntimeClass(global: Global)(typer0: global.analyzer.Typer): global.Tree = { import global._ import definitions._ @@ -68,8 +77,15 @@ package object reify { if (isThisInScope) { val enclosingClasses = typer0.context.enclosingContextChain map (_.tree) collect { case classDef: ClassDef => classDef } val classInScope = enclosingClasses.headOption getOrElse EmptyTree + def isUnsafeToUseThis = { + val isInsideConstructorSuper = typer0.context.enclosingContextChain exists (_.inSelfSuperCall) + // Note: It's ok to check for any object here, because if we were in an enclosing class, we'd already have returned its classOf + val isInsideObject = typer0.context.enclosingContextChain map (_.tree) exists { case _: ModuleDef => true; case _ => false } + isInsideConstructorSuper && isInsideObject + } if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.toTypeConstructor, concrete = true) - else Select(This(tpnme.EMPTY), sn.GetClass) + else if(!isUnsafeToUseThis) Select(This(tpnme.EMPTY), sn.GetClass) + else EmptyTree } else EmptyTree } } diff --git a/test/files/pos/t6259.scala b/test/files/pos/t6259.scala new file mode 100644 index 0000000000..43361c417e --- /dev/null +++ b/test/files/pos/t6259.scala @@ -0,0 +1,47 @@ +package t6259 + +import scala.reflect.runtime.universe._ + +class A[X](implicit val tt: TypeTag[X]) {} +object B extends A[String] + +object C { + object D extends A[String] +} + +trait E { + object F extends A[String] +} + +class G { + object H extends A[String] +} + +object Test { + val x = { + object InVal extends A[String] + 5 + } + +} + +// Note: Both of these fail right now. + +trait NeedsEarly { + val x: AnyRef +} + +object Early extends { + // Drops to this.getClass and is not ok... + val x = { object EarlyOk extends A[String]; EarlyOk } +} with NeedsEarly + + +class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X] + +object DoubleOk extends DoubleTrouble[String]({ + // Drops to this.getClass and is an issue + object InnerTrouble extends A[String]; + InnerTrouble +}) + diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index 9cf101c69d..4d253f31fc 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -1,32 +1,41 @@ -{ - val $u: ru.type = ru; - val $m: $u.Mirror = ru.rootMirror; - $u.Expr.apply[Int(2)]($m, { - final class $treecreator1 extends TreeCreator { - def (): $treecreator1 = { - $treecreator1.super.(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Literal.apply($u.Constant.apply(2)) - } - }; - new $treecreator1() - })($u.TypeTag.apply[Int(2)]($m, { - final class $typecreator2 extends TypeCreator { - def (): $typecreator2 = { - $typecreator2.super.(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.ConstantType.apply($u.Constant.apply(2)) - } - }; - new $typecreator2() - })) -} -ru.reify[Int](2) +{ + val $u: ru.type = ru; + val $m: $u.Mirror = ru.runtimeMirror({ + final class $anon extends scala.AnyRef { + def (): anonymous class $anon = { + $anon.super.(); + () + }; + () + }; + new $anon() +}.getClass().getClassLoader()); + $u.Expr.apply[Int(2)]($m, { + final class $treecreator1 extends TreeCreator { + def (): $treecreator1 = { + $treecreator1.super.(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.Literal.apply($u.Constant.apply(2)) + } + }; + new $treecreator1() + })($u.TypeTag.apply[Int(2)]($m, { + final class $typecreator2 extends TypeCreator { + def (): $typecreator2 = { + $typecreator2.super.(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.ConstantType.apply($u.Constant.apply(2)) + } + }; + new $typecreator2() + })) +} +ru.reify[Int](2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index bcbd637e02..01a418d42e 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -3,6 +3,10 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox +// Note: If you're looking at this test and you don't know why, you may +// have accidentally changed the way type tags reify. If so, validate +// that your changes are accurate and update the check file. + object Test extends App { val toolbox = cm.mkToolBox() val rupkg = cm.staticModule("scala.reflect.runtime.package") @@ -17,4 +21,4 @@ object Test extends App { val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) -} \ No newline at end of file +} diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index d344e33180..149c3def12 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -1,32 +1,41 @@ -{ - val $u: ru.type = ru; - val $m: $u.Mirror = ru.rootMirror; - $u.Expr.apply[Array[Int]]($m, { - final class $treecreator1 extends TreeCreator { - def (): $treecreator1 = { - $treecreator1.super.(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) - } - }; - new $treecreator1() - })($u.TypeTag.apply[Array[Int]]($m, { - final class $typecreator2 extends TypeCreator { - def (): $typecreator2 = { - $typecreator2.super.(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) - } - }; - new $typecreator2() - })) -} -ru.reify[Array[Int]](scala.Array.apply(2)) +{ + val $u: ru.type = ru; + val $m: $u.Mirror = ru.runtimeMirror({ + final class $anon extends scala.AnyRef { + def (): anonymous class $anon = { + $anon.super.(); + () + }; + () + }; + new $anon() +}.getClass().getClassLoader()); + $u.Expr.apply[Array[Int]]($m, { + final class $treecreator1 extends TreeCreator { + def (): $treecreator1 = { + $treecreator1.super.(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + } + }; + new $treecreator1() + })($u.TypeTag.apply[Array[Int]]($m, { + final class $typecreator2 extends TypeCreator { + def (): $typecreator2 = { + $typecreator2.super.(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) + } + }; + new $typecreator2() + })) +} +ru.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 51493ffc1c..462dc9fa91 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -3,6 +3,10 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox +// Note: If you're looking at this test and you don't know why, you may +// have accidentally changed the way type tags reify. If so, validate +// that your changes are accurate and update the check file. + object Test extends App { val toolbox = cm.mkToolBox() val rupkg = cm.staticModule("scala.reflect.runtime.package") -- cgit v1.2.3 From 41dfb1612126c3b5763da25f4c3bdd73d605f12b Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 13 Sep 2012 23:53:24 +0200 Subject: SI-6359 Deep prohibition of templates in value class This seems to have been the intent of 95d532 / SI-5882. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 +++++++++-------- test/files/neg/t6359.check | 7 +++++++ test/files/neg/t6359.scala | 8 ++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 test/files/neg/t6359.check create mode 100644 test/files/neg/t6359.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d90141b732..e96f2f75c7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1405,14 +1405,15 @@ trait Typers extends Modes with Adaptations with Tags { unit.error(clazz.pos, "value class needs to have exactly one public val parameter") } } - body foreach { - case md: ModuleDef => - unit.error(md.pos, "value class may not have nested module definitions") - case cd: ClassDef => - unit.error(cd.pos, "value class may not have nested class definitions") - case md: DefDef if md.symbol.isConstructor && !md.symbol.isPrimaryConstructor => - unit.error(md.pos, "value class may not have secondary constructors") - case _ => + + def valueClassMayNotHave(at: Tree, what: String) = unit.error(at.pos, s"value class may not have $what") + body.foreach { + case dd: DefDef if dd.symbol.isAuxiliaryConstructor => valueClassMayNotHave(dd, "secondary constructors") + case t => t.foreach { + case md: ModuleDef => valueClassMayNotHave(md, "nested module definitions") + case cd: ClassDef => valueClassMayNotHave(cd, "nested class definitions") + case _ => + } } for (tparam <- clazz.typeParams) if (tparam hasAnnotation definitions.SpecializedClass) diff --git a/test/files/neg/t6359.check b/test/files/neg/t6359.check new file mode 100644 index 0000000000..2aa1ac5035 --- /dev/null +++ b/test/files/neg/t6359.check @@ -0,0 +1,7 @@ +t6359.scala:3: error: value class may not have nested module definitions + object X + ^ +t6359.scala:4: error: value class may not have nested class definitions + class Y + ^ +two errors found diff --git a/test/files/neg/t6359.scala b/test/files/neg/t6359.scala new file mode 100644 index 0000000000..96550fd906 --- /dev/null +++ b/test/files/neg/t6359.scala @@ -0,0 +1,8 @@ +class M(val t: Int) extends AnyVal { + def lazyString = { + object X + class Y + + () => {X; new Y} + } +} -- cgit v1.2.3 From 00d7cd2d5300524aeb885d8d51b2123aa0b44f6e Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 10 Sep 2012 20:00:22 +0200 Subject: improvements for reification of free symbols 1) Free symbols no longer carry signatures in their constructors. Previously to reify a free symbol (i.e. to generate a ValDef that creates it) one had to reify sym.info first. However reification of sym.info might lead to unexpected side effects, including stack overflows, if reification of sym.info recursively required reifying sym itself. Now it's not a problem. First we reify a "header" of a free symbol by emitting something like: val free$Foo1 = build.newFreeTerm("Foo", Foo.this, NoFlags)` Afterwards, when doing code generation for the reification symbol table, we populate free symbols by inserting calls to `build.setTypeSignature($sym.info)` This techniques transforms recursion into memoized iteration, because even if reifying sym.info indirectly requires reification of sym itself, we remember that we already reified sym and simply return things like Ident(free$Foo1). 2) Unfortunately I haven't been able to get rid of recursion completely. Since some symbols (e.g. local classes) aren't pickled, we need to recreate them during reification (this is necessary e.g. to reify RefinedTypes). Reifier uses a special function, named `reifySymDef`, for that purpose. Here's an example of how it works: val symdef$_1 = build.newNestedSymbol(free$U1, newTypeName("_"), NoPosition, DEFERRED | PARAM, false); `reifySymDef` expands into a call to `newNestedSymbol`, which requires an owner This essentially turns `reifySymDef` into a recursion of `reifySymDef` calls, so that the entire owner chain get reified. This is an implementation strategy that was employed in the first revision of the reifier written by Martin, and personally I have no clue whether it's really necessary to reify the parents. I leave this as a future work. 3) When working with free symbols, it's necessary to attach free symbols to their reification. This is required in obscure nested reification scenarios, when a symbol that was free for an inner reifee is no longer free for an outer reifee. In that case we need to remove that free symbol from the symbol table of the inner reification. Back then we didn't have tree attachments, so I had to introduce a phantom "value" parameter for `newFreeType` to keep track of the original symbols for free types. Now when we have attachments, this is no longer necessary and allowed me to clean up the code. --- .../scala/reflect/reify/codegen/GenSymbols.scala | 60 +++++++++++++--------- .../scala/reflect/reify/codegen/GenTrees.scala | 2 +- .../scala/reflect/reify/utils/Extractors.scala | 16 +----- .../scala/reflect/reify/utils/StdAttachments.scala | 10 +++- .../scala/reflect/reify/utils/SymbolTables.scala | 58 +++++++++------------ src/library/scala/reflect/base/Base.scala | 8 +-- src/library/scala/reflect/base/BuildUtils.scala | 10 +--- .../scala/reflect/internal/BuildUtils.scala | 8 +-- src/reflect/scala/reflect/internal/Importers.scala | 4 +- src/reflect/scala/reflect/internal/Symbols.scala | 12 ++--- .../reflect/runtime/SynchronizedSymbols.scala | 8 +-- test/files/run/existentials3-new.check | 16 +++--- test/files/run/existentials3-new.scala | 16 +++--- .../Impls_Macros_1.scala | 3 +- .../Impls_Macros_1.scala | 3 +- test/files/run/t1195-new.scala | 2 +- .../run/toolbox_typecheck_macrosdisabled.scala | 3 +- .../run/toolbox_typecheck_macrosdisabled2.scala | 3 +- 18 files changed, 117 insertions(+), 125 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala index 5a474b11fb..be138c7bfa 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala @@ -90,48 +90,60 @@ trait GenSymbols { } } else { // todo. make sure that free methods and free local defs work correctly - if (sym.isTerm) reifyFreeTerm(sym, Ident(sym)) - else reifyFreeType(sym, Ident(sym)) + if (sym.isExistential) reifySymDef(sym) + else if (sym.isTerm) reifyFreeTerm(Ident(sym)) + else reifyFreeType(Ident(sym)) } } - def reifyFreeTerm(sym: Symbol, value: Tree): Tree = - reifyIntoSymtab(sym) { + def reifyFreeTerm(binding: Tree): Tree = + reifyIntoSymtab(binding.symbol) { sym => if (reifyDebug) println("Free term" + (if (sym.isCapturedVariable) " (captured)" else "") + ": " + sym + "(" + sym.accurateKindString + ")") - var name = newTermName(nme.REIFY_FREE_PREFIX + sym.name) - if (sym.isType) name = name.append(nme.REIFY_FREE_THIS_SUFFIX) + val name = newTermName(nme.REIFY_FREE_PREFIX + sym.name + (if (sym.isType) nme.REIFY_FREE_THIS_SUFFIX else "")) if (sym.isCapturedVariable) { - assert(value.isInstanceOf[Ident], showRaw(value)) - val capturedTpe = capturedVariableType(sym) - val capturedValue = referenceCapturedVariable(sym) - (name, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), reify(capturedTpe), capturedValue, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) + assert(binding.isInstanceOf[Ident], showRaw(binding)) + val capturedBinding = referenceCapturedVariable(sym) + Reification(name, capturedBinding, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), capturedBinding, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) } else { - (name, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), reify(sym.tpe), value, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) + Reification(name, binding, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), binding, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) } } - def reifyFreeType(sym: Symbol, value: Tree): Tree = - reifyIntoSymtab(sym) { + def reifyFreeType(binding: Tree): Tree = + reifyIntoSymtab(binding.symbol) { sym => if (reifyDebug) println("Free type: %s (%s)".format(sym, sym.accurateKindString)) - var name = newTermName(nme.REIFY_FREE_PREFIX + sym.name) - val phantomTypeTag = Apply(TypeApply(Select(Ident(nme.UNIVERSE_SHORT), nme.TypeTag), List(value)), List(Literal(Constant(null)), Literal(Constant(null)))) - (name, mirrorBuildCall(nme.newFreeType, reify(sym.name.toString), reify(sym.info), phantomTypeTag, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) + val name = newTermName(nme.REIFY_FREE_PREFIX + sym.name) + Reification(name, binding, mirrorBuildCall(nme.newFreeType, reify(sym.name.toString), mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) } def reifySymDef(sym: Symbol): Tree = - reifyIntoSymtab(sym) { + reifyIntoSymtab(sym) { sym => if (reifyDebug) println("Sym def: %s (%s)".format(sym, sym.accurateKindString)) - assert(!sym.isLocatable, sym) // if this assertion fires, then tough type reification needs to be rethought - sym.owner.ownersIterator find (!_.isLocatable) foreach reifySymDef - var name = newTermName(nme.REIFY_SYMDEF_PREFIX + sym.name) - (name, mirrorBuildCall(nme.newNestedSymbol, reify(sym.owner), reify(sym.name), reify(sym.pos), mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(sym.isClass))) + val name = newTermName(nme.REIFY_SYMDEF_PREFIX + sym.name) + def reifiedOwner = if (sym.owner.isLocatable) reify(sym.owner) else reifySymDef(sym.owner) + Reification(name, Ident(sym), mirrorBuildCall(nme.newNestedSymbol, reifiedOwner, reify(sym.name), reify(sym.pos), mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(sym.isClass))) } - private def reifyIntoSymtab(sym: Symbol)(reificode: => (TermName, Tree)): Tree ={ + case class Reification(name: Name, binding: Tree, tree: Tree) + + private def reifyIntoSymtab(sym: Symbol)(reificode: Symbol => Reification): Tree = { def fromSymtab = symtab symRef sym if (fromSymtab == EmptyTree) { - val reification = reificode - state.symtab += (sym, reification._1, reification._2) + // reification is lazy, so that we can carefully choose where to evaluate it + // and we choose this place to be exactly here: + // + // reasons: + // 1) reification happens at maximum once per symbol to prevent repeated reifications + // 2) reification happens before putting the symbol itself into the symbol table to ensure correct initialization order: + // for example, if reification of symbol A refers to reification of symbol B + // (this might happen when we're doing `reifySymDef`, which expands into `newNestedSymbol`, which needs `sym.owner`) + // then we have to put reification-B into the symbol table before reification-A + // so that subsequent code generation that traverses the symbol table in the first-added first-codegenned order + // produces valid Scala code (with vals in a block depending only on lexically preceding vals) + val reification = reificode(sym) + import reification.{name, binding} + val tree = reification.tree addAttachment ReifyBindingAttachment(binding) + state.symtab += (sym, name, tree) } fromSymtab } diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala index f48df8df65..bdcc7383b0 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala @@ -124,7 +124,7 @@ trait GenTrees { val sym = tree.symbol if (reifyDebug) println("This for %s, reified as freeVar".format(sym)) if (reifyDebug) println("Free: " + sym) - mirrorBuildCall(nme.Ident, reifyFreeTerm(sym, This(sym))) + mirrorBuildCall(nme.Ident, reifyFreeTerm(This(sym))) case tree @ This(_) if !tree.symbol.isLocalToReifee => if (reifyDebug) println("This for %s, reified as This".format(tree.symbol)) mirrorBuildCall(nme.This, reify(tree.symbol)) diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index cd8d2b60dc..3f3f08cf2b 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -176,12 +176,11 @@ trait Extractors { List( _, _, - binding, Apply(Select(Select(uref2 @ Ident(_), build2), flagsFromBits), List(Literal(Constant(flags: Long)))), Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeTerm == nme.newFreeTerm && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - Some(uref1, name, binding, flags, origin) + Some(uref1, name, reifyBinding(tree), flags, origin) case _ => None } @@ -194,22 +193,11 @@ trait Extractors { Select(Select(uref1 @ Ident(_), build1), newFreeType), List( _, - _, - value, Apply(Select(Select(uref2 @ Ident(_), build2), flagsFromBits), List(Literal(Constant(flags: Long)))), Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeType == nme.newFreeType && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - value match { - case Apply(TypeApply(Select(Select(uref3 @ Ident(_), typeTag), apply), List(binding)), List(Literal(Constant(null)), _)) - if uref3.name == nme.UNIVERSE_SHORT && typeTag == nme.TypeTag && apply == nme.apply => - Some(uref1, name, binding, flags, origin) - case Apply(TypeApply(Select(uref3 @ Ident(_), typeTag), List(binding)), List(Literal(Constant(null)), _)) - if uref3.name == nme.UNIVERSE_SHORT && typeTag == nme.TypeTag => - Some(uref1, name, binding, flags, origin) - case _ => - throw new Error("unsupported free type def: %s%n%s".format(value, showRaw(value))) - } + Some(uref1, name, reifyBinding(tree), flags, origin) case _ => None } diff --git a/src/compiler/scala/reflect/reify/utils/StdAttachments.scala b/src/compiler/scala/reflect/reify/utils/StdAttachments.scala index abbed814e0..0b9cf58c89 100644 --- a/src/compiler/scala/reflect/reify/utils/StdAttachments.scala +++ b/src/compiler/scala/reflect/reify/utils/StdAttachments.scala @@ -6,7 +6,13 @@ trait StdAttachments { import global._ - case class ReifyBindingAttachment(binding: Symbol) + case class ReifyBindingAttachment(binding: Tree) - case class ReifyAliasAttachment(binding: Symbol, alias: TermName) + def reifyBinding(tree: Tree): Tree = + tree.attachments.get[ReifyBindingAttachment] match { + case Some(ReifyBindingAttachment(binding)) => binding + case other => Ident(NoSymbol) + } + + case class ReifyAliasAttachment(sym: Symbol, alias: TermName) } \ No newline at end of file diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index 3892c86dd3..30ec6e8d52 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -45,28 +45,27 @@ trait SymbolTables { def symRef(sym: Symbol): Tree = symtab.get(sym) match { - case Some(FreeDef(_, name, _, _, _)) => Ident(name) addAttachment ReifyBindingAttachment(sym) - case Some(SymDef(_, name, _, _)) => Ident(name) addAttachment ReifyBindingAttachment(sym) + case Some(FreeDef(_, name, binding, _, _)) => Ident(name) addAttachment binding + case Some(SymDef(_, name, _, _)) => Ident(name) addAttachment ReifyBindingAttachment(Ident(sym)) case None => EmptyTree } def +(sym: Symbol, name: TermName, reification: Tree): SymbolTable = add(sym, name, reification) - def +(sym: Symbol, name: TermName): SymbolTable = add(sym, name) def +(symDef: Tree): SymbolTable = add(symDef) def ++(symDefs: TraversableOnce[Tree]): SymbolTable = (this /: symDefs)((symtab, symDef) => symtab.add(symDef)) def ++(symtab: SymbolTable): SymbolTable = { val updated = this ++ symtab.symtab.values; new SymbolTable(updated.symtab, updated.aliases ++ symtab.aliases) } def -(sym: Symbol): SymbolTable = remove(sym) def -(name: TermName): SymbolTable = remove(name) - def -(symDef: Tree): SymbolTable = remove(binding(symDef)) + def -(symDef: Tree): SymbolTable = remove(reifyBinding(symDef).symbol) def --(syms: GenTraversableOnce[Symbol]): SymbolTable = (this /: syms)((symtab, sym) => symtab.remove(sym)) def --(names: Iterable[TermName]): SymbolTable = (this /: names)((symtab, name) => symtab.remove(name)) - def --(symDefs: TraversableOnce[Tree]): SymbolTable = this -- (symDefs map (binding(_))) + def --(symDefs: TraversableOnce[Tree]): SymbolTable = this -- (symDefs map (reifyBinding(_))) def --(symtab: SymbolTable): SymbolTable = { val updated = this -- symtab.symtab.values; new SymbolTable(updated.symtab, updated.aliases diff symtab.aliases) } def filterSyms(p: Symbol => Boolean): SymbolTable = this -- (syms filterNot p) def filterAliases(p: (Symbol, TermName) => Boolean): SymbolTable = this -- (aliases filterNot (tuple => p(tuple._1, tuple._2)) map (_._2)) private def add(symDef: Tree): SymbolTable = { - val sym = binding(symDef) + val sym = reifyBinding(symDef).symbol assert(sym != NoSymbol, showRaw(symDef)) val name = symDef match { case FreeDef(_, name, _, _, _) => name @@ -85,7 +84,8 @@ trait SymbolTables { val fresh = typer.context.unit.fresh newTermName(fresh.newName(name)) } - add(ValDef(NoMods, freshName(name0), TypeTree(), reification) addAttachment ReifyBindingAttachment(sym)) + val bindingAttachment = reification.attachments.get[ReifyBindingAttachment].get + add(ValDef(NoMods, freshName(name0), TypeTree(), reification) addAttachment bindingAttachment) } private def add(sym: Symbol, name: TermName): SymbolTable = { @@ -115,12 +115,6 @@ trait SymbolTables { new SymbolTable(newSymtab, newAliases) } - private def binding(tree: Tree): Symbol = - tree.attachments.get[ReifyBindingAttachment] match { - case Some(ReifyBindingAttachment(binding)) => binding - case other => NoSymbol - } - private val cache = mutable.Map[SymbolTable, List[Tree]]() def encode: List[Tree] = cache.getOrElseUpdate(this, SymbolTable.encode(this)) map (_.duplicate) @@ -147,7 +141,7 @@ trait SymbolTables { def apply(encoded: List[Tree]): SymbolTable = { var result = new SymbolTable(original = Some(encoded)) encoded foreach (entry => (entry.attachments.get[ReifyBindingAttachment], entry.attachments.get[ReifyAliasAttachment]) match { - case (Some(ReifyBindingAttachment(sym)), _) => result += entry + case (Some(ReifyBindingAttachment(_)), _) => result += entry case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ (sym, alias)) case _ => // do nothing, this is boilerplate that can easily be recreated by subsequent `result.encode` }) @@ -169,30 +163,26 @@ trait SymbolTables { def fillInSymbol(sym: Symbol): Tree = { if (reifyDebug) println("Filling in: %s (%s)".format(sym, sym.accurateKindString)) - val isFree = currtab.symName(sym) startsWith nme.REIFY_FREE_PREFIX - if (isFree) { - if (sym.annotations.isEmpty) EmptyTree - else Apply(Select(currtab.symRef(sym), nme.setAnnotations), List(reifier.reify(sym.annotations))) - } else { - // SI-6204 don't reify signatures for incomplete symbols, because this might lead to cyclic reference errors - val signature = - if (sym.isInitialized) { - if (sym.isCapturedVariable) capturedVariableType(sym) - else sym.info - } else NoType - val rset = reifier.mirrorBuildCall(nme.setTypeSignature, currtab.symRef(sym), reifier.reify(signature)) - // `Symbol.annotations` doesn't initialize the symbol, so we don't need to do anything special here - // also since we call `sym.info` a few lines above, by now the symbol will be initialized (if possible) - // so the annotations will be filled in and will be waiting to be reified (unless symbol initialization is prohibited as described above) - if (sym.annotations.isEmpty) rset - else reifier.mirrorBuildCall(nme.setAnnotations, rset, reifier.mkList(sym.annotations map reifier.reifyAnnotationInfo)) - } + val isFreeTerm = FreeTermDef.unapply(currtab.symDef(sym)).isDefined + // SI-6204 don't reify signatures for incomplete symbols, because this might lead to cyclic reference errors + val signature = + if (sym.isInitialized) { + if (sym.isCapturedVariable) capturedVariableType(sym) + else if (isFreeTerm) sym.tpe + else sym.info + } else NoType + val rset = reifier.mirrorBuildCall(nme.setTypeSignature, currtab.symRef(sym), reifier.reify(signature)) + // `Symbol.annotations` doesn't initialize the symbol, so we don't need to do anything special here + // also since we call `sym.info` a few lines above, by now the symbol will be initialized (if possible) + // so the annotations will be filled in and will be waiting to be reified (unless symbol initialization is prohibited as described above) + if (sym.annotations.isEmpty) rset + else reifier.mirrorBuildCall(nme.setAnnotations, rset, reifier.mkList(sym.annotations map reifier.reifyAnnotationInfo)) } // `fillInSymbol` might add symbols to `symtab`, that's why this is done iteratively var progress = 0 while (progress < cumulativeSymtab.length) { - val sym = currtab.binding(cumulativeSymtab(progress)) + val sym = reifyBinding(cumulativeSymtab(progress)).symbol if (sym != NoSymbol) { val symtabProgress = currtab.symtab.size val aliasesProgress = currtab.aliases.length @@ -207,7 +197,7 @@ trait SymbolTables { val withAliases = cumulativeSymtab flatMap (entry => { val result = mutable.ListBuffer[Tree]() result += entry - val sym = currtab.binding(entry) + val sym = reifyBinding(entry).symbol if (sym != NoSymbol) result ++= cumulativeAliases.distinct filter (alias => alias._1 == sym && alias._2 != currtab.symName(sym)) map (alias => { val canonicalName = currtab.symName(sym) diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala index 2448dd53e4..6f90d598f9 100644 --- a/src/library/scala/reflect/base/Base.scala +++ b/src/library/scala/reflect/base/Base.scala @@ -36,10 +36,10 @@ class Base extends Universe { self => def newClassSymbol(name: TypeName, pos: Position = NoPosition, flags: FlagSet = NoFlags): ClassSymbol = new ClassSymbol(this, name, flags) - def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null) = + def newFreeTermSymbol(name: TermName, value: => Any, flags: FlagSet = NoFlags, origin: String = null) = new FreeTermSymbol(this, name, flags) - def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null) = + def newFreeTypeSymbol(name: TypeName, flags: FlagSet = NoFlags, origin: String = null) = new FreeTypeSymbol(this, name, flags) private def kindString: String = @@ -311,10 +311,10 @@ class Base extends Universe { self => else new TypeSymbol(owner, name.toTypeName, flags) else new TermSymbol(owner, name.toTermName, flags) - def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = + def newFreeTerm(name: String, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = new FreeTermSymbol(rootMirror.RootClass, newTermName(name), flags) - def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol = + def newFreeType(name: String, flags: Long = 0L, origin: String = null): FreeTypeSymbol = new FreeTypeSymbol(rootMirror.RootClass, newTypeName(name), flags) def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S = sym diff --git a/src/library/scala/reflect/base/BuildUtils.scala b/src/library/scala/reflect/base/BuildUtils.scala index 28d2528af9..c4231dd515 100644 --- a/src/library/scala/reflect/base/BuildUtils.scala +++ b/src/library/scala/reflect/base/BuildUtils.scala @@ -29,24 +29,18 @@ trait BuildUtils { self: Universe => /** Create a fresh free term symbol. * @param name the name of the free variable - * @param info the type signature of the free variable * @param value the value of the free variable at runtime * @param flags (optional) flags of the free variable * @param origin debug information that tells where this symbol comes from */ - def newFreeTerm(name: String, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTermSymbol + def newFreeTerm(name: String, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTermSymbol /** Create a fresh free type symbol. * @param name the name of the free variable - * @param info the type signature of the free variable - * @param value a type tag that captures the value of the free variable - * is completely phantom, since the captured type cannot be propagated to the runtime - * if it could be, we wouldn't be creating a free type to begin with - * the only usage for it is preserving the captured symbol for compile-time analysis * @param flags (optional) flags of the free variable * @param origin debug information that tells where this symbol comes from */ - def newFreeType(name: String, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTypeSymbol + def newFreeType(name: String, flags: FlagSet = NoFlags, origin: String = null): FreeTypeSymbol /** Set symbol's type signature to given type. * @return the symbol itself diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index b9d489628e..f7371f4180 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -30,11 +30,11 @@ trait BuildUtils extends base.BuildUtils { self: SymbolTable => else MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName)) } - def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = - newFreeTermSymbol(newTermName(name), info, value, flags, origin) + def newFreeTerm(name: String, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = + newFreeTermSymbol(newTermName(name), value, flags, origin) - def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol = - newFreeTypeSymbol(newTypeName(name), info, value, flags, origin) + def newFreeType(name: String, flags: Long = 0L, origin: String = null): FreeTypeSymbol = + newFreeTypeSymbol(newTypeName(name), flags, origin) def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol = owner.newNestedSymbol(name, pos, flags, isClass) diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index 4b3eb0cdc4..87058df732 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -72,9 +72,9 @@ trait Importers extends api.Importers { self: SymbolTable => case x: from.ModuleSymbol => linkReferenced(myowner.newModuleSymbol(myname, mypos, myflags), x, importSymbol) case x: from.FreeTermSymbol => - newFreeTermSymbol(importName(x.name).toTermName, importType(x.info), x.value, x.flags, x.origin) + newFreeTermSymbol(importName(x.name).toTermName, x.value, x.flags, x.origin) setInfo importType(x.info) case x: from.FreeTypeSymbol => - newFreeTypeSymbol(importName(x.name).toTypeName, importType(x.info), x.value, x.flags, x.origin) + newFreeTypeSymbol(importName(x.name).toTypeName, x.flags, x.origin) case x: from.TermSymbol => linkReferenced(myowner.newValue(myname, mypos, myflags), x, importSymbol) case x: from.TypeSkolem => diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index b1e81de037..430cf58a54 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -48,13 +48,13 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Create a new free term. Its owner is NoSymbol. */ - def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeTermSymbol = - new FreeTermSymbol(name, value, origin) initFlags flags setInfo info + def newFreeTermSymbol(name: TermName, value: => Any, flags: Long = 0L, origin: String): FreeTermSymbol = + new FreeTermSymbol(name, value, origin) initFlags flags /** Create a new free type. Its owner is NoSymbol. */ - def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeTypeSymbol = - new FreeTypeSymbol(name, value, origin) initFlags flags setInfo info + def newFreeTypeSymbol(name: TypeName, flags: Long = 0L, origin: String): FreeTypeSymbol = + new FreeTypeSymbol(name, origin) initFlags flags /** The original owner of a class. Used by the backend to generate * EnclosingMethod attributes. @@ -3080,9 +3080,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => } implicit val FreeTermSymbolTag = ClassTag[FreeTermSymbol](classOf[FreeTermSymbol]) - class FreeTypeSymbol(name0: TypeName, value0: => Any, val origin: String) extends TypeSkolem(NoSymbol, NoPosition, name0, NoSymbol) with FreeSymbol with FreeTypeSymbolApi { - def value = value0 - } + class FreeTypeSymbol(name0: TypeName, val origin: String) extends TypeSkolem(NoSymbol, NoPosition, name0, NoSymbol) with FreeSymbol with FreeTypeSymbolApi implicit val FreeTypeSymbolTag = ClassTag[FreeTypeSymbol](classOf[FreeTypeSymbol]) /** An object representing a missing symbol */ diff --git a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala index 40346cad79..7705610efb 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala @@ -14,11 +14,11 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable => override def connectModuleToClass(m: ModuleSymbol, moduleClass: ClassSymbol): ModuleSymbol = synchronized { super.connectModuleToClass(m, moduleClass) } - override def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = - new FreeTermSymbol(name, value, origin) with SynchronizedTermSymbol initFlags flags setInfo info + override def newFreeTermSymbol(name: TermName, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol = + new FreeTermSymbol(name, value, origin) with SynchronizedTermSymbol initFlags flags - override def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol = - new FreeTypeSymbol(name, value, origin) with SynchronizedTypeSymbol initFlags flags setInfo info + override def newFreeTypeSymbol(name: TypeName, flags: Long = 0L, origin: String = null): FreeTypeSymbol = + new FreeTypeSymbol(name, origin) with SynchronizedTypeSymbol initFlags flags override protected def makeNoSymbol: NoSymbol = new NoSymbol with SynchronizedSymbol diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index a036d92a24..2550f4dae0 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -1,24 +1,24 @@ -Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton -Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +Bar.type, t=TypeRef, s=type Bar.type +Bar, t=TypeRef, s=type Bar Test.ToS, t=RefinedType, s=f3 Test.ToS, t=RefinedType, s=f4 Test.ToS, t=RefinedType, s=f5 () => Test.ToS, t=TypeRef, s=class Function0 () => Test.ToS, t=TypeRef, s=class Function0 -$anon, t=TypeRef, s= <: B with Test.ToS -$anon, t=TypeRef, s= <: B with A with Test.ToS +$anon, t=TypeRef, s=type $anon +$anon, t=TypeRef, s=type $anon List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List List[Seq[Int]], t=TypeRef, s=class List List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List -Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton -Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +Bar.type, t=TypeRef, s=type Bar.type +Bar, t=TypeRef, s=type Bar Test.ToS, t=RefinedType, s=g3 Test.ToS, t=RefinedType, s=g4 Test.ToS, t=RefinedType, s=g5 () => Test.ToS, t=TypeRef, s=class Function0 () => Test.ToS, t=TypeRef, s=class Function0 -$anon, t=TypeRef, s= <: B with Test.ToS -$anon, t=TypeRef, s= <: B with A with Test.ToS +$anon, t=TypeRef, s=type $anon +$anon, t=TypeRef, s=type $anon List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List List[Seq[Int]], t=TypeRef, s=class List List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala index 16735eab4f..31ddc8cc9e 100644 --- a/test/files/run/existentials3-new.scala +++ b/test/files/run/existentials3-new.scala @@ -42,27 +42,27 @@ object Test { // tags do work for f10/g10 def main(args: Array[String]): Unit = { - m(f1) - m(f2) + m2(f1) + m2(f2) m(f3) m(f4) m(f5) m(f6) m(f7) - m(f8) - m(f9) + m2(f8) + m2(f9) m2(f10) m(f11) m(f12) - m(g1) - m(g2) + m2(g1) + m2(g2) m(g3) m(g4) m(g5) m(g6) m(g7) - m(g8) - m(g9) + m2(g8) + m2(g9) m2(g10) m(g11) m(g12) diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index b2f6f7d50e..f693ad78cc 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -18,7 +18,8 @@ object Macros { val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index 948c047351..1dbf5a1a87 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -18,7 +18,8 @@ object Macros { val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala index 4edfb5073f..690c6213cf 100644 --- a/test/files/run/t1195-new.scala +++ b/test/files/run/t1195-new.scala @@ -9,7 +9,7 @@ object Test { val g1 = g() val h1 = h() - def m[T: TypeTag](x: T) = println(typeOf[T] + ", underlying = " + typeOf[T].typeSymbol.typeSignature) + def m[T: AbsTypeTag](x: T) = println(absTypeOf[T] + ", underlying = " + absTypeOf[T].typeSymbol.typeSignature) def main(args: Array[String]): Unit = { m(f) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 01a418d42e..51eb63f294 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -12,7 +12,8 @@ object Test extends App { val rupkg = cm.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 462dc9fa91..74fd09d9fd 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -12,7 +12,8 @@ object Test extends App { val rupkg = cm.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) -- cgit v1.2.3 From 0eabb63c06f4041077860875c9ea71216adf4faa Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 11 Sep 2012 09:54:20 +0200 Subject: SI-6323 prohibits reflection against free types One of the use cases for free types is reification of local classes. The result is very seamless. Despite that local classes are not pickled, free types recreated the symbols referenced by local classes, so that we get our own symbol table, which can be analyzed with usual precision of pickled symbols and types. However when we try to use those symbols for reflection, we hit a problem. Scala runtime reflection uses its own mechanism for dealing with non-pickled types, which is incompatible with mini symbol tables used in free types. Therefore to prevent confusion, I prohibit using those symbols for reflection. --- .../scala/reflect/runtime/JavaMirrors.scala | 23 +++++++++++++++++++--- test/files/run/t6323.check | 1 + test/files/run/t6323.scala | 21 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 test/files/run/t6323.check create mode 100644 test/files/run/t6323.scala (limited to 'test') diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 9f2c3fc79c..455cc14789 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -133,6 +133,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym """.trim.stripMargin) private def ErrorSetImmutableField(wannabe: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${wannabe.name}") private def ErrorNotConstructor(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a constructor of $owner, you provided $wannabe") + private def ErrorFree(member: Symbol, freeType: Symbol) = throw new ScalaReflectionException(s"cannot reflect ${member.kindString} ${member.name}, because it's a member of a free type ${freeType.name}") def reflect[T: ClassTag](obj: T): InstanceMirror = new JavaInstanceMirror(obj) @@ -154,13 +155,30 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol = classToScala(rtcls).companionModule.asModule + private def ensuringNotFree(wannabe: Symbol)(body: => Any) { + val freeType = wannabe.ownerChain find (_.isFreeType) + freeType match { + case Some(freeType) => ErrorFree(wannabe, freeType) + case _ => body + } + } + private def checkMemberOf(wannabe: Symbol, owner: ClassSymbol) { if (wannabe.owner == AnyClass || wannabe.owner == AnyRefClass || wannabe.owner == ObjectClass) { // do nothing } else if (wannabe.owner == AnyValClass) { if (!owner.isPrimitiveValueClass && !owner.isDerivedValueClass) ErrorNotMember(wannabe, owner) } else { - if (!(owner.info.baseClasses contains wannabe.owner)) ErrorNotMember(wannabe, owner) + ensuringNotFree(wannabe) { + if (!(owner.info.baseClasses contains wannabe.owner)) ErrorNotMember(wannabe, owner) + } + } + } + + private def checkConstructorOf(wannabe: Symbol, owner: ClassSymbol) { + if (!wannabe.isClassConstructor) ErrorNotConstructor(wannabe, owner) + ensuringNotFree(wannabe) { + if (!owner.info.decls.toList.contains(wannabe)) ErrorNotConstructor(wannabe, owner) } } @@ -386,8 +404,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def erasure = symbol def isStatic = false def reflectConstructor(constructor: MethodSymbol) = { - if (!constructor.isClassConstructor) ErrorNotConstructor(constructor, symbol) - if (!symbol.info.decls.toList.contains(constructor)) ErrorNotConstructor(constructor, symbol) + checkConstructorOf(constructor, symbol) new JavaConstructorMirror(outer, constructor) } def companion: Option[ModuleMirror] = symbol.companionModule match { diff --git a/test/files/run/t6323.check b/test/files/run/t6323.check new file mode 100644 index 0000000000..2219278a16 --- /dev/null +++ b/test/files/run/t6323.check @@ -0,0 +1 @@ +cannot reflect value a, because it's a member of a free type Test diff --git a/test/files/run/t6323.scala b/test/files/run/t6323.scala new file mode 100644 index 0000000000..625cfaae20 --- /dev/null +++ b/test/files/run/t6323.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.typeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +} \ No newline at end of file -- cgit v1.2.3 From 524c90d09f2fb4687b312f2c7597393978d50b6a Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 12 Sep 2012 12:24:08 +0200 Subject: SI-6323 outlaws free types from TypeTag Free types are no longer acceptable in normal type tags. Like type parameters or abstract type members they don't map on any real type, therefore I think this is a justified change. The main reason for doing is this is to prohibit people from using `typeOf` on local classes. Sure, the guard introduced in the previous commit will raise runtime errors about that, but this commit provides static checking. Those especially persistent might use `absTypeOf` and then try to play around with the weak type it returns, but that's advanced usage scenario, and I don't worry much about it. Bottom line: `typeOf` should just work. Things that work with additional effort should be explicitly marked as such. --- src/compiler/scala/reflect/reify/Errors.scala | 4 ++-- src/compiler/scala/reflect/reify/States.scala | 8 +++++--- .../scala/reflect/reify/codegen/GenSymbols.scala | 1 + .../scala/reflect/reify/utils/SymbolTables.scala | 1 + test/files/neg/t6323a.check | 9 +++++++++ test/files/neg/t6323a.flags | 1 + test/files/neg/t6323a.scala | 21 +++++++++++++++++++++ test/files/run/t6323.check | 1 - test/files/run/t6323.scala | 21 --------------------- test/files/run/t6323b.check | 1 + test/files/run/t6323b.scala | 21 +++++++++++++++++++++ 11 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 test/files/neg/t6323a.check create mode 100644 test/files/neg/t6323a.flags create mode 100644 test/files/neg/t6323a.scala delete mode 100644 test/files/run/t6323.check delete mode 100644 test/files/run/t6323.scala create mode 100644 test/files/run/t6323b.check create mode 100644 test/files/run/t6323b.scala (limited to 'test') diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala index 5e15c5ad3a..73c13901b6 100644 --- a/src/compiler/scala/reflect/reify/Errors.scala +++ b/src/compiler/scala/reflect/reify/Errors.scala @@ -27,8 +27,8 @@ trait Errors { throw new ReificationError(defaultErrorPosition, msg) } - def CannotReifyTypeTagHavingUnresolvedTypeParameters(tpe: Type) = { - val msg = "cannot reify TypeTag having unresolved type parameter %s".format(tpe) + def CannotReifyWeakType(details: Any) = { + val msg = "cannot create a TypeTag" + details throw new ReificationError(defaultErrorPosition, msg) } diff --git a/src/compiler/scala/reflect/reify/States.scala b/src/compiler/scala/reflect/reify/States.scala index a01cfe5d74..58455c9f3c 100644 --- a/src/compiler/scala/reflect/reify/States.scala +++ b/src/compiler/scala/reflect/reify/States.scala @@ -34,9 +34,11 @@ trait States { def reificationIsConcrete_=(value: Boolean): Unit = { _reificationIsConcrete = value if (!value && concrete) { - assert(current.isInstanceOf[Type], current) - val offender = current.asInstanceOf[Type] - CannotReifyTypeTagHavingUnresolvedTypeParameters(offender) + current match { + case tpe: Type => CannotReifyWeakType(s" having unresolved type parameter $tpe") + case sym: Symbol => CannotReifyWeakType(s" referring to local ${sym.kindString} ${sym.fullName}") + case _ => CannotReifyWeakType("") + } } } var reifyStack = reifee :: Nil diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala index be138c7bfa..c4b674955a 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala @@ -112,6 +112,7 @@ trait GenSymbols { def reifyFreeType(binding: Tree): Tree = reifyIntoSymtab(binding.symbol) { sym => if (reifyDebug) println("Free type: %s (%s)".format(sym, sym.accurateKindString)) + state.reificationIsConcrete = false val name = newTermName(nme.REIFY_FREE_PREFIX + sym.name) Reification(name, binding, mirrorBuildCall(nme.newFreeType, reify(sym.name.toString), mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym)))) } diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index 30ec6e8d52..2e17558f54 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -17,6 +17,7 @@ trait SymbolTables { private[SymbolTable] val original: Option[List[Tree]] = None) { def syms: List[Symbol] = symtab.keys.toList + def isConcrete: Boolean = symtab.values forall (sym => !FreeTypeDef.unapply(sym).isDefined) // def aliases: Map[Symbol, List[TermName]] = aliases.distinct groupBy (_._1) mapValues (_ map (_._2)) diff --git a/test/files/neg/t6323a.check b/test/files/neg/t6323a.check new file mode 100644 index 0000000000..694c79ca5f --- /dev/null +++ b/test/files/neg/t6323a.check @@ -0,0 +1,9 @@ +t6323a.scala:11: `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because: +failed to typecheck the materialized tag: +cannot create a TypeTag referring to local class Test.Test + val value = u.typeOf[Test] + ^ +t6323a.scala:11: error: No TypeTag available for Test + val value = u.typeOf[Test] + ^ +one error found diff --git a/test/files/neg/t6323a.flags b/test/files/neg/t6323a.flags new file mode 100644 index 0000000000..4c6cdb71e2 --- /dev/null +++ b/test/files/neg/t6323a.flags @@ -0,0 +1 @@ +-Xlog-implicits \ No newline at end of file diff --git a/test/files/neg/t6323a.scala b/test/files/neg/t6323a.scala new file mode 100644 index 0000000000..a203167f3c --- /dev/null +++ b/test/files/neg/t6323a.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.typeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +} \ No newline at end of file diff --git a/test/files/run/t6323.check b/test/files/run/t6323.check deleted file mode 100644 index 2219278a16..0000000000 --- a/test/files/run/t6323.check +++ /dev/null @@ -1 +0,0 @@ -cannot reflect value a, because it's a member of a free type Test diff --git a/test/files/run/t6323.scala b/test/files/run/t6323.scala deleted file mode 100644 index 625cfaae20..0000000000 --- a/test/files/run/t6323.scala +++ /dev/null @@ -1,21 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{currentMirror => m} -import scala.reflect.runtime.{universe => u} - -object Test extends App { - locally { - try { - case class Test(a:String,b:List[Int]) - - val lookAtMe = m.reflect(Test("a",List(5))) - val value = u.typeOf[Test] - val members = value.members - val member = value.members.filter(_.name.encoded == "a") - val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) - val thisShouldBeA = aAccessor.apply() - println(thisShouldBeA) - } catch { - case ScalaReflectionException(msg) => println(msg) - } - } -} \ No newline at end of file diff --git a/test/files/run/t6323b.check b/test/files/run/t6323b.check new file mode 100644 index 0000000000..2219278a16 --- /dev/null +++ b/test/files/run/t6323b.check @@ -0,0 +1 @@ +cannot reflect value a, because it's a member of a free type Test diff --git a/test/files/run/t6323b.scala b/test/files/run/t6323b.scala new file mode 100644 index 0000000000..25a2329d94 --- /dev/null +++ b/test/files/run/t6323b.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.absTypeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +} \ No newline at end of file -- cgit v1.2.3 From f4a722d20547a5b4ffe47405d122b34b586c17c3 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 12 Sep 2012 12:55:39 +0200 Subject: SI-6310 AbsTypeTag => WeakTypeTag The new name for AbsTypeTag was a matter of a lengthy discussion: http://groups.google.com/group/scala-internals/browse_thread/thread/fb2007e61b505c4d I couldn't decide until having fixed SI-6323 today, which is about trying to reflect against a local class using typeOf. The problem with local classes is that they aren't pickled, so their metadata isn't preserved between Scala compilation runs. Sure, we can restore some of that metadata with Java reflection, but you get the idea. Before today typeOf of a local class created a free type, a synthetic symbol, with a bunch of synthetic children that remember the metadata, effectively creating a mini symbol table. That might be useful at time, but the problem is that this free type cannot be reflected, because the global symbol table of Scala reflection doesn't know about its mini symbol table. And then it struck me. It's not the presence of abs types (type parameters and abs type members) that differentiates arbitrary type tags from good type tags. It's the presence of types that don't map well on the runtime world - ones that can't be used to instantiate values, ones that can't be reflected. So we just need a name for these types. Phantom types are compile-time only concept, whereas our types can have partial correspondence with the runtime. "Weak types" sound more or less okish, so let's try them out. --- .../scala/reflect/macros/runtime/Aliases.scala | 8 +- .../scala/reflect/macros/runtime/Exprs.scala | 2 +- .../scala/reflect/macros/runtime/TypeTags.scala | 2 +- src/compiler/scala/reflect/reify/Taggers.scala | 4 +- .../scala/reflect/reify/codegen/GenTypes.scala | 2 +- .../scala/reflect/reify/codegen/GenUtils.scala | 2 +- .../scala/reflect/reify/phases/Reshape.scala | 4 +- .../scala/reflect/reify/utils/Extractors.scala | 4 +- src/compiler/scala/tools/nsc/doc/Settings.scala | 2 +- .../scala/tools/nsc/doc/html/SyntaxHigh.scala | 2 +- .../scala/tools/nsc/interpreter/ReplVals.scala | 2 +- .../tools/nsc/typechecker/ContextErrors.scala | 6 +- .../scala/tools/nsc/typechecker/Implicits.scala | 2 +- .../scala/tools/nsc/typechecker/Macros.scala | 12 +- .../scala/tools/nsc/typechecker/Tags.scala | 6 +- src/compiler/scala/tools/reflect/FastTrack.scala | 4 +- src/library/scala/reflect/base/Exprs.scala | 14 +-- src/library/scala/reflect/base/TypeTags.scala | 133 +++++++++++---------- src/library/scala/reflect/base/Universe.scala | 2 +- .../scala/reflect/macros/internal/package.scala | 6 +- .../scala/reflect/internal/Definitions.scala | 10 +- src/reflect/scala/reflect/internal/StdNames.scala | 4 +- src/reflect/scala/reflect/macros/Aliases.scala | 8 +- src/reflect/scala/reflect/macros/Exprs.scala | 2 +- src/reflect/scala/reflect/macros/TypeTags.scala | 2 +- .../scala/reflect/runtime/JavaMirrors.scala | 2 +- src/reflect/scala/reflect/runtime/package.scala | 2 +- ...interop_abstypetags_arenot_classmanifests.scala | 8 +- .../neg/interop_abstypetags_arenot_classtags.scala | 8 +- .../neg/interop_abstypetags_arenot_manifests.scala | 8 +- .../neg/macro-invalidsig-context-bounds.check | 2 +- .../macro-invalidsig-context-bounds/Impls_1.scala | 2 +- .../neg/macro-invalidsig-implicit-params.check | 2 +- .../Impls_Macros_1.scala | 4 +- .../neg/macro-invalidsig-tparams-notparams-a.check | 2 +- .../Impls_1.scala | 2 +- .../neg/macro-invalidsig-tparams-notparams-b.check | 2 +- .../Impls_1.scala | 6 +- .../neg/macro-invalidsig-tparams-notparams-c.check | 2 +- .../Impls_1.scala | 6 +- .../macro-reify-typetag-useabstypetag/Test.scala | 2 +- test/files/pos/t6047.scala | 6 +- test/files/run/abstypetags_core.scala | 60 +++++----- test/files/run/abstypetags_serialize.scala | 8 +- test/files/run/existentials3-new.scala | 2 +- .../run/interop_manifests_are_abstypetags.scala | 10 +- .../Impls_Macros_1.scala | 2 +- .../run/macro-def-path-dependent-d2/Impls_1.scala | 2 +- .../macro-expand-implicit-argument/Macros_1.scala | 4 +- .../run/macro-expand-nullary-generic/Impls_1.scala | 12 +- .../macro-expand-tparams-explicit/Impls_1.scala | 4 +- test/files/run/macro-expand-tparams-implicit.check | 2 +- .../macro-expand-tparams-implicit/Impls_1.scala | 4 +- test/files/run/macro-expand-tparams-prefix-a.check | 2 +- .../macro-expand-tparams-prefix-a/Impls_1.scala | 4 +- test/files/run/macro-expand-tparams-prefix-b.check | 2 +- .../macro-expand-tparams-prefix-b/Impls_1.scala | 6 +- .../files/run/macro-expand-tparams-prefix-c1.check | 2 +- .../macro-expand-tparams-prefix-c1/Impls_1.scala | 4 +- .../files/run/macro-expand-tparams-prefix-c2.check | 2 +- .../Impls_Macros_1.scala | 4 +- .../files/run/macro-expand-tparams-prefix-d1.check | 4 +- .../macro-expand-tparams-prefix-d1/Impls_1.scala | 4 +- .../macro-impl-default-params/Impls_Macros_1.scala | 4 +- .../Impls_Macros_1.scala | 2 +- .../macro-reify-abstypetag-notypeparams/Test.scala | 4 +- .../macro-reify-abstypetag-typeparams-notags.check | 4 +- .../Test.scala | 4 +- .../macro-reify-abstypetag-typeparams-tags.check | 2 +- .../Test.scala | 6 +- .../run/macro-reify-abstypetag-usetypetag.check | 2 +- .../macro-reify-abstypetag-usetypetag/Test.scala | 4 +- test/files/run/macro-reify-freevars/Macros_1.scala | 2 +- .../run/macro-reify-nested-a/Impls_Macros_1.scala | 6 +- .../run/macro-reify-nested-b/Impls_Macros_1.scala | 6 +- test/files/run/macro-reify-tagful-a/Macros_1.scala | 2 +- test/files/run/macro-reify-tagless-a.check | 2 +- .../Impls_Macros_1.scala | 8 +- test/files/run/macro-undetparams-macroitself.check | 2 +- .../Impls_Macros_1.scala | 2 +- test/files/run/reify_newimpl_26.check | 6 +- test/files/run/reify_newimpl_26.scala | 2 +- test/files/run/t1195-new.scala | 2 +- test/files/run/t6323b.check | 2 +- test/files/run/t6323b.scala | 2 +- .../Impls_1.scala | 2 +- .../macro-expand-tparams-prefix-e1/Impls_1.scala | 4 +- .../macro-expand-tparams-prefix-f1/Impls_1.scala | 4 +- test/pending/run/macro-reify-array/Macros_1.scala | 2 +- .../run/macro-reify-tagful-b/Macros_1.scala | 2 +- 90 files changed, 277 insertions(+), 268 deletions(-) (limited to 'test') diff --git a/src/compiler/scala/reflect/macros/runtime/Aliases.scala b/src/compiler/scala/reflect/macros/runtime/Aliases.scala index 5e15b61dbd..30e72997f7 100644 --- a/src/compiler/scala/reflect/macros/runtime/Aliases.scala +++ b/src/compiler/scala/reflect/macros/runtime/Aliases.scala @@ -17,12 +17,12 @@ trait Aliases { override type Expr[+T] = universe.Expr[T] override val Expr = universe.Expr - override type AbsTypeTag[T] = universe.AbsTypeTag[T] + override type WeakTypeTag[T] = universe.WeakTypeTag[T] override type TypeTag[T] = universe.TypeTag[T] - override val AbsTypeTag = universe.AbsTypeTag + override val WeakTypeTag = universe.WeakTypeTag override val TypeTag = universe.TypeTag - override def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag + override def weakTypeTag[T](implicit attag: WeakTypeTag[T]) = attag override def typeTag[T](implicit ttag: TypeTag[T]) = ttag - override def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe + override def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe override def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } \ No newline at end of file diff --git a/src/compiler/scala/reflect/macros/runtime/Exprs.scala b/src/compiler/scala/reflect/macros/runtime/Exprs.scala index 4217a6a404..ebf8fa2b96 100644 --- a/src/compiler/scala/reflect/macros/runtime/Exprs.scala +++ b/src/compiler/scala/reflect/macros/runtime/Exprs.scala @@ -4,5 +4,5 @@ package runtime trait Exprs { self: Context => - def Expr[T: AbsTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree)) + def Expr[T: WeakTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree)) } diff --git a/src/compiler/scala/reflect/macros/runtime/TypeTags.scala b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala index 2bc2fe6384..19b60159de 100644 --- a/src/compiler/scala/reflect/macros/runtime/TypeTags.scala +++ b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala @@ -4,6 +4,6 @@ package runtime trait TypeTags { self: Context => - def AbsTypeTag[T](tpe: Type): AbsTypeTag[T] = universe.AbsTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) + def WeakTypeTag[T](tpe: Type): WeakTypeTag[T] = universe.WeakTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) def TypeTag[T](tpe: Type): TypeTag[T] = universe.TypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe)) } diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index a8523fe686..bc12d383a4 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -37,7 +37,7 @@ abstract class Taggers { } def materializeTypeTag(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean): Tree = { - val tagType = if (concrete) TypeTagClass else AbsTypeTagClass + val tagType = if (concrete) TypeTagClass else WeakTypeTagClass // what we need here is to compose a type BaseUniverse # TypeTag[$tpe] // to look for an implicit that conforms to this type // that's why neither appliedType(tagType, List(tpe)) aka TypeRef(TypeTagsClass.thisType, tagType, List(tpe)) @@ -50,7 +50,7 @@ abstract class Taggers { case success if !success.isEmpty => Apply(Select(success, nme.in), List(mirror orElse mkDefaultMirrorRef(c.universe)(universe, c.callsiteTyper))) case _ => - val tagModule = if (concrete) TypeTagModule else AbsTypeTagModule + val tagModule = if (concrete) TypeTagModule else WeakTypeTagModule materializeTag(universe, tpe, tagModule, c.reifyType(universe, mirror, tpe, concrete = concrete)) } } diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 1d2e177688..7aa87dc2f8 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -73,7 +73,7 @@ trait GenTypes { if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) { if (reifyDebug) println("splicing " + tpe) - val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.AbsTypeTag.toString + val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.WeakTypeTag.toString val key = (tagFlavor, tpe.typeSymbol) // if this fails, it might produce the dreaded "erroneous or inaccessible type" error // to find out the whereabouts of the error run scalac with -Ydebug diff --git a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala index 2b7733fb6c..8aef8d772f 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala @@ -131,7 +131,7 @@ trait GenUtils { def isCrossStageTypeBearer(tree: Tree): Boolean = tree match { case TypeApply(hk, _) => isCrossStageTypeBearer(hk) - case Select(sym @ Select(_, ctor), nme.apply) if ctor == nme.AbsTypeTag || ctor == nme.TypeTag || ctor == nme.Expr => true + case Select(sym @ Select(_, ctor), nme.apply) if ctor == nme.WeakTypeTag || ctor == nme.TypeTag || ctor == nme.Expr => true case _ => false } diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index fcf3c0e65c..0b07c47c0f 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -103,8 +103,8 @@ trait Reshape { // of, say, ClassTag or TypeTag case Apply(TypeApply(_, List(tt)), _) if original.symbol == MacroInternal_materializeClassTag => gen.mkNullaryCall(Predef_implicitly, List(appliedType(ClassTagClass, tt.tpe))) - case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeAbsTypeTag => - gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, AbsTypeTagClass, List(tt.tpe)))) + case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeWeakTypeTag => + gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, WeakTypeTagClass, List(tt.tpe)))) case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeTypeTag => gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, TypeTagClass, List(tt.tpe)))) case _ => diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index 3f3f08cf2b..1df9efbb82 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -94,7 +94,7 @@ trait Extractors { object ReifiedTree { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, rtree: Tree, tpe: Type, rtpe: Tree, concrete: Boolean): Tree = { - val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag + val tagFactory = if (concrete) nme.TypeTag else nme.WeakTypeTag val tagCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) val exprCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), nme.Expr), nme.apply), List(TypeTree(tpe))) val tagArgs = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) @@ -122,7 +122,7 @@ trait Extractors { object ReifiedType { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, tpe: Type, rtpe: Tree, concrete: Boolean) = { - val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag + val tagFactory = if (concrete) nme.TypeTag else nme.WeakTypeTag val ctor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) val args = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) val unwrapped = Apply(ctor, args) diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index dbc34bd7b3..60cd375175 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -257,7 +257,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_)) ("scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) + ("scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) + ("scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) + - ("scala.reflect.AbsTypeTag" -> ((tparam: String) => tparam + " is accompanied by an AbsTypeTag, which is a runtime representation of its type that survives erasure")) + + ("scala.reflect.WeakTypeTag" -> ((tparam: String) => tparam + " is accompanied by an WeakTypeTag, which is a runtime representation of its type that survives erasure")) + ("scala.reflect.base.TypeTags.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure")) /** diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala index f1eab841f9..9b0765e394 100644 --- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -40,7 +40,7 @@ private[html] object SyntaxHigh { /** Standard library classes/objects, sorted alphabetically */ val standards = Array ( - "AbsTypeTag", "Any", "AnyRef", "AnyVal", "App", "Application", "Array", + "WeakTypeTag", "Any", "AnyRef", "AnyVal", "App", "Application", "Array", "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "Console", "Double", "Enumeration", "Float", "Function", "Int", "List", "Long", "Manifest", "Map", diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala index 5b8e4c3d92..cb10de7dca 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala @@ -65,7 +65,7 @@ object ReplVals { * I have this forwarder which widens the type and then cast the result back * to the dependent type. */ - def compilerTypeFromTag(t: BaseUniverse # AbsTypeTag[_]): Global#Type = + def compilerTypeFromTag(t: BaseUniverse # WeakTypeTag[_]): Global#Type = definitions.compilerTypeFromTag(t) class AppliedTypeFromTags(sym: Symbol) { diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 49ace019b9..bbeb549289 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -738,7 +738,7 @@ trait ContextErrors { ) val forgotten = ( if (sym.isTerm) "splice when splicing this variable into a reifee" - else "c.AbsTypeTag annotation for this type parameter" + else "c.WeakTypeTag annotation for this type parameter" ) macroExpansionError(expandee, template(sym.name.nameKind).format(sym.name + " " + sym.origin, forgotten)) } @@ -1234,7 +1234,7 @@ trait ContextErrors { message + suffix } - private def abbreviateCoreAliases(s: String): String = List("AbsTypeTag", "Expr").foldLeft(s)((res, x) => res.replace("c.universe." + x, "c." + x)) + private def abbreviateCoreAliases(s: String): String = List("WeakTypeTag", "Expr").foldLeft(s)((res, x) => res.replace("c.universe." + x, "c." + x)) private def showMeth(pss: List[List[Symbol]], restpe: Type, abbreviate: Boolean) = { var argsPart = (pss map (ps => ps map (_.defString) mkString ("(", ", ", ")"))).mkString @@ -1313,7 +1313,7 @@ trait ContextErrors { // aXXX (e.g. aparams) => characteristics of the macro impl ("a" stands for "actual") // rXXX (e.g. rparams) => characteristics of a reference macro impl signature synthesized from the macro def ("r" stands for "reference") - def MacroImplNonTagImplicitParameters(params: List[Symbol]) = compatibilityError("macro implementations cannot have implicit parameters other than AbsTypeTag evidences") + def MacroImplNonTagImplicitParameters(params: List[Symbol]) = compatibilityError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences") def MacroImplParamssMismatchError() = compatibilityError("number of parameter sections differ") diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 6a91922b4c..08978ef4b5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1151,7 +1151,7 @@ trait Implicits { private def TagSymbols = TagMaterializers.keySet private val TagMaterializers = Map[Symbol, Symbol]( ClassTagClass -> MacroInternal_materializeClassTag, - AbsTypeTagClass -> MacroInternal_materializeAbsTypeTag, + WeakTypeTagClass -> MacroInternal_materializeWeakTypeTag, TypeTagClass -> MacroInternal_materializeTypeTag ) diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 59935677a8..b9dd31ec77 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -26,7 +26,7 @@ import scala.reflect.macros.runtime.AbortMacroException * * Then fooBar needs to point to a static method of the following form: * - * def fooBar[T: c.AbsTypeTag] // type tag annotation is optional + * def fooBar[T: c.WeakTypeTag] // type tag annotation is optional * (c: scala.reflect.macros.Context) * (xs: c.Expr[List[T]]) * : c.Expr[T] = { @@ -84,7 +84,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { val methName: String, // flattens the macro impl's parameter lists having symbols replaced with metadata // currently metadata is an index of the type parameter corresponding to that type tag (if applicable) - // f.ex. for: def impl[T: AbsTypeTag, U: AbsTypeTag, V](c: Context)(x: c.Expr[T]): (U, V) = ??? + // f.ex. for: def impl[T: WeakTypeTag, U: WeakTypeTag, V](c: Context)(x: c.Expr[T]): (U, V) = ??? // `signature` will be equal to List(-1, -1, 0, 1) val signature: List[Int], // type arguments part of a macro impl ref (the right-hand side of a macro definition) @@ -216,7 +216,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { } /** Transforms parameters lists of a macro impl. - * The `transform` function is invoked only for AbsTypeTag evidence parameters. + * The `transform` function is invoked only for WeakTypeTag evidence parameters. * * The transformer takes two arguments: a value parameter from the parameter list * and a type parameter that is witnesses by the value parameter. @@ -232,7 +232,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { if (paramss.isEmpty || paramss.last.isEmpty) return paramss // no implicit parameters in the signature => nothing to do if (paramss.head.isEmpty || !(paramss.head.head.tpe <:< MacroContextClass.tpe)) return paramss // no context parameter in the signature => nothing to do def transformTag(param: Symbol): Symbol = param.tpe.dealias match { - case TypeRef(SingleType(SingleType(NoPrefix, c), universe), AbsTypeTagClass, targ :: Nil) + case TypeRef(SingleType(SingleType(NoPrefix, c), universe), WeakTypeTagClass, targ :: Nil) if c == paramss.head.head && universe == MacroContextUniverse => transform(param, targ.typeSymbol) case _ => @@ -336,7 +336,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { RepeatedParamClass.typeConstructor, List(implType(isType, sigma(origTpe.typeArgs.head)))) else { - val tsym = getMember(MacroContextClass, if (isType) tpnme.AbsTypeTag else tpnme.Expr) + val tsym = getMember(MacroContextClass, if (isType) tpnme.WeakTypeTag else tpnme.Expr) typeRef(singleType(NoPrefix, ctxParam), tsym, List(sigma(origTpe))) } val paramCache = collection.mutable.Map[Symbol, Symbol]() @@ -630,7 +630,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { macroDef.owner) } else targ.tpe - context.AbsTypeTag(tpe) + context.WeakTypeTag(tpe) }) macroTraceVerbose("tags: ")(tags) diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala index f82e009be8..167bf5c857 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala @@ -26,7 +26,7 @@ trait Tags { /** Finds in scope or materializes a ClassTag. * Should be used instead of ClassManifest every time compiler needs to persist an erasure. * - * Once upon a time, we had an `ErasureTag` which was to `ClassTag` the same that `AbsTypeTag` is for `TypeTag`. + * Once upon a time, we had an `ErasureTag` which was to `ClassTag` the same that `WeakTypeTag` is for `TypeTag`. * However we found out that we don't really need this concept, so it got removed. * * @param pos Position for error reporting. Please, provide meaningful value. @@ -43,7 +43,7 @@ trait Tags { resolveTag(pos, taggedTp, allowMaterialization) } - /** Finds in scope or materializes an AbsTypeTag (if `concrete` is false) or a TypeTag (if `concrete` is true). + /** Finds in scope or materializes an WeakTypeTag (if `concrete` is false) or a TypeTag (if `concrete` is true). * * @param pos Position for error reporting. Please, provide meaningful value. * @param pre Prefix that represents a universe this type tag will be bound to. @@ -60,7 +60,7 @@ trait Tags { * EmptyTree if `allowMaterialization` is false, and there is no array tag in scope. */ def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = { - val tagSym = if (concrete) TypeTagClass else AbsTypeTagClass + val tagSym = if (concrete) TypeTagClass else WeakTypeTagClass val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.toTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) val taggedTp = appliedType(tagTp, List(tp)) resolveTag(pos, taggedTp, allowMaterialization) diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index 07c972899e..d6bed0c6d1 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -23,7 +23,7 @@ trait FastTrack { def validate(c: MacroContext): Boolean = expander.isDefinedAt((c, c.expandee)) def run(c: MacroContext): Any = { val result = expander((c, c.expandee)) - c.Expr[Nothing](result)(c.AbsTypeTag.Nothing) + c.Expr[Nothing](result)(c.WeakTypeTag.Nothing) } } @@ -31,7 +31,7 @@ trait FastTrack { var registry = Map[Symbol, FastTrackEntry]() implicit class BindTo(sym: Symbol) { def bindTo(expander: FastTrackExpander): Unit = if (sym != NoSymbol) registry += sym -> FastTrackEntry(sym, expander) } MacroInternal_materializeClassTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeClassTag(u, tt.tpe) } - MacroInternal_materializeAbsTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) } + MacroInternal_materializeWeakTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) } MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) } BaseUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) } ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree } diff --git a/src/library/scala/reflect/base/Exprs.scala b/src/library/scala/reflect/base/Exprs.scala index 10c222722a..45598c03e2 100644 --- a/src/library/scala/reflect/base/Exprs.scala +++ b/src/library/scala/reflect/base/Exprs.scala @@ -28,19 +28,19 @@ trait Exprs { self: Universe => } object Expr { - def apply[T: AbsTypeTag](mirror: MirrorOf[self.type], treec: TreeCreator): Expr[T] = new ExprImpl[T](mirror.asInstanceOf[Mirror], treec) + def apply[T: WeakTypeTag](mirror: MirrorOf[self.type], treec: TreeCreator): Expr[T] = new ExprImpl[T](mirror.asInstanceOf[Mirror], treec) def unapply[T](expr: Expr[T]): Option[Tree] = Some(expr.tree) } - private class ExprImpl[+T: AbsTypeTag](val mirror: Mirror, val treec: TreeCreator) extends Expr[T] { + private class ExprImpl[+T: WeakTypeTag](val mirror: Mirror, val treec: TreeCreator) extends Expr[T] { def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T] = { val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] - val tag1 = (implicitly[AbsTypeTag[T]] in otherMirror).asInstanceOf[otherMirror.universe.AbsTypeTag[T]] + val tag1 = (implicitly[WeakTypeTag[T]] in otherMirror).asInstanceOf[otherMirror.universe.WeakTypeTag[T]] otherMirror.universe.Expr[T](otherMirror1, treec)(tag1) } lazy val tree: Tree = treec(mirror) - lazy val staticType: Type = implicitly[AbsTypeTag[T]].tpe + lazy val staticType: Type = implicitly[WeakTypeTag[T]].tpe def actualType: Type = treeType(tree) def splice: T = throw new UnsupportedOperationException(""" @@ -54,11 +54,11 @@ trait Exprs { self: Universe => |if you want to get a value of the underlying expression, add scala-compiler.jar to the classpath, |import `scala.tools.reflect.Eval` and call `.eval` instead.""".trim.stripMargin) - private def writeReplace(): AnyRef = new SerializedExpr(treec, implicitly[AbsTypeTag[T]].in(scala.reflect.basis.rootMirror)) + private def writeReplace(): AnyRef = new SerializedExpr(treec, implicitly[WeakTypeTag[T]].in(scala.reflect.basis.rootMirror)) } } -private[scala] class SerializedExpr(var treec: TreeCreator, var tag: scala.reflect.basis.AbsTypeTag[_]) extends Serializable { +private[scala] class SerializedExpr(var treec: TreeCreator, var tag: scala.reflect.basis.WeakTypeTag[_]) extends Serializable { private def writeObject(out: java.io.ObjectOutputStream): Unit = { out.writeObject(treec) out.writeObject(tag) @@ -66,7 +66,7 @@ private[scala] class SerializedExpr(var treec: TreeCreator, var tag: scala.refle private def readObject(in: java.io.ObjectInputStream): Unit = { treec = in.readObject().asInstanceOf[TreeCreator] - tag = in.readObject().asInstanceOf[scala.reflect.basis.AbsTypeTag[_]] + tag = in.readObject().asInstanceOf[scala.reflect.basis.WeakTypeTag[_]] } private def readResolve(): AnyRef = { diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index b7e0c37a4b..fd7a204ff4 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -17,15 +17,15 @@ import language.implicitConversions * === Overview === * * Type tags are organized in a hierarchy of three classes: - * [[scala.reflect.ClassTag]], [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#AbsTypeTag]]. + * [[scala.reflect.ClassTag]], [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#WeakTypeTag]]. * * A [[scala.reflect.ClassTag]] carries a runtime class that corresponds to the source type T. * As of such, it possesses the knowledge about how to build single- and multi-dimensional arrays of elements of that type. * It guarantees that the source type T did not to contain any references to type parameters or abstract types. * [[scala.reflect.ClassTag]] corresponds to a previous notion of [[scala.reflect.ClassManifest]]. * - * A [[scala.reflect.base.Universe#AbsTypeTag]] value wraps a full Scala type in its tpe field. - * A [[scala.reflect.base.Universe#TypeTag]] value is an [[scala.reflect.base.Universe#AbsTypeTag]] + * A [[scala.reflect.base.Universe#WeakTypeTag]] value wraps a full Scala type in its tpe field. + * A [[scala.reflect.base.Universe#TypeTag]] value is an [[scala.reflect.base.Universe#WeakTypeTag]] * that is guaranteed not to contain any references to type parameters or abstract types. * * [Eugene++] also mention sensitivity to prefixes, i.e. that rb.TypeTag is different from ru.TypeTag @@ -40,36 +40,36 @@ import language.implicitConversions * import reflect.mirror._ * def f[T: TypeTag, U] = { * type L = T => U - * implicitly[AbsTypeTag[L]] + * implicitly[WeakTypeTag[L]] * } * * Then a call of f[String, Int] will yield a result of the form * - * AbsTypeTag(<[ String => U ]>). + * WeakTypeTag(<[ String => U ]>). * * Note that T has been replaced by String, because it comes with a TypeTag in f, whereas U was left as a type parameter. * - * === AbsTypeTag vs TypeTag === + * === WeakTypeTag vs TypeTag === * - * Be careful with AbsTypeTag, because it will reify types even if these types are abstract. + * Be careful with WeakTypeTag, because it will reify types even if these types are abstract. * This makes it easy to forget to tag one of the methods in the call chain and discover it much later in the runtime * by getting cryptic errors far away from their source. For example, consider the following snippet: * - * def bind[T: AbsTypeTag](name: String, value: T): IR.Result = bind((name, value)) - * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value) + * def bind[T: WeakTypeTag](name: String, value: T): IR.Result = bind((name, value)) + * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value) * object NamedParam { - * implicit def namedValue[T: AbsTypeTag](name: String, x: T): NamedParam = apply(name, x) - * def apply[T: AbsTypeTag](name: String, x: T): NamedParam = new Typed[T](name, x) + * implicit def namedValue[T: WeakTypeTag](name: String, x: T): NamedParam = apply(name, x) + * def apply[T: WeakTypeTag](name: String, x: T): NamedParam = new Typed[T](name, x) * } * * This fragment of Scala REPL implementation defines a `bind` function that carries a named value along with its type - * into the heart of the REPL. Using a [[scala.reflect.base.Universe#AbsTypeTag]] here is reasonable, because it is desirable + * into the heart of the REPL. Using a [[scala.reflect.base.Universe#WeakTypeTag]] here is reasonable, because it is desirable * to work with all types, even if they are type parameters or abstract type members. * - * However if any of the three `AbsTypeTag` context bounds is omitted, the resulting code will be incorrect, - * because the missing `AbsTypeTag` will be transparently generated by the compiler, carrying meaningless information. + * However if any of the three `WeakTypeTag` context bounds is omitted, the resulting code will be incorrect, + * because the missing `WeakTypeTag` will be transparently generated by the compiler, carrying meaningless information. * Most likely, this problem will manifest itself elsewhere, making debugging complicated. - * If `AbsTypeTag` context bounds were replaced with `TypeTag`, then such errors would be reported statically. + * If `WeakTypeTag` context bounds were replaced with `TypeTag`, then such errors would be reported statically. * But in that case we wouldn't be able to use `bind` in arbitrary contexts. * * === Backward compatibility === @@ -103,72 +103,77 @@ trait TypeTags { self: Universe => import definitions._ + // should be removed in the subsequent commit + // after the starr is redeployed + trait AbsTypeTag[T] + object AbsTypeTag + /** - * If an implicit value of type u.AbsTypeTag[T] is required, the compiler will make one up on demand. + * If an implicit value of type u.WeakTypeTag[T] is required, the compiler will make one up on demand. * The implicitly created value contains in its tpe field a value of type u.Type that is a reflective representation of T. * In that value, any occurrences of type parameters or abstract types U * which come themselves with a TypeTag are represented by the type referenced by that TypeTag. * * @see [[scala.reflect.base.TypeTags]] */ - @annotation.implicitNotFound(msg = "No AbsTypeTag available for ${T}") - trait AbsTypeTag[T] extends Equals with Serializable { + @annotation.implicitNotFound(msg = "No WeakTypeTag available for ${T}") + trait WeakTypeTag[T] extends Equals with Serializable { val mirror: Mirror - def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T] + def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # WeakTypeTag[T] def tpe: Type /** case class accessories */ - override def canEqual(x: Any) = x.isInstanceOf[AbsTypeTag[_]] - override def equals(x: Any) = x.isInstanceOf[AbsTypeTag[_]] && this.mirror == x.asInstanceOf[AbsTypeTag[_]].mirror && this.tpe == x.asInstanceOf[AbsTypeTag[_]].tpe + override def canEqual(x: Any) = x.isInstanceOf[WeakTypeTag[_]] + override def equals(x: Any) = x.isInstanceOf[WeakTypeTag[_]] && this.mirror == x.asInstanceOf[WeakTypeTag[_]].mirror && this.tpe == x.asInstanceOf[WeakTypeTag[_]].tpe override def hashCode = mirror.hashCode * 31 + tpe.hashCode - override def toString = "AbsTypeTag[" + tpe + "]" + override def toString = "WeakTypeTag[" + tpe + "]" } - object AbsTypeTag { - val Byte : AbsTypeTag[scala.Byte] = TypeTag.Byte - val Short : AbsTypeTag[scala.Short] = TypeTag.Short - val Char : AbsTypeTag[scala.Char] = TypeTag.Char - val Int : AbsTypeTag[scala.Int] = TypeTag.Int - val Long : AbsTypeTag[scala.Long] = TypeTag.Long - val Float : AbsTypeTag[scala.Float] = TypeTag.Float - val Double : AbsTypeTag[scala.Double] = TypeTag.Double - val Boolean : AbsTypeTag[scala.Boolean] = TypeTag.Boolean - val Unit : AbsTypeTag[scala.Unit] = TypeTag.Unit - val Any : AbsTypeTag[scala.Any] = TypeTag.Any - val AnyVal : AbsTypeTag[scala.AnyVal] = TypeTag.AnyVal - val AnyRef : AbsTypeTag[scala.AnyRef] = TypeTag.AnyRef - val Object : AbsTypeTag[java.lang.Object] = TypeTag.Object - val Nothing : AbsTypeTag[scala.Nothing] = TypeTag.Nothing - val Null : AbsTypeTag[scala.Null] = TypeTag.Null + object WeakTypeTag { + val Byte : WeakTypeTag[scala.Byte] = TypeTag.Byte + val Short : WeakTypeTag[scala.Short] = TypeTag.Short + val Char : WeakTypeTag[scala.Char] = TypeTag.Char + val Int : WeakTypeTag[scala.Int] = TypeTag.Int + val Long : WeakTypeTag[scala.Long] = TypeTag.Long + val Float : WeakTypeTag[scala.Float] = TypeTag.Float + val Double : WeakTypeTag[scala.Double] = TypeTag.Double + val Boolean : WeakTypeTag[scala.Boolean] = TypeTag.Boolean + val Unit : WeakTypeTag[scala.Unit] = TypeTag.Unit + val Any : WeakTypeTag[scala.Any] = TypeTag.Any + val AnyVal : WeakTypeTag[scala.AnyVal] = TypeTag.AnyVal + val AnyRef : WeakTypeTag[scala.AnyRef] = TypeTag.AnyRef + val Object : WeakTypeTag[java.lang.Object] = TypeTag.Object + val Nothing : WeakTypeTag[scala.Nothing] = TypeTag.Nothing + val Null : WeakTypeTag[scala.Null] = TypeTag.Null - def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): AbsTypeTag[T] = + def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): WeakTypeTag[T] = tpec1(mirror1) match { - case ByteTpe => AbsTypeTag.Byte.asInstanceOf[AbsTypeTag[T]] - case ShortTpe => AbsTypeTag.Short.asInstanceOf[AbsTypeTag[T]] - case CharTpe => AbsTypeTag.Char.asInstanceOf[AbsTypeTag[T]] - case IntTpe => AbsTypeTag.Int.asInstanceOf[AbsTypeTag[T]] - case LongTpe => AbsTypeTag.Long.asInstanceOf[AbsTypeTag[T]] - case FloatTpe => AbsTypeTag.Float.asInstanceOf[AbsTypeTag[T]] - case DoubleTpe => AbsTypeTag.Double.asInstanceOf[AbsTypeTag[T]] - case BooleanTpe => AbsTypeTag.Boolean.asInstanceOf[AbsTypeTag[T]] - case UnitTpe => AbsTypeTag.Unit.asInstanceOf[AbsTypeTag[T]] - case AnyTpe => AbsTypeTag.Any.asInstanceOf[AbsTypeTag[T]] - case AnyValTpe => AbsTypeTag.AnyVal.asInstanceOf[AbsTypeTag[T]] - case AnyRefTpe => AbsTypeTag.AnyRef.asInstanceOf[AbsTypeTag[T]] - case ObjectTpe => AbsTypeTag.Object.asInstanceOf[AbsTypeTag[T]] - case NothingTpe => AbsTypeTag.Nothing.asInstanceOf[AbsTypeTag[T]] - case NullTpe => AbsTypeTag.Null.asInstanceOf[AbsTypeTag[T]] - case _ => new AbsTypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1) + case ByteTpe => WeakTypeTag.Byte.asInstanceOf[WeakTypeTag[T]] + case ShortTpe => WeakTypeTag.Short.asInstanceOf[WeakTypeTag[T]] + case CharTpe => WeakTypeTag.Char.asInstanceOf[WeakTypeTag[T]] + case IntTpe => WeakTypeTag.Int.asInstanceOf[WeakTypeTag[T]] + case LongTpe => WeakTypeTag.Long.asInstanceOf[WeakTypeTag[T]] + case FloatTpe => WeakTypeTag.Float.asInstanceOf[WeakTypeTag[T]] + case DoubleTpe => WeakTypeTag.Double.asInstanceOf[WeakTypeTag[T]] + case BooleanTpe => WeakTypeTag.Boolean.asInstanceOf[WeakTypeTag[T]] + case UnitTpe => WeakTypeTag.Unit.asInstanceOf[WeakTypeTag[T]] + case AnyTpe => WeakTypeTag.Any.asInstanceOf[WeakTypeTag[T]] + case AnyValTpe => WeakTypeTag.AnyVal.asInstanceOf[WeakTypeTag[T]] + case AnyRefTpe => WeakTypeTag.AnyRef.asInstanceOf[WeakTypeTag[T]] + case ObjectTpe => WeakTypeTag.Object.asInstanceOf[WeakTypeTag[T]] + case NothingTpe => WeakTypeTag.Nothing.asInstanceOf[WeakTypeTag[T]] + case NullTpe => WeakTypeTag.Null.asInstanceOf[WeakTypeTag[T]] + case _ => new WeakTypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1) } - def unapply[T](ttag: AbsTypeTag[T]): Option[Type] = Some(ttag.tpe) + def unapply[T](ttag: WeakTypeTag[T]): Option[Type] = Some(ttag.tpe) } - private class AbsTypeTagImpl[T](val mirror: Mirror, val tpec: TypeCreator) extends AbsTypeTag[T] { + private class WeakTypeTagImpl[T](val mirror: Mirror, val tpec: TypeCreator) extends WeakTypeTag[T] { lazy val tpe: Type = tpec(mirror) - def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T] = { + def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # WeakTypeTag[T] = { val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] - otherMirror.universe.AbsTypeTag[T](otherMirror1, tpec) + otherMirror.universe.WeakTypeTag[T](otherMirror1, tpec) } private def writeReplace(): AnyRef = new SerializedTypeTag(tpec, concrete = false) } @@ -180,7 +185,7 @@ trait TypeTags { self: Universe => * @see [[scala.reflect.base.TypeTags]] */ @annotation.implicitNotFound(msg = "No TypeTag available for ${T}") - trait TypeTag[T] extends AbsTypeTag[T] with Equals with Serializable { + trait TypeTag[T] extends WeakTypeTag[T] with Equals with Serializable { override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] /** case class accessories */ @@ -230,7 +235,7 @@ trait TypeTags { self: Universe => def unapply[T](ttag: TypeTag[T]): Option[Type] = Some(ttag.tpe) } - private class TypeTagImpl[T](mirror: Mirror, tpec: TypeCreator) extends AbsTypeTagImpl[T](mirror, tpec) with TypeTag[T] { + private class TypeTagImpl[T](mirror: Mirror, tpec: TypeCreator) extends WeakTypeTagImpl[T](mirror, tpec) with TypeTag[T] { override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = { val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] otherMirror.universe.TypeTag[T](otherMirror1, tpec) @@ -250,11 +255,11 @@ trait TypeTags { self: Universe => } // incantations - def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag + def weakTypeTag[T](implicit attag: WeakTypeTag[T]) = attag def typeTag[T](implicit ttag: TypeTag[T]) = ttag // big thanks to Viktor Klang for this brilliant idea! - def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe + def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } @@ -272,6 +277,6 @@ private[scala] class SerializedTypeTag(var tpec: TypeCreator, var concrete: Bool private def readResolve(): AnyRef = { import scala.reflect.basis._ if (concrete) TypeTag(rootMirror, tpec) - else AbsTypeTag(rootMirror, tpec) + else WeakTypeTag(rootMirror, tpec) } } \ No newline at end of file diff --git a/src/library/scala/reflect/base/Universe.scala b/src/library/scala/reflect/base/Universe.scala index f098876c18..18599ad092 100644 --- a/src/library/scala/reflect/base/Universe.scala +++ b/src/library/scala/reflect/base/Universe.scala @@ -46,7 +46,7 @@ abstract class Universe extends Symbols * def macroImpl[T](c: Context) = { * ... * // T here is just a type parameter, so the tree produced by reify won't be of much use in a macro expansion - * // however, if T were annotated with c.AbsTypeTag (which would declare an implicit parameter for macroImpl) + * // however, if T were annotated with c.WeakTypeTag (which would declare an implicit parameter for macroImpl) * // then reification would substitute T with the TypeTree that was used in a TypeApply of this particular macro invocation * val factory = c.reify{ new Queryable[T] } * ... diff --git a/src/library/scala/reflect/macros/internal/package.scala b/src/library/scala/reflect/macros/internal/package.scala index 0a0e6c5b51..bbb57667ea 100644 --- a/src/library/scala/reflect/macros/internal/package.scala +++ b/src/library/scala/reflect/macros/internal/package.scala @@ -7,7 +7,11 @@ import scala.reflect.ClassTag // implementation is magically hardwired into `scala.reflect.reify.Taggers` // todo. once we have implicit macros for tag generation, we can remove these anchors package object internal { + // should be removed in the subsequent commit + // after the starr is redeployed + private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.WeakTypeTag[T] = ??? // macro + private[scala] def materializeClassTag[T](u: BaseUniverse): ClassTag[T] = ??? // macro - private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.AbsTypeTag[T] = ??? // macro + private[scala] def materializeWeakTypeTag[T](u: BaseUniverse): u.WeakTypeTag[T] = ??? // macro private[scala] def materializeTypeTag[T](u: BaseUniverse): u.TypeTag[T] = ??? // macro } diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 15b74058b7..6d9f68a8a5 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -505,8 +505,8 @@ trait Definitions extends api.StandardDefinitions { lazy val ClassTagModule = requiredModule[scala.reflect.ClassTag[_]] lazy val ClassTagClass = requiredClass[scala.reflect.ClassTag[_]] lazy val TypeTagsClass = requiredClass[scala.reflect.base.TypeTags] - lazy val AbsTypeTagClass = getMemberClass(TypeTagsClass, tpnme.AbsTypeTag) - lazy val AbsTypeTagModule = getMemberModule(TypeTagsClass, nme.AbsTypeTag) + lazy val WeakTypeTagClass = getMemberClass(TypeTagsClass, tpnme.WeakTypeTag) + lazy val WeakTypeTagModule = getMemberModule(TypeTagsClass, nme.WeakTypeTag) lazy val TypeTagClass = getMemberClass(TypeTagsClass, tpnme.TypeTag) lazy val TypeTagModule = getMemberModule(TypeTagsClass, nme.TypeTag) @@ -527,7 +527,7 @@ trait Definitions extends api.StandardDefinitions { lazy val MacroImplAnnotation = requiredClass[scala.reflect.macros.internal.macroImpl] lazy val MacroInternalPackage = getPackageObject("scala.reflect.macros.internal") def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag) - def MacroInternal_materializeAbsTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeAbsTypeTag) + def MacroInternal_materializeWeakTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeWeakTypeTag) def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag) lazy val StringContextClass = requiredClass[scala.StringContext] @@ -542,8 +542,8 @@ trait Definitions extends api.StandardDefinitions { lazy val NoneModule: ModuleSymbol = requiredModule[scala.None.type] lazy val SomeModule: ModuleSymbol = requiredModule[scala.Some.type] - def compilerTypeFromTag(tt: BaseUniverse # AbsTypeTag[_]): Type = tt.in(rootMirror).tpe - def compilerSymbolFromTag(tt: BaseUniverse # AbsTypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol + def compilerTypeFromTag(tt: BaseUniverse # WeakTypeTag[_]): Type = tt.in(rootMirror).tpe + def compilerSymbolFromTag(tt: BaseUniverse # WeakTypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol // The given symbol represents either String.+ or StringAdd.+ def isStringAddition(sym: Symbol) = sym == String_+ || sym == StringAdd_+ diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index e9c21d1187..92adc85e25 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -131,7 +131,7 @@ trait StdNames { final val Seq: NameType = "Seq" final val Symbol: NameType = "Symbol" final val ClassTag: NameType = "ClassTag" - final val AbsTypeTag: NameType = "AbsTypeTag" + final val WeakTypeTag: NameType = "WeakTypeTag" final val TypeTag : NameType = "TypeTag" final val Expr: NameType = "Expr" final val String: NameType = "String" @@ -704,7 +704,7 @@ trait StdNames { val manifestToTypeTag: NameType = "manifestToTypeTag" val map: NameType = "map" val materializeClassTag: NameType = "materializeClassTag" - val materializeAbsTypeTag: NameType = "materializeAbsTypeTag" + val materializeWeakTypeTag: NameType = "materializeWeakTypeTag" val materializeTypeTag: NameType = "materializeTypeTag" val mirror : NameType = "mirror" val moduleClass : NameType = "moduleClass" diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala index ad100d7e89..eff7f34b02 100644 --- a/src/reflect/scala/reflect/macros/Aliases.scala +++ b/src/reflect/scala/reflect/macros/Aliases.scala @@ -17,12 +17,12 @@ trait Aliases { type Expr[+T] = universe.Expr[T] val Expr = universe.Expr - type AbsTypeTag[T] = universe.AbsTypeTag[T] + type WeakTypeTag[T] = universe.WeakTypeTag[T] type TypeTag[T] = universe.TypeTag[T] - val AbsTypeTag = universe.AbsTypeTag + val WeakTypeTag = universe.WeakTypeTag val TypeTag = universe.TypeTag - def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag + def weakTypeTag[T](implicit attag: WeakTypeTag[T]) = attag def typeTag[T](implicit ttag: TypeTag[T]) = ttag - def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe + def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } diff --git a/src/reflect/scala/reflect/macros/Exprs.scala b/src/reflect/scala/reflect/macros/Exprs.scala index ceaab06d12..280d5508c8 100644 --- a/src/reflect/scala/reflect/macros/Exprs.scala +++ b/src/reflect/scala/reflect/macros/Exprs.scala @@ -4,5 +4,5 @@ package macros trait Exprs { self: Context => - def Expr[T: AbsTypeTag](tree: Tree): Expr[T] + def Expr[T: WeakTypeTag](tree: Tree): Expr[T] } diff --git a/src/reflect/scala/reflect/macros/TypeTags.scala b/src/reflect/scala/reflect/macros/TypeTags.scala index 8f590d1de4..2f15e37f6a 100644 --- a/src/reflect/scala/reflect/macros/TypeTags.scala +++ b/src/reflect/scala/reflect/macros/TypeTags.scala @@ -4,6 +4,6 @@ package macros trait TypeTags { self: Context => - def AbsTypeTag[T](tpe: Type): AbsTypeTag[T] + def WeakTypeTag[T](tpe: Type): WeakTypeTag[T] def TypeTag[T](tpe: Type): TypeTag[T] } diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 455cc14789..6abd40abc6 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -133,7 +133,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym """.trim.stripMargin) private def ErrorSetImmutableField(wannabe: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${wannabe.name}") private def ErrorNotConstructor(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a constructor of $owner, you provided $wannabe") - private def ErrorFree(member: Symbol, freeType: Symbol) = throw new ScalaReflectionException(s"cannot reflect ${member.kindString} ${member.name}, because it's a member of a free type ${freeType.name}") + private def ErrorFree(member: Symbol, freeType: Symbol) = throw new ScalaReflectionException(s"cannot reflect ${member.kindString} ${member.name}, because it's a member of a weak type ${freeType.name}") def reflect[T: ClassTag](obj: T): InstanceMirror = new JavaInstanceMirror(obj) diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala index ccdea3e82d..d325cf6a16 100644 --- a/src/reflect/scala/reflect/runtime/package.scala +++ b/src/reflect/scala/reflect/runtime/package.scala @@ -17,7 +17,7 @@ package runtime { if (runtimeClass.isEmpty) c.abort(c.enclosingPosition, "call site does not have an enclosing class") val runtimeUniverse = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("universe")) val currentMirror = Apply(Select(runtimeUniverse, newTermName("runtimeMirror")), List(Select(runtimeClass, newTermName("getClassLoader")))) - c.Expr[Nothing](currentMirror)(c.AbsTypeTag.Nothing) + c.Expr[Nothing](currentMirror)(c.WeakTypeTag.Nothing) } } } diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala index c8567be5d4..5d88c90ffd 100644 --- a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotClassManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { println(classManifest[T]) } - absTypeTagIsnotClassManifest[Int] - absTypeTagIsnotClassManifest[String] - absTypeTagIsnotClassManifest[Array[Int]] + weakTypeTagIsnotClassManifest[Int] + weakTypeTagIsnotClassManifest[String] + weakTypeTagIsnotClassManifest[Array[Int]] } \ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.scala b/test/files/neg/interop_abstypetags_arenot_classtags.scala index e3911c1588..de1f8657b6 100644 --- a/test/files/neg/interop_abstypetags_arenot_classtags.scala +++ b/test/files/neg/interop_abstypetags_arenot_classtags.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.{ClassTag, classTag} object Test extends App { - def absTypeTagIsnotClassTag[T: AbsTypeTag] = { + def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { println(classTag[T]) } - absTypeTagIsnotClassTag[Int] - absTypeTagIsnotClassTag[String] - absTypeTagIsnotClassTag[Array[Int]] + weakTypeTagIsnotClassTag[Int] + weakTypeTagIsnotClassTag[String] + weakTypeTagIsnotClassTag[Array[Int]] } \ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_manifests.scala b/test/files/neg/interop_abstypetags_arenot_manifests.scala index 77a95048fd..1ca3673ce4 100644 --- a/test/files/neg/interop_abstypetags_arenot_manifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_manifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotManifest[T: WeakTypeTag] = { println(manifest[T]) } - absTypeTagIsnotManifest[Int] - absTypeTagIsnotManifest[String] - absTypeTagIsnotManifest[Array[Int]] + weakTypeTagIsnotManifest[Int] + weakTypeTagIsnotManifest[String] + weakTypeTagIsnotManifest[Array[Int]] } \ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 5d42ebc515..eb5d833bc0 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,7 +1,7 @@ Macros_Test_1.scala:2: error: macro implementation has wrong shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal -macro implementations cannot have implicit parameters other than AbsTypeTag evidences +macro implementations cannot have implicit parameters other than WeakTypeTag evidences def foo[U] = macro Impls.foo[U] ^ one error found diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala index 5aa9a7eaf9..c066c485b1 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { + def foo[U: c.WeakTypeTag: Numeric](c: Ctx) = { import c.universe._ Literal(Constant(42)) } diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 62156770e4..ca35e62cd7 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:18: error: macro implementation has wrong shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit] found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit] -macro implementations cannot have implicit parameters other than AbsTypeTag evidences +macro implementations cannot have implicit parameters other than WeakTypeTag evidences def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U] ^ one error found diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index f724538993..845a168ff2 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.AbsTypeTag[U]].tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check index 5aee62b9e5..5404c185f3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[U])Nothing +Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing def foo = macro Impls.foo ^ one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala index afbe0f0915..f8b3c92869 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = ??? + def foo[U: c.WeakTypeTag](c: Ctx) = ??? } \ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check index e8de8a4c6b..485d4de96e 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] def foo[V] = macro Impls.foo ^ one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index b48f9d5f98..baf3aab9e3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check index b1078fb233..1530c35097 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] def foo[V] = macro Impls.foo[V] ^ one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 3506bdc789..44b4ed6ab3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala index b66ad6c523..1e7fcb3f45 100644 --- a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala +++ b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala @@ -1,7 +1,7 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { + def fooTypeTag[T: WeakTypeTag] = { println(implicitly[TypeTag[T]]) println(implicitly[TypeTag[List[T]]]) } diff --git a/test/files/pos/t6047.scala b/test/files/pos/t6047.scala index 80d5e9668b..bc5f856bd2 100644 --- a/test/files/pos/t6047.scala +++ b/test/files/pos/t6047.scala @@ -4,17 +4,17 @@ import java.io.InputStream object Macros { def unpack[A](input: InputStream): A = macro unpack_impl[A] - def unpack_impl[A: c.AbsTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { + def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { import c.universe._ def unpackcode(tpe: c.Type): c.Expr[_] = { - if (tpe <:< implicitly[c.AbsTypeTag[Traversable[_]]].tpe) { + if (tpe <:< implicitly[c.WeakTypeTag[Traversable[_]]].tpe) { } ??? } - unpackcode(implicitly[c.AbsTypeTag[A]].tpe) + unpackcode(implicitly[c.WeakTypeTag[A]].tpe) ??? } } \ No newline at end of file diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala index 226de94055..2692fec035 100644 --- a/test/files/run/abstypetags_core.scala +++ b/test/files/run/abstypetags_core.scala @@ -1,34 +1,34 @@ import scala.reflect.runtime.universe._ object Test extends App { - println(implicitly[AbsTypeTag[Byte]] eq AbsTypeTag.Byte) - println(implicitly[AbsTypeTag[Byte]]) - println(implicitly[AbsTypeTag[Short]] eq AbsTypeTag.Short) - println(implicitly[AbsTypeTag[Short]]) - println(implicitly[AbsTypeTag[Char]] eq AbsTypeTag.Char) - println(implicitly[AbsTypeTag[Char]]) - println(implicitly[AbsTypeTag[Int]] eq AbsTypeTag.Int) - println(implicitly[AbsTypeTag[Int]]) - println(implicitly[AbsTypeTag[Long]] eq AbsTypeTag.Long) - println(implicitly[AbsTypeTag[Long]]) - println(implicitly[AbsTypeTag[Float]] eq AbsTypeTag.Float) - println(implicitly[AbsTypeTag[Float]]) - println(implicitly[AbsTypeTag[Double]] eq AbsTypeTag.Double) - println(implicitly[AbsTypeTag[Double]]) - println(implicitly[AbsTypeTag[Boolean]] eq AbsTypeTag.Boolean) - println(implicitly[AbsTypeTag[Boolean]]) - println(implicitly[AbsTypeTag[Unit]] eq AbsTypeTag.Unit) - println(implicitly[AbsTypeTag[Unit]]) - println(implicitly[AbsTypeTag[Any]] eq AbsTypeTag.Any) - println(implicitly[AbsTypeTag[Any]]) - println(implicitly[AbsTypeTag[AnyVal]] eq AbsTypeTag.AnyVal) - println(implicitly[AbsTypeTag[AnyVal]]) - println(implicitly[AbsTypeTag[AnyRef]] eq AbsTypeTag.AnyRef) - println(implicitly[AbsTypeTag[AnyRef]]) - println(implicitly[AbsTypeTag[Object]] eq AbsTypeTag.Object) - println(implicitly[AbsTypeTag[Object]]) - println(implicitly[AbsTypeTag[Null]] eq AbsTypeTag.Null) - println(implicitly[AbsTypeTag[Null]]) - println(implicitly[AbsTypeTag[Nothing]] eq AbsTypeTag.Nothing) - println(implicitly[AbsTypeTag[Nothing]]) + println(implicitly[WeakTypeTag[Byte]] eq WeakTypeTag.Byte) + println(implicitly[WeakTypeTag[Byte]]) + println(implicitly[WeakTypeTag[Short]] eq WeakTypeTag.Short) + println(implicitly[WeakTypeTag[Short]]) + println(implicitly[WeakTypeTag[Char]] eq WeakTypeTag.Char) + println(implicitly[WeakTypeTag[Char]]) + println(implicitly[WeakTypeTag[Int]] eq WeakTypeTag.Int) + println(implicitly[WeakTypeTag[Int]]) + println(implicitly[WeakTypeTag[Long]] eq WeakTypeTag.Long) + println(implicitly[WeakTypeTag[Long]]) + println(implicitly[WeakTypeTag[Float]] eq WeakTypeTag.Float) + println(implicitly[WeakTypeTag[Float]]) + println(implicitly[WeakTypeTag[Double]] eq WeakTypeTag.Double) + println(implicitly[WeakTypeTag[Double]]) + println(implicitly[WeakTypeTag[Boolean]] eq WeakTypeTag.Boolean) + println(implicitly[WeakTypeTag[Boolean]]) + println(implicitly[WeakTypeTag[Unit]] eq WeakTypeTag.Unit) + println(implicitly[WeakTypeTag[Unit]]) + println(implicitly[WeakTypeTag[Any]] eq WeakTypeTag.Any) + println(implicitly[WeakTypeTag[Any]]) + println(implicitly[WeakTypeTag[AnyVal]] eq WeakTypeTag.AnyVal) + println(implicitly[WeakTypeTag[AnyVal]]) + println(implicitly[WeakTypeTag[AnyRef]] eq WeakTypeTag.AnyRef) + println(implicitly[WeakTypeTag[AnyRef]]) + println(implicitly[WeakTypeTag[Object]] eq WeakTypeTag.Object) + println(implicitly[WeakTypeTag[Object]]) + println(implicitly[WeakTypeTag[Null]] eq WeakTypeTag.Null) + println(implicitly[WeakTypeTag[Null]]) + println(implicitly[WeakTypeTag[Nothing]] eq WeakTypeTag.Nothing) + println(implicitly[WeakTypeTag[Nothing]]) } \ No newline at end of file diff --git a/test/files/run/abstypetags_serialize.scala b/test/files/run/abstypetags_serialize.scala index 5b9142f6d5..38a7aba325 100644 --- a/test/files/run/abstypetags_serialize.scala +++ b/test/files/run/abstypetags_serialize.scala @@ -3,7 +3,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { - def test(tag: AbsTypeTag[_]) = + def test(tag: WeakTypeTag[_]) = try { val fout = new ByteArrayOutputStream() val out = new ObjectOutputStream(fout) @@ -13,7 +13,7 @@ object Test extends App { val fin = new ByteArrayInputStream(fout.toByteArray) val in = new ObjectInputStream(fin) - val retag = in.readObject().asInstanceOf[scala.reflect.basis.AbsTypeTag[_]].in(cm) + val retag = in.readObject().asInstanceOf[scala.reflect.basis.WeakTypeTag[_]].in(cm) in.close() fin.close() @@ -24,8 +24,8 @@ object Test extends App { } def qwe[T, U[_]] = { - test(implicitly[AbsTypeTag[T]]) - test(implicitly[AbsTypeTag[U[String]]]) + test(implicitly[WeakTypeTag[T]]) + test(implicitly[WeakTypeTag[U[String]]]) } qwe diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala index 31ddc8cc9e..110c8eff7a 100644 --- a/test/files/run/existentials3-new.scala +++ b/test/files/run/existentials3-new.scala @@ -38,7 +38,7 @@ object Test { println("%s, t=%s, s=%s".format(t, t.asInstanceOf[Product].productPrefix, s)) } def m[T: TypeTag](x: T) = printTpe(typeOf[T]) - def m2[T: AbsTypeTag](x: T) = printTpe(implicitly[AbsTypeTag[T]].tpe) + def m2[T: WeakTypeTag](x: T) = printTpe(implicitly[WeakTypeTag[T]].tpe) // tags do work for f10/g10 def main(args: Array[String]): Unit = { diff --git a/test/files/run/interop_manifests_are_abstypetags.scala b/test/files/run/interop_manifests_are_abstypetags.scala index 1cba2fdb4b..f2c2723106 100644 --- a/test/files/run/interop_manifests_are_abstypetags.scala +++ b/test/files/run/interop_manifests_are_abstypetags.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def manifestIsAbsTypeTag[T: Manifest] = { - println(implicitly[AbsTypeTag[T]].tpe) + def manifestIsWeakTypeTag[T: Manifest] = { + println(implicitly[WeakTypeTag[T]].tpe) } - manifestIsAbsTypeTag[Int] - manifestIsAbsTypeTag[String] - manifestIsAbsTypeTag[Array[Int]] + manifestIsWeakTypeTag[Int] + manifestIsWeakTypeTag[String] + manifestIsWeakTypeTag[Array[Int]] } \ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala index 2daf6fc3fb..69d9708b2a 100644 --- a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala @@ -5,5 +5,5 @@ import scala.reflect.api.Universe object Test { def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T] - def materializeTypeTag_impl[T: c.AbsTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? } \ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala b/test/files/run/macro-def-path-dependent-d2/Impls_1.scala index 1cda64e43e..7fa9c3579e 100644 --- a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala +++ b/test/files/run/macro-def-path-dependent-d2/Impls_1.scala @@ -3,5 +3,5 @@ import scala.reflect.macros.Context import scala.reflect.api.Universe object Impls { - def materializeTypeTag_impl[T: c.AbsTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? } \ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index 7629c5a9e2..86c4198870 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -35,7 +35,7 @@ object Macros { * arr * } */ - def arrayMacro[A:c.AbsTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { + def arrayMacro[A:c.WeakTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { import c.mirror._ import c.universe._ def const(x:Int) = Literal(Constant(x)) @@ -44,7 +44,7 @@ object Macros { val arr = newTermName("arr") val create = Apply(Select(ct.tree, "newArray"), List(const(n))) - val arrtpe = TypeTree(implicitly[c.AbsTypeTag[Array[A]]].tpe) + val arrtpe = TypeTree(implicitly[c.WeakTypeTag[Array[A]]].tpe) val valdef = ValDef(Modifiers(), arr, arrtpe, create) val updates = (0 until n).map { diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index fbbc23a824..1180c83a40 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -2,14 +2,14 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl[T: c.AbsTypeTag](c: Ctx) = { + def impl[T: c.WeakTypeTag](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.AbsTypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) c.Expr[Unit](body) } - def fooNullary[T: c.AbsTypeTag](c: Ctx) = impl[T](c) - def fooEmpty[T: c.AbsTypeTag](c: Ctx)() = impl[T](c) - def barNullary[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) - def barEmpty[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) + def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c) + def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c) + def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) + def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) } \ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 0a879687e8..72b420d92f 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = { + def foo[U: c.WeakTypeTag](c: Ctx) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check index 1c1a785706..37226ec68d 100644 --- a/test/files/run/macro-expand-tparams-implicit.check +++ b/test/files/run/macro-expand-tparams-implicit.check @@ -1,2 +1,2 @@ TypeTag[Int] -AbsTypeTag[String] +WeakTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index f6cb63b9c9..33770516df 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check index 6a7f9c5f52..7ef9fa7330 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ b/test/files/run/macro-expand-tparams-prefix-a.check @@ -1,4 +1,4 @@ TypeTag[Int] TypeTag[Int] -AbsTypeTag[String] +WeakTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala index f6cb63b9c9..33770516df 100644 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check index daae32bd0a..f4a2a8e80d 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ b/test/files/run/macro-expand-tparams-prefix-b.check @@ -1,2 +1,2 @@ TypeTag[Boolean] TypeTag[Int] -TypeTag[Boolean] AbsTypeTag[String] +TypeTag[Boolean] WeakTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala index 7e0fa26569..9378e67712 100644 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val T = implicitly[c.AbsTypeTag[T]] - val U = implicitly[c.AbsTypeTag[U]] + val T = implicitly[c.WeakTypeTag[T]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check index 5356b3e6d1..473668ac58 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ b/test/files/run/macro-expand-tparams-prefix-c1.check @@ -1,3 +1,3 @@ TypeTag[Int] -AbsTypeTag[String] +WeakTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala index ca515be627..afdd7d4f7a 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check index 5356b3e6d1..473668ac58 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ b/test/files/run/macro-expand-tparams-prefix-c2.check @@ -1,3 +1,3 @@ TypeTag[Int] -AbsTypeTag[String] +WeakTypeTag[String] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala index 5a554590d8..3c2838208a 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check index 319edfbed0..2331e2549e 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1.check +++ b/test/files/run/macro-expand-tparams-prefix-d1.check @@ -1,3 +1,3 @@ -AbsTypeTag[T] -AbsTypeTag[U] +WeakTypeTag[T] +WeakTypeTag[U] TypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala index ca515be627..afdd7d4f7a 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 06c58d96ab..db77b1923a 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { import c.{prefix => prefix} import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index a54b7f4b08..4583a726cf 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[T]) = { + def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) diff --git a/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala index 34f742b9fb..73c2d05921 100644 --- a/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala +++ b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ object Test extends App { - println(implicitly[AbsTypeTag[Int]]) - println(implicitly[AbsTypeTag[List[Int]]]) + println(implicitly[WeakTypeTag[Int]]) + println(implicitly[WeakTypeTag[List[Int]]]) } \ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags.check b/test/files/run/macro-reify-abstypetag-typeparams-notags.check index be62b59a69..6aeec96079 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-notags.check +++ b/test/files/run/macro-reify-abstypetag-typeparams-notags.check @@ -1,2 +1,2 @@ -AbsTypeTag[T] -AbsTypeTag[List[T]] +WeakTypeTag[T] +WeakTypeTag[List[T]] diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala index 0b42cc07b5..4ba2231d9a 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala +++ b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala @@ -2,8 +2,8 @@ import scala.reflect.runtime.universe._ object Test extends App { def fooNoTypeTag[T] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooNoTypeTag[Int] } \ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags.check b/test/files/run/macro-reify-abstypetag-typeparams-tags.check index d6ca5a85ef..6e2646c5e0 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-tags.check +++ b/test/files/run/macro-reify-abstypetag-typeparams-tags.check @@ -1,2 +1,2 @@ TypeTag[Int] -AbsTypeTag[List[Int]] +WeakTypeTag[List[Int]] diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala index 82a7b7971d..70ca615e1f 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala +++ b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala @@ -1,9 +1,9 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + def fooTypeTag[T: WeakTypeTag] = { + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooTypeTag[Int] } \ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-usetypetag.check b/test/files/run/macro-reify-abstypetag-usetypetag.check index d6ca5a85ef..6e2646c5e0 100644 --- a/test/files/run/macro-reify-abstypetag-usetypetag.check +++ b/test/files/run/macro-reify-abstypetag-usetypetag.check @@ -1,2 +1,2 @@ TypeTag[Int] -AbsTypeTag[List[Int]] +WeakTypeTag[List[Int]] diff --git a/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala index 3c62725c42..ecae4110a8 100644 --- a/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala +++ b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala @@ -2,8 +2,8 @@ import scala.reflect.runtime.universe._ object Test extends App { def fooTypeTag[T: TypeTag] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooTypeTag[Int] } \ No newline at end of file diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala index 57fdc32437..20f80c06d1 100644 --- a/test/files/run/macro-reify-freevars/Macros_1.scala +++ b/test/files/run/macro-reify-freevars/Macros_1.scala @@ -1,7 +1,7 @@ package scala.collection.slick object QueryableMacros{ - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]) : c.Expr[scala.collection.slick.Queryable[S]] = { diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index 04714970dd..ae2def2d3e 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = implicitly[c.AbsTypeTag[S]].tpe + val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index 04714970dd..ae2def2d3e 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = implicitly[c.AbsTypeTag[S]].tpe + val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala index 0eac74236f..f2512dcfaf 100644 --- a/test/files/run/macro-reify-tagful-a/Macros_1.scala +++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala @@ -5,7 +5,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[T] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check index d69f641280..c2385ba008 100644 --- a/test/files/run/macro-reify-tagless-a.check +++ b/test/files/run/macro-reify-tagless-a.check @@ -1,3 +1,3 @@ reflective compilation has failed: -Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.AbsTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types +Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.WeakTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala index 3d350a50fa..bcbd12817b 100644 --- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def cons_impl[A: c.AbsTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { - println("A = " + c.literal(implicitly[c.AbsTypeTag[A]].toString).splice) + def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { + println("A = " + c.literal(implicitly[c.WeakTypeTag[A]].toString).splice) x.splice :: xs.splice } - def nil_impl[B: c.AbsTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { - println("B = " + c.literal(implicitly[c.AbsTypeTag[B]].toString).splice) + def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { + println("B = " + c.literal(implicitly[c.WeakTypeTag[B]].toString).splice) Nil } diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check index 1c1a785706..37226ec68d 100644 --- a/test/files/run/macro-undetparams-macroitself.check +++ b/test/files/run/macro-undetparams-macroitself.check @@ -1,2 +1,2 @@ TypeTag[Int] -AbsTypeTag[String] +WeakTypeTag[String] diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index 081894cf52..0244273b6f 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def impl[T: c.AbsTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.AbsTypeTag[T]].toString).splice) } + def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.WeakTypeTag[T]].toString).splice) } def foo[T](foo: T) = macro impl[T] } \ No newline at end of file diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index c006cb7ffb..5996f3b322 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -5,16 +5,16 @@ scala> scala> def foo[T]{ import scala.reflect.runtime.universe._ - val tt = implicitly[AbsTypeTag[List[T]]] + val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } :9: free type: Ident(newTypeName("T")) defined by foo in :7:16 - val tt = implicitly[AbsTypeTag[List[T]]] + val tt = implicitly[WeakTypeTag[List[T]]] ^ foo: [T]=> Unit scala> foo[Int] -AbsTypeTag[scala.List[T]] +WeakTypeTag[scala.List[T]] scala> diff --git a/test/files/run/reify_newimpl_26.scala b/test/files/run/reify_newimpl_26.scala index a12d8a2970..af74d60e8b 100644 --- a/test/files/run/reify_newimpl_26.scala +++ b/test/files/run/reify_newimpl_26.scala @@ -5,7 +5,7 @@ object Test extends ReplTest { def code = """ def foo[T]{ import scala.reflect.runtime.universe._ - val tt = implicitly[AbsTypeTag[List[T]]] + val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } foo[Int] diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala index 690c6213cf..0f62b140c9 100644 --- a/test/files/run/t1195-new.scala +++ b/test/files/run/t1195-new.scala @@ -9,7 +9,7 @@ object Test { val g1 = g() val h1 = h() - def m[T: AbsTypeTag](x: T) = println(absTypeOf[T] + ", underlying = " + absTypeOf[T].typeSymbol.typeSignature) + def m[T: WeakTypeTag](x: T) = println(weakTypeOf[T] + ", underlying = " + weakTypeOf[T].typeSymbol.typeSignature) def main(args: Array[String]): Unit = { m(f) diff --git a/test/files/run/t6323b.check b/test/files/run/t6323b.check index 2219278a16..80b6176178 100644 --- a/test/files/run/t6323b.check +++ b/test/files/run/t6323b.check @@ -1 +1 @@ -cannot reflect value a, because it's a member of a free type Test +cannot reflect value a, because it's a member of a weak type Test diff --git a/test/files/run/t6323b.scala b/test/files/run/t6323b.scala index 25a2329d94..f530ac3ecc 100644 --- a/test/files/run/t6323b.scala +++ b/test/files/run/t6323b.scala @@ -8,7 +8,7 @@ object Test extends App { case class Test(a:String,b:List[Int]) val lookAtMe = m.reflect(Test("a",List(5))) - val value = u.absTypeOf[Test] + val value = u.weakTypeOf[Test] val members = value.members val member = value.members.filter(_.name.encoded == "a") val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala index 26d4a45fee..15bcb581c8 100644 --- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala +++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.Context object Impls { - def foo[T: c.AbsTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { println("openImplicits are: " + c.literal(c.openImplicits.toString).splice) println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).splice) println("typetag is: " + c.literal(c.tag[T].toString).splice) diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala index 99006c548a..f970be5caa 100644 --- a/test/pending/run/macro-reify-array/Macros_1.scala +++ b/test/pending/run/macro-reify-array/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: String) = macro Impls.foo[T] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { Array(s.splice) } } diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala index a14187e8a7..59dbe7157b 100644 --- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala +++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[List[T]] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } -- cgit v1.2.3 From f3fd018f145ffc02de03744259ba585d8152483f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 10 Sep 2012 16:13:51 -0400 Subject: Fix SI-4813 - Clone doesn't work on LinkedList. * Added extensive test for clone across all standard mutable collections * Fixed clone implementations when needed so they work. --- .../scala/collection/mutable/ArrayBuffer.scala | 6 ---- .../scala/collection/mutable/ArraySeq.scala | 7 ++++ .../scala/collection/mutable/BufferLike.scala | 10 ++++++ .../scala/collection/mutable/LinkedListLike.scala | 10 ++++++ .../scala/collection/mutable/MutableList.scala | 7 ++++ src/library/scala/collection/mutable/Queue.scala | 6 ++++ test/files/run/t4813.scala | 37 ++++++++++++++++++++++ 7 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 test/files/run/t4813.scala (limited to 'test') diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index 3034fc2bce..d5308c3b1a 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -169,12 +169,6 @@ class ArrayBuffer[A](override protected val initialSize: Int) result } - /** Return a clone of this buffer. - * - * @return an `ArrayBuffer` with the same elements. - */ - override def clone(): ArrayBuffer[A] = new ArrayBuffer[A] ++= this - def result: ArrayBuffer[A] = this /** Defines the prefix of the string representation. diff --git a/src/library/scala/collection/mutable/ArraySeq.scala b/src/library/scala/collection/mutable/ArraySeq.scala index d0eaee348b..60baf7b35b 100644 --- a/src/library/scala/collection/mutable/ArraySeq.scala +++ b/src/library/scala/collection/mutable/ArraySeq.scala @@ -89,6 +89,13 @@ extends AbstractSeq[A] Array.copy(array, 0, xs, start, len1) } + override def clone(): ArraySeq[A] = { + val cloned = array.clone.asInstanceOf[Array[AnyRef]] + new ArraySeq[A](length) { + override val array = cloned + } + } + } /** $factoryInfo diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index 3274fe6194..e77c1256a0 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -252,4 +252,14 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] */ @migration("`--` creates a new buffer. Use `--=` to remove an element from this buffer and return that buffer itself.", "2.8.0") override def --(xs: GenTraversableOnce[A]): This = clone() --= xs.seq + + /** Return a clone of this buffer. + * + * @return a `Buffer` with the same elements. + */ + override def clone(): This = { + val bf = newBuilder + bf ++= this + bf.result.asInstanceOf[This] + } } diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala index 07a8501ca4..59004a3de6 100644 --- a/src/library/scala/collection/mutable/LinkedListLike.scala +++ b/src/library/scala/collection/mutable/LinkedListLike.scala @@ -180,4 +180,14 @@ trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]] extends Seq these = these.next } } + + /** Return a clone of this list. + * + * @return a `LinkedList` with the same elements. + */ + override def clone(): This = { + val bf = newBuilder + bf ++= this + bf.result + } } diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index c9e44ac165..6fa1f4872a 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -140,6 +140,13 @@ extends AbstractSeq[A] } def result = this + + override def clone(): MutableList[A] = { + val bf = newBuilder + bf ++= seq + bf.result + } + } diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 21c3a84699..fc7e76125e 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -177,6 +177,12 @@ extends MutableList[A] tl.len = len - 1 tl } + + override def clone(): Queue[A] = { + val bf = newBuilder + bf ++= seq + bf.result + } } diff --git a/test/files/run/t4813.scala b/test/files/run/t4813.scala new file mode 100644 index 0000000000..6d48ca8758 --- /dev/null +++ b/test/files/run/t4813.scala @@ -0,0 +1,37 @@ +import collection.mutable._ +import reflect._ + + +object Test extends App { + def runTest[T, U](col: T)(clone: T => U)(mod: T => Unit)(implicit ct: ClassTag[T]): Unit = { + val cloned = clone(col) + assert(cloned == col, s"cloned should be equal to original. $cloned != $col") + mod(col) + assert(cloned != col, s"cloned should not modify when original does: $ct") + } + + // Seqs + runTest(ArrayBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(ArraySeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Buffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(DoubleLinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(IndexedSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(LinearSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(LinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(ListBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(MutableList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Queue(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Stack(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + + // Sets + runTest(BitSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(HashSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(Set(1,2,3))(_.clone) { buf => buf add 4 } + runTest(SortedSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(TreeSet(1,2,3))(_.clone) { buf => buf add 4 } + + // Maps + runTest(HashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) } + runTest(WeakHashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) } +} + -- cgit v1.2.3 From 55b609458fd14de248c21132a3e4a4672de4ce4b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 14 Sep 2012 07:18:12 -0700 Subject: Eliminate breaking relative names in source. These things are killing me. Constructions like package scala.foo.bar.baz import foo.Other DO NOT WORK in general. Such files are not really in the "scala" package, because it is not declared package scala package foo.bar.baz And there is a second problem: using a relative path name means compilation will fail in the presence of a directory of the same name, e.g. % mkdir reflect % scalac src/reflect/scala/reflect/internal/util/Position.scala src/reflect/scala/reflect/internal/util/Position.scala:9: error: object ClassTag is not a member of package reflect import reflect.ClassTag ^ src/reflect/scala/reflect/internal/util/Position.scala:10: error: object base is not a member of package reflect import reflect.base.Attachments ^ As a rule, do not use relative package paths unless you have explicitly imported the path to which you think you are relative. Better yet, don't use them at all. Unfortunately they mostly work because scala variously thinks everything scala.* is in the scala package and/or because you usually aren't bootstrapping and it falls through to an existing version of the class already on the classpath. Making the paths explicit is not a complete solution - in particular, we remain enormously vulnerable to any directory or package called "scala" which isn't ours - but it greatly limts the severity of the problem. --- src/actors-migration/scala/actors/Pattern.scala | 4 +- .../scala/actors/StashingActor.scala | 2 +- src/actors-migration/scala/actors/Timeout.scala | 2 +- src/actors/scala/actors/AbstractActor.scala | 2 +- src/actors/scala/actors/Actor.scala | 2 +- src/actors/scala/actors/CanReply.scala | 2 +- src/actors/scala/actors/Combinators.scala | 2 +- src/actors/scala/actors/Future.scala | 2 +- src/actors/scala/actors/Reactor.scala | 2 +- .../scala/actors/scheduler/ThreadPoolConfig.scala | 2 +- src/build/InnerObjectTestGen.scala | 2 +- src/build/genprod.scala | 2 +- .../reflect/macros/runtime/Infrastructure.scala | 6 +- .../scala/reflect/macros/runtime/Parsers.scala | 4 +- src/compiler/scala/reflect/reify/package.scala | 2 +- src/compiler/scala/tools/ant/ClassloadVerify.scala | 2 +- .../scala/tools/ant/sabbus/Compilers.scala | 2 +- src/compiler/scala/tools/cmd/Property.scala | 2 +- src/compiler/scala/tools/cmd/Reference.scala | 2 +- src/compiler/scala/tools/cmd/gen/AnyVals.scala | 8 +-- src/compiler/scala/tools/cmd/gen/Codegen.scala | 2 +- src/compiler/scala/tools/nsc/EvalLoop.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 8 +-- src/compiler/scala/tools/nsc/PhaseAssembly.scala | 2 +- src/compiler/scala/tools/nsc/Phases.scala | 4 +- .../scala/tools/nsc/ast/NodePrinters.scala | 4 +- src/compiler/scala/tools/nsc/ast/Printers.scala | 2 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 2 +- src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 2 +- src/compiler/scala/tools/nsc/ast/TreeGen.scala | 4 +- src/compiler/scala/tools/nsc/ast/TreeInfo.scala | 6 +- src/compiler/scala/tools/nsc/ast/Trees.scala | 2 +- .../tools/nsc/ast/parser/SymbolicXMLBuilder.scala | 8 +-- .../scala/tools/nsc/ast/parser/Tokens.scala | 2 +- .../tools/nsc/backend/icode/BasicBlocks.scala | 2 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 2 +- .../tools/nsc/backend/icode/Linearizers.scala | 2 +- .../backend/icode/analysis/TypeFlowAnalysis.scala | 4 +- .../tools/nsc/backend/jvm/BytecodeWriters.scala | 2 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 36 ++++++------ .../scala/tools/nsc/backend/jvm/GenJVM.scala | 2 +- .../scala/tools/nsc/backend/msil/GenMSIL.scala | 2 +- .../scala/tools/nsc/backend/opt/Inliners.scala | 2 +- .../scala/tools/nsc/dependencies/Changes.scala | 2 +- .../nsc/dependencies/DependencyAnalysis.scala | 2 +- src/compiler/scala/tools/nsc/doc/Settings.scala | 2 +- .../scala/tools/nsc/doc/Uncompilable.scala | 4 +- .../scala/tools/nsc/doc/html/HtmlPage.scala | 20 +++---- .../scala/tools/nsc/doc/html/SyntaxHigh.scala | 4 +- .../tools/nsc/doc/html/page/ReferenceIndex.scala | 2 +- .../scala/tools/nsc/doc/html/page/Source.scala | 2 +- .../scala/tools/nsc/doc/html/page/Template.scala | 68 +++++++++++----------- .../html/page/diagram/DotDiagramGenerator.scala | 4 +- .../scala/tools/nsc/doc/model/ModelFactory.scala | 2 +- .../nsc/doc/model/comment/CommentFactory.scala | 2 +- .../nsc/doc/model/diagram/DiagramFactory.scala | 2 +- .../scala/tools/nsc/interactive/BuildManager.scala | 2 +- .../scala/tools/nsc/interactive/ContextTrees.scala | 2 +- .../scala/tools/nsc/interactive/Global.scala | 2 +- .../nsc/interactive/InteractiveReporter.scala | 2 +- .../scala/tools/nsc/interactive/Picklers.scala | 2 +- .../nsc/interactive/RefinedBuildManager.scala | 2 +- .../nsc/interactive/RichCompilationUnits.scala | 2 +- .../tools/nsc/interactive/ScratchPadMaker.scala | 4 +- .../nsc/interactive/tests/InteractiveTest.scala | 4 +- .../scala/tools/nsc/interactive/tests/Tester.scala | 4 +- .../nsc/interactive/tests/core/TestMarker.scala | 4 +- .../tools/nsc/interpreter/CompletionAware.scala | 2 +- .../scala/tools/nsc/interpreter/ILoop.scala | 4 +- .../scala/tools/nsc/interpreter/IMain.scala | 2 +- .../tools/nsc/interpreter/JLineCompletion.scala | 2 +- .../scala/tools/nsc/interpreter/LoopCommands.scala | 6 +- .../tools/nsc/interpreter/MemberHandlers.scala | 2 +- .../scala/tools/nsc/interpreter/NamedParam.scala | 2 +- .../scala/tools/nsc/interpreter/Phased.scala | 2 +- .../scala/tools/nsc/interpreter/Power.scala | 2 +- .../scala/tools/nsc/interpreter/ReplVals.scala | 2 +- .../scala/tools/nsc/interpreter/TypeStrings.scala | 4 +- .../scala/tools/nsc/interpreter/package.scala | 4 +- .../tools/nsc/interpreter/session/package.scala | 2 +- src/compiler/scala/tools/nsc/io/Jar.scala | 4 +- src/compiler/scala/tools/nsc/io/Pickler.scala | 6 +- src/compiler/scala/tools/nsc/io/package.scala | 2 +- .../scala/tools/nsc/javac/JavaParsers.scala | 2 +- .../scala/tools/nsc/javac/JavaScanners.scala | 2 +- .../scala/tools/nsc/matching/MatchSupport.scala | 4 +- src/compiler/scala/tools/nsc/matching/Matrix.scala | 2 +- .../tools/nsc/matching/ParallelMatching.scala | 4 +- .../scala/tools/nsc/matching/PatternBindings.scala | 2 +- .../scala/tools/nsc/scratchpad/Mixer.scala | 2 +- .../tools/nsc/scratchpad/SourceInserter.scala | 3 +- .../scala/tools/nsc/settings/AbsSettings.scala | 2 +- .../scala/tools/nsc/settings/ScalaSettings.scala | 4 +- .../scala/tools/nsc/symtab/SymbolLoaders.scala | 8 +-- .../scala/tools/nsc/symtab/SymbolTable.scala | 2 +- .../scala/tools/nsc/symtab/SymbolTrackers.scala | 4 +- .../nsc/symtab/classfile/ClassfileParser.scala | 2 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 2 +- .../scala/tools/nsc/symtab/classfile/package.scala | 2 +- .../scala/tools/nsc/symtab/clr/TypeParser.scala | 2 +- src/compiler/scala/tools/nsc/symtab/package.scala | 2 +- .../scala/tools/nsc/transform/AddInterfaces.scala | 2 +- .../scala/tools/nsc/transform/CleanUp.scala | 6 +- .../scala/tools/nsc/transform/Erasure.scala | 2 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 2 +- .../tools/nsc/transform/OverridingPairs.scala | 2 +- .../tools/nsc/transform/SpecializeTypes.scala | 4 +- .../scala/tools/nsc/transform/UnCurry.scala | 16 ++--- .../scala/tools/nsc/typechecker/Analyzer.scala | 4 +- .../scala/tools/nsc/typechecker/Contexts.scala | 2 +- .../tools/nsc/typechecker/DestructureTypes.scala | 2 +- .../scala/tools/nsc/typechecker/Duplicators.scala | 2 +- .../scala/tools/nsc/typechecker/Implicits.scala | 12 ++-- .../scala/tools/nsc/typechecker/Macros.scala | 6 +- .../tools/nsc/typechecker/MethodSynthesis.scala | 2 +- .../tools/nsc/typechecker/PatternMatching.scala | 6 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 8 +-- .../scala/tools/nsc/typechecker/Typers.scala | 9 ++- .../scala/tools/nsc/util/Exceptional.scala | 2 +- .../scala/tools/nsc/util/ScalaClassLoader.scala | 2 +- .../scala/tools/nsc/util/StatisticsInfo.scala | 6 +- src/compiler/scala/tools/reflect/FastTrack.scala | 4 +- src/compiler/scala/tools/reflect/package.scala | 2 +- src/compiler/scala/tools/util/Javap.scala | 2 +- src/compiler/scala/tools/util/PathResolver.scala | 2 +- src/compiler/scala/tools/util/VerifyClass.scala | 2 +- .../scala/util/continuations/ControlContext.scala | 2 +- src/detach/library/scala/remoting/Channel.scala | 8 +-- src/library/scala/Array.scala | 2 +- src/library/scala/Boolean.scala | 2 +- src/library/scala/Byte.scala | 2 +- src/library/scala/Char.scala | 2 +- src/library/scala/Double.scala | 2 +- src/library/scala/Float.scala | 2 +- src/library/scala/Int.scala | 2 +- src/library/scala/Long.scala | 2 +- src/library/scala/LowPriorityImplicits.scala | 2 +- src/library/scala/Option.scala | 2 +- src/library/scala/PartialFunction.scala | 6 +- src/library/scala/Predef.scala | 8 +-- src/library/scala/SerialVersionUID.scala | 2 +- src/library/scala/Short.scala | 2 +- src/library/scala/Unit.scala | 2 +- src/library/scala/annotation/bridge.scala | 2 +- src/library/scala/annotation/cloneable.scala | 2 +- src/library/scala/annotation/elidable.scala | 8 +-- .../scala/annotation/implicitNotFound.scala | 2 +- src/library/scala/annotation/meta/beanGetter.scala | 2 +- src/library/scala/annotation/meta/beanSetter.scala | 2 +- .../scala/annotation/meta/companionClass.scala | 4 +- .../scala/annotation/meta/companionMethod.scala | 4 +- .../scala/annotation/meta/companionObject.scala | 2 +- src/library/scala/annotation/meta/field.scala | 2 +- src/library/scala/annotation/meta/getter.scala | 2 +- .../scala/annotation/meta/languageFeature.scala | 2 +- src/library/scala/annotation/meta/param.scala | 2 +- src/library/scala/annotation/meta/setter.scala | 2 +- src/library/scala/annotation/migration.scala | 4 +- src/library/scala/annotation/serializable.scala | 2 +- src/library/scala/annotation/strictfp.scala | 2 +- src/library/scala/annotation/switch.scala | 2 +- src/library/scala/annotation/tailrec.scala | 2 +- .../annotation/unchecked/uncheckedStable.scala | 2 +- .../annotation/unchecked/uncheckedVariance.scala | 2 +- src/library/scala/annotation/unspecialized.scala | 2 +- src/library/scala/annotation/varargs.scala | 2 +- src/library/scala/beans/BeanDescription.scala | 2 +- src/library/scala/beans/BeanDisplayName.scala | 2 +- src/library/scala/beans/BeanInfo.scala | 2 +- src/library/scala/beans/BeanInfoSkip.scala | 2 +- src/library/scala/beans/BeanProperty.scala | 2 +- src/library/scala/beans/BooleanBeanProperty.scala | 2 +- .../scala/collection/GenTraversableLike.scala | 2 +- .../scala/collection/GenTraversableOnce.scala | 6 +- src/library/scala/collection/IterableLike.scala | 2 +- .../scala/collection/IterableViewLike.scala | 2 +- src/library/scala/collection/Iterator.scala | 6 +- src/library/scala/collection/LinearSeqLike.scala | 2 +- src/library/scala/collection/MapLike.scala | 10 ++-- src/library/scala/collection/SetLike.scala | 2 +- src/library/scala/collection/TraversableLike.scala | 6 +- src/library/scala/collection/TraversableOnce.scala | 16 ++--- .../scala/collection/TraversableProxyLike.scala | 2 +- .../scala/collection/TraversableViewLike.scala | 4 +- .../scala/collection/concurrent/TrieMap.scala | 49 ++++++---------- .../scala/collection/convert/DecorateAsJava.scala | 2 +- .../scala/collection/convert/DecorateAsScala.scala | 2 +- .../scala/collection/convert/WrapAsJava.scala | 4 +- .../scala/collection/convert/WrapAsScala.scala | 2 +- .../scala/collection/convert/Wrappers.scala | 4 +- .../generic/ClassTagTraversableFactory.scala | 4 +- .../scala/collection/generic/GenMapFactory.scala | 2 +- .../scala/collection/generic/GenSeqFactory.scala | 2 +- .../scala/collection/generic/GenSetFactory.scala | 2 +- .../collection/generic/GenTraversableFactory.scala | 2 +- .../generic/GenericClassTagCompanion.scala | 4 +- .../GenericClassTagTraversableTemplate.scala | 6 +- .../collection/generic/GenericCompanion.scala | 2 +- .../generic/GenericOrderedCompanion.scala | 2 +- .../GenericOrderedTraversableTemplate.scala | 4 +- .../collection/generic/GenericParCompanion.scala | 2 +- .../collection/generic/GenericParTemplate.scala | 6 +- .../collection/generic/GenericSeqCompanion.scala | 4 +- .../collection/generic/GenericSetTemplate.scala | 2 +- .../generic/GenericTraversableTemplate.scala | 10 ++-- .../collection/generic/ImmutableMapFactory.scala | 2 +- .../collection/generic/ImmutableSetFactory.scala | 2 +- .../generic/ImmutableSortedMapFactory.scala | 2 +- .../generic/ImmutableSortedSetFactory.scala | 2 +- .../collection/generic/IsTraversableLike.scala | 4 +- .../collection/generic/IsTraversableOnce.scala | 4 +- .../collection/generic/IterableForwarder.scala | 2 +- .../scala/collection/generic/MapFactory.scala | 2 +- .../collection/generic/MutableMapFactory.scala | 2 +- .../collection/generic/MutableSetFactory.scala | 2 +- .../generic/MutableSortedSetFactory.scala | 2 +- .../generic/OrderedTraversableFactory.scala | 2 +- .../scala/collection/generic/ParFactory.scala | 2 +- .../scala/collection/generic/ParMapFactory.scala | 2 +- .../scala/collection/generic/ParSetFactory.scala | 10 ++-- .../scala/collection/generic/SeqFactory.scala | 2 +- .../scala/collection/generic/SetFactory.scala | 4 +- .../collection/generic/SortedMapFactory.scala | 2 +- .../collection/generic/SortedSetFactory.scala | 2 +- .../collection/generic/TraversableFactory.scala | 2 +- .../collection/generic/TraversableForwarder.scala | 2 +- src/library/scala/collection/generic/package.scala | 2 +- .../scala/collection/immutable/HashMap.scala | 18 +++--- .../scala/collection/immutable/HashSet.scala | 4 +- src/library/scala/collection/immutable/List.scala | 4 +- .../scala/collection/immutable/ListMap.scala | 2 +- .../scala/collection/immutable/ListSet.scala | 2 +- src/library/scala/collection/immutable/Map.scala | 2 +- .../scala/collection/immutable/PagedSeq.scala | 2 +- src/library/scala/collection/immutable/Queue.scala | 2 +- src/library/scala/collection/immutable/Range.scala | 12 ++-- .../scala/collection/immutable/RedBlackTree.scala | 4 +- .../scala/collection/immutable/SortedMap.scala | 14 ++--- .../scala/collection/immutable/Stream.scala | 4 +- .../collection/immutable/StreamViewLike.scala | 8 +-- .../scala/collection/immutable/StringLike.scala | 4 +- .../scala/collection/immutable/TrieIterator.scala | 2 +- .../scala/collection/immutable/Vector.scala | 6 +- .../scala/collection/mutable/ArrayBuffer.scala | 4 +- .../scala/collection/mutable/ArrayOps.scala | 4 +- .../scala/collection/mutable/ArrayStack.scala | 2 +- .../scala/collection/mutable/BufferLike.scala | 4 +- .../collection/mutable/DoubleLinkedListLike.scala | 2 +- src/library/scala/collection/mutable/HashMap.scala | 4 +- src/library/scala/collection/mutable/HashSet.scala | 2 +- .../scala/collection/mutable/HashTable.scala | 2 +- .../collection/mutable/ImmutableMapAdaptor.scala | 8 +-- .../scala/collection/mutable/IndexedSeqView.scala | 2 +- .../scala/collection/mutable/LinkedListLike.scala | 2 +- src/library/scala/collection/mutable/Map.scala | 2 +- src/library/scala/collection/mutable/MapLike.scala | 2 +- .../collection/mutable/ObservableBuffer.scala | 6 +- .../scala/collection/mutable/ResizableArray.scala | 4 +- .../scala/collection/mutable/SetBuilder.scala | 2 +- src/library/scala/collection/mutable/SetLike.scala | 2 +- .../scala/collection/mutable/SortedSet.scala | 2 +- src/library/scala/collection/mutable/Stack.scala | 6 +- .../scala/collection/mutable/StringBuilder.scala | 2 +- .../scala/collection/mutable/SynchronizedMap.scala | 8 +-- .../scala/collection/mutable/UnrolledBuffer.scala | 24 ++++---- .../collection/parallel/ParIterableLike.scala | 16 ++--- .../collection/parallel/ParIterableViewLike.scala | 2 +- .../scala/collection/parallel/ParMapLike.scala | 2 +- src/library/scala/collection/parallel/Tasks.scala | 16 ++--- .../collection/parallel/immutable/ParHashMap.scala | 12 ++-- .../collection/parallel/immutable/ParHashSet.scala | 4 +- .../parallel/immutable/ParIterable.scala | 2 +- .../collection/parallel/immutable/ParMap.scala | 6 +- .../collection/parallel/immutable/ParSeq.scala | 2 +- .../collection/parallel/mutable/LazyCombiner.scala | 2 +- .../parallel/mutable/ParFlatHashTable.scala | 6 +- .../collection/parallel/mutable/ParHashMap.scala | 16 ++--- .../collection/parallel/mutable/ParHashSet.scala | 16 ++--- .../collection/parallel/mutable/ParHashTable.scala | 6 +- .../collection/parallel/mutable/ParIterable.scala | 4 +- .../scala/collection/parallel/mutable/ParMap.scala | 14 ++--- .../collection/parallel/mutable/ParMapLike.scala | 16 ++--- .../scala/collection/parallel/mutable/ParSeq.scala | 6 +- .../scala/collection/parallel/mutable/ParSet.scala | 4 +- .../collection/parallel/mutable/ParSetLike.scala | 4 +- .../collection/parallel/mutable/ParTrieMap.scala | 4 +- .../scala/collection/parallel/package.scala | 12 ++-- src/library/scala/concurrent/Future.scala | 16 ++--- .../scala/concurrent/FutureTaskRunner.scala | 2 +- src/library/scala/concurrent/JavaConversions.scala | 2 +- src/library/scala/concurrent/TaskRunner.scala | 2 +- .../scala/concurrent/ThreadPoolRunner.scala | 2 +- src/library/scala/concurrent/ThreadRunner.scala | 2 +- src/library/scala/concurrent/util/Duration.scala | 28 ++++----- .../scala/concurrent/util/duration/package.scala | 2 +- src/library/scala/deprecated.scala | 4 +- src/library/scala/deprecatedInheritance.scala | 2 +- src/library/scala/deprecatedName.scala | 4 +- src/library/scala/deprecatedOverriding.scala | 2 +- src/library/scala/inline.scala | 2 +- src/library/scala/io/Codec.scala | 4 +- src/library/scala/languageFeature.scala | 2 +- src/library/scala/math/BigDecimal.scala | 2 +- src/library/scala/math/BigInt.scala | 2 +- src/library/scala/math/Fractional.scala | 4 +- src/library/scala/math/Integral.scala | 4 +- src/library/scala/math/Numeric.scala | 2 +- src/library/scala/math/Ordered.scala | 2 +- src/library/scala/math/Ordering.scala | 4 +- src/library/scala/native.scala | 2 +- src/library/scala/noinline.scala | 2 +- src/library/scala/reflect/ClassTag.scala | 4 +- src/library/scala/reflect/base/Base.scala | 2 +- src/library/scala/reflect/base/Names.scala | 2 +- src/library/scala/reflect/base/TypeTags.scala | 4 +- .../scala/reflect/macros/internal/macroImpl.scala | 2 +- src/library/scala/remote.scala | 2 +- src/library/scala/runtime/RichException.scala | 2 +- src/library/scala/runtime/ScalaNumberProxy.scala | 2 +- src/library/scala/runtime/ScalaRunTime.scala | 6 +- src/library/scala/runtime/SeqCharSequence.scala | 2 +- src/library/scala/runtime/Tuple2Zipped.scala | 4 +- src/library/scala/runtime/Tuple3Zipped.scala | 4 +- src/library/scala/specialized.scala | 4 +- src/library/scala/sys/BooleanProp.scala | 2 +- src/library/scala/sys/SystemProperties.scala | 2 +- src/library/scala/sys/package.scala | 4 +- src/library/scala/sys/process/Process.scala | 2 +- src/library/scala/sys/process/package.scala | 2 +- src/library/scala/testing/Benchmark.scala | 2 +- src/library/scala/throws.scala | 2 +- src/library/scala/transient.scala | 4 +- src/library/scala/unchecked.scala | 2 +- src/library/scala/util/Either.scala | 2 +- src/library/scala/util/MurmurHash.scala | 2 +- src/library/scala/util/Random.scala | 6 +- src/library/scala/util/Try.scala | 4 +- src/library/scala/util/control/Exception.scala | 10 ++-- src/library/scala/util/hashing/MurmurHash3.scala | 30 +++++----- src/library/scala/util/parsing/ast/Binders.scala | 2 +- .../parsing/combinator/ImplicitConversions.scala | 2 +- .../util/parsing/combinator/JavaTokenParsers.scala | 2 +- .../util/parsing/combinator/PackratParsers.scala | 2 +- .../scala/util/parsing/combinator/Parsers.scala | 4 +- .../util/parsing/combinator/RegexParsers.scala | 2 +- .../syntactical/StandardTokenParsers.scala | 2 +- .../combinator/syntactical/StdTokenParsers.scala | 2 +- .../parsing/combinator/testing/RegexTest.scala | 2 +- .../scala/util/parsing/input/OffsetPosition.scala | 2 +- src/library/scala/volatile.scala | 4 +- src/library/scala/xml/Elem.scala | 2 +- src/library/scala/xml/Equality.scala | 2 +- src/library/scala/xml/MetaData.scala | 2 +- src/library/scala/xml/NodeSeq.scala | 4 +- src/library/scala/xml/Utility.scala | 2 +- src/library/scala/xml/dtd/ContentModel.scala | 6 +- src/library/scala/xml/pull/XMLEventReader.scala | 2 +- .../scala/tools/partest/PartestDefaults.scala | 2 +- src/partest/scala/tools/partest/TestUtil.scala | 2 +- .../scala/tools/partest/nest/FileManager.scala | 2 +- .../scala/tools/partest/nest/SBTRunner.scala | 2 +- src/partest/scala/tools/partest/package.scala | 4 +- src/reflect/scala/reflect/api/Printers.scala | 2 +- .../scala/reflect/internal/BaseTypeSeqs.scala | 4 +- src/reflect/scala/reflect/internal/Chars.scala | 4 +- .../reflect/internal/ClassfileConstants.scala | 2 +- src/reflect/scala/reflect/internal/Constants.scala | 2 +- .../scala/reflect/internal/Definitions.scala | 2 +- src/reflect/scala/reflect/internal/FlagSets.scala | 2 +- src/reflect/scala/reflect/internal/Names.scala | 8 +-- src/reflect/scala/reflect/internal/Printers.scala | 2 +- src/reflect/scala/reflect/internal/StdNames.scala | 4 +- src/reflect/scala/reflect/internal/Trees.scala | 2 +- .../reflect/internal/pickling/UnPickler.scala | 6 +- .../reflect/internal/transform/Transforms.scala | 4 +- .../scala/reflect/internal/util/HashSet.scala | 2 +- .../scala/reflect/internal/util/Position.scala | 8 +-- .../scala/reflect/internal/util/SourceFile.scala | 20 +++---- .../scala/reflect/internal/util/Statistics.scala | 2 +- .../scala/reflect/internal/util/TableDef.scala | 2 +- .../internal/util/TraceSymbolActivity.scala | 6 +- .../scala/reflect/macros/Infrastructure.scala | 4 +- src/reflect/scala/reflect/macros/Reifiers.scala | 6 +- .../scala/reflect/runtime/JavaMirrors.scala | 4 +- .../scala/reflect/runtime/ReflectionUtils.scala | 2 +- .../scala/reflect/runtime/SymbolLoaders.scala | 2 +- .../scala/reflect/runtime/TwoWayCache.scala | 2 +- src/reflect/scala/tools/nsc/io/File.scala | 2 +- src/reflect/scala/tools/nsc/io/Path.scala | 2 +- src/reflect/scala/tools/nsc/io/Streamable.scala | 2 +- src/reflect/scala/tools/nsc/io/ZipArchive.scala | 6 +- src/scalap/scala/tools/scalap/CodeWriter.scala | 2 +- test/files/neg/macro-without-xmacros-a.check | 34 +++++------ test/files/neg/macro-without-xmacros-b.check | 34 +++++------ test/files/neg/t6040.check | 2 +- 395 files changed, 837 insertions(+), 850 deletions(-) (limited to 'test') diff --git a/src/actors-migration/scala/actors/Pattern.scala b/src/actors-migration/scala/actors/Pattern.scala index 26e9d1bb64..fa2db79152 100644 --- a/src/actors-migration/scala/actors/Pattern.scala +++ b/src/actors-migration/scala/actors/Pattern.scala @@ -1,7 +1,7 @@ package scala.actors import scala.concurrent.util.Duration -import language.implicitConversions +import scala.language.implicitConversions object pattern { @@ -23,4 +23,4 @@ class AskableActorRef(val ar: ActorRef) extends ActorRef { def forward(message: Any) = ar.forward(message) private[actors] def localActor: AbstractActor = ar.localActor -} \ No newline at end of file +} diff --git a/src/actors-migration/scala/actors/StashingActor.scala b/src/actors-migration/scala/actors/StashingActor.scala index 8f96e1b002..29f370a3e2 100644 --- a/src/actors-migration/scala/actors/StashingActor.scala +++ b/src/actors-migration/scala/actors/StashingActor.scala @@ -3,7 +3,7 @@ package scala.actors import scala.collection._ import scala.concurrent.util.Duration import java.util.concurrent.TimeUnit -import language.implicitConversions +import scala.language.implicitConversions object StashingActor extends Combinators { implicit def mkBody[A](body: => A) = new InternalActor.Body[A] { diff --git a/src/actors-migration/scala/actors/Timeout.scala b/src/actors-migration/scala/actors/Timeout.scala index 7e400ab140..5540d2880e 100644 --- a/src/actors-migration/scala/actors/Timeout.scala +++ b/src/actors-migration/scala/actors/Timeout.scala @@ -10,7 +10,7 @@ package scala.actors import scala.concurrent.util.Duration import java.util.concurrent.TimeUnit -import language.implicitConversions +import scala.language.implicitConversions case class Timeout(duration: Duration) { def this(timeout: Long) = this(Duration(timeout, TimeUnit.MILLISECONDS)) diff --git a/src/actors/scala/actors/AbstractActor.scala b/src/actors/scala/actors/AbstractActor.scala index dec91859bb..fd11b9a0a8 100644 --- a/src/actors/scala/actors/AbstractActor.scala +++ b/src/actors/scala/actors/AbstractActor.scala @@ -8,7 +8,7 @@ package scala.actors -import language.higherKinds +import scala.language.higherKinds /** * @author Philipp Haller diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 0b1e7fb1e9..8869165062 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -10,7 +10,7 @@ package scala.actors import scala.util.control.ControlThrowable import java.util.{Timer, TimerTask} -import language.implicitConversions +import scala.language.implicitConversions /** * Provides functions for the definition of actors, as well as actor diff --git a/src/actors/scala/actors/CanReply.scala b/src/actors/scala/actors/CanReply.scala index 9bf0022247..92ab23dae1 100644 --- a/src/actors/scala/actors/CanReply.scala +++ b/src/actors/scala/actors/CanReply.scala @@ -8,7 +8,7 @@ package scala.actors -import language.higherKinds +import scala.language.higherKinds /** * Defines result-bearing message send operations. diff --git a/src/actors/scala/actors/Combinators.scala b/src/actors/scala/actors/Combinators.scala index dd704436fc..aef01b67a8 100644 --- a/src/actors/scala/actors/Combinators.scala +++ b/src/actors/scala/actors/Combinators.scala @@ -10,7 +10,7 @@ package scala.actors -import language.implicitConversions +import scala.language.implicitConversions private[actors] trait Combinators { diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index 735c13190b..0198e95ae1 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -174,7 +174,7 @@ object Futures { * or timeout + `System.currentTimeMillis()` is negative. */ def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = { - var resultsMap: collection.mutable.Map[Int, Option[Any]] = new collection.mutable.HashMap[Int, Option[Any]] + var resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new collection.mutable.HashMap[Int, Option[Any]] var cnt = 0 val mappedFts = fts.map(ft => diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala index c962bb9d3d..11c910e577 100644 --- a/src/actors/scala/actors/Reactor.scala +++ b/src/actors/scala/actors/Reactor.scala @@ -12,7 +12,7 @@ package scala.actors import scala.actors.scheduler.{DelegatingScheduler, ExecutorScheduler, ForkJoinScheduler, ThreadPoolConfig} import java.util.concurrent.{ThreadPoolExecutor, TimeUnit, LinkedBlockingQueue} -import language.implicitConversions +import scala.language.implicitConversions private[actors] object Reactor { diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala index a7bf8ec2ba..59f4afccc4 100644 --- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala +++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala @@ -10,7 +10,7 @@ package scala.actors package scheduler -import util.Properties.{ javaVersion, javaVmVendor, isJavaAtLeast, propIsSetTo, propOrNone } +import scala.util.Properties.{ javaVersion, javaVmVendor, isJavaAtLeast, propIsSetTo, propOrNone } /** * @author Erik Engbrecht diff --git a/src/build/InnerObjectTestGen.scala b/src/build/InnerObjectTestGen.scala index 5945bc17c7..b66112609c 100644 --- a/src/build/InnerObjectTestGen.scala +++ b/src/build/InnerObjectTestGen.scala @@ -1,4 +1,4 @@ -import collection.mutable +import scala.collection.mutable /** All contexts where objects can be embedded. */ object Contexts extends Enumeration { diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 83a65e6876..b9511c1ad2 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -import language.postfixOps +import scala.language.postfixOps /** This program generates the ProductN, TupleN, FunctionN, * and AbstractFunctionN, where 0 <= N <= MAX_ARITY. diff --git a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala index 0a8a8d015d..77ac8c6581 100644 --- a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala +++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala @@ -34,7 +34,7 @@ trait Infrastructure { val currentMacro: Symbol = expandee.symbol - val globalCache: collection.mutable.Map[Any, Any] = universe.analyzer.globalMacroCache + val globalCache: scala.collection.mutable.Map[Any, Any] = universe.analyzer.globalMacroCache - val cache: collection.mutable.Map[Any, Any] = universe.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]()) -} \ No newline at end of file + val cache: scala.collection.mutable.Map[Any, Any] = universe.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]()) +} diff --git a/src/compiler/scala/reflect/macros/runtime/Parsers.scala b/src/compiler/scala/reflect/macros/runtime/Parsers.scala index 6d89b71f39..e4acf104e3 100644 --- a/src/compiler/scala/reflect/macros/runtime/Parsers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Parsers.scala @@ -1,7 +1,7 @@ package scala.reflect.macros package runtime -import language.existentials +import scala.language.existentials import scala.tools.reflect.ToolBox import scala.tools.reflect.ToolBoxError @@ -22,4 +22,4 @@ trait Parsers { case class ParseError(val pos: Position, val msg: String) extends Throwable(msg) object ParseError extends ParseErrorExtractor -} \ No newline at end of file +} diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index fab5699da6..a76f147dc4 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -1,6 +1,6 @@ package scala.reflect -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.base.{Universe => BaseUniverse} import scala.reflect.macros.{Context, ReificationError, UnexpectedReificationError} import scala.tools.nsc.Global diff --git a/src/compiler/scala/tools/ant/ClassloadVerify.scala b/src/compiler/scala/tools/ant/ClassloadVerify.scala index 33a20f6894..d1d557b9d3 100644 --- a/src/compiler/scala/tools/ant/ClassloadVerify.scala +++ b/src/compiler/scala/tools/ant/ClassloadVerify.scala @@ -10,7 +10,7 @@ package scala.tools.ant import org.apache.tools.ant.Project import org.apache.tools.ant.types.{Path, Reference} -import collection.JavaConverters._ +import scala.collection.JavaConverters._ import scala.tools.util.VerifyClass class ClassloadVerify extends ScalaMatchingTask { diff --git a/src/compiler/scala/tools/ant/sabbus/Compilers.scala b/src/compiler/scala/tools/ant/sabbus/Compilers.scala index 843ee043ea..bb32149a75 100644 --- a/src/compiler/scala/tools/ant/sabbus/Compilers.scala +++ b/src/compiler/scala/tools/ant/sabbus/Compilers.scala @@ -11,7 +11,7 @@ package scala.tools.ant.sabbus import java.net.URL -object Compilers extends collection.DefaultMap[String, Compiler] { +object Compilers extends scala.collection.DefaultMap[String, Compiler] { val debug = false diff --git a/src/compiler/scala/tools/cmd/Property.scala b/src/compiler/scala/tools/cmd/Property.scala index aae5bebcc8..bde7bb8cb8 100644 --- a/src/compiler/scala/tools/cmd/Property.scala +++ b/src/compiler/scala/tools/cmd/Property.scala @@ -64,7 +64,7 @@ trait Property extends Reference { propertiesToOptions(loadProperties(file)) def propertiesToOptions(props: java.util.Properties): List[String] = { - import collection.JavaConversions._ + import scala.collection.JavaConversions._ propertiesToOptions(props.toList) } def propertiesToOptions(props: List[(String, String)]) = props flatMap propMapper diff --git a/src/compiler/scala/tools/cmd/Reference.scala b/src/compiler/scala/tools/cmd/Reference.scala index 77fe01051e..b6c564e9fb 100644 --- a/src/compiler/scala/tools/cmd/Reference.scala +++ b/src/compiler/scala/tools/cmd/Reference.scala @@ -6,7 +6,7 @@ package scala.tools package cmd -import collection.mutable.ListBuffer +import scala.collection.mutable.ListBuffer import nsc.Properties.envOrNone /** Mixes in the specification trait and uses the vals therein to diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 7842603af7..910804245b 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -14,7 +14,7 @@ trait AnyValReps { sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { case class Op(val op : String, val doc : String) - + private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => """implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name) @@ -24,7 +24,7 @@ trait AnyValReps { def coercionComment = """ /** Language mandated coercions from @name@ to "wider" types.%s */""".format(coercionCommentExtra) - + def implicitCoercions: List[String] = { val coercions = this match { case B => companionCoercions(S, I, L, F, D) @@ -247,7 +247,7 @@ trait AnyValReps { def classDoc = interpolate(classDocTemplate) def objectDoc = "" def mkImports = "" - + def mkClass = assemble("final abstract class " + name + " private extends AnyVal", classLines) def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines) def make() = List[String]( @@ -281,7 +281,7 @@ trait AnyValTemplates { %s package scala -import language.implicitConversions +import scala.language.implicitConversions """.trim.format(timestampString) + "\n\n") diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala index b94c640f1c..ff3d41c8b7 100644 --- a/src/compiler/scala/tools/cmd/gen/Codegen.scala +++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala @@ -6,7 +6,7 @@ package scala.tools.cmd package gen -import language.postfixOps +import scala.language.postfixOps class Codegen(args: List[String]) extends { val parsed = CodegenSpec(args: _*) diff --git a/src/compiler/scala/tools/nsc/EvalLoop.scala b/src/compiler/scala/tools/nsc/EvalLoop.scala index da03419d8a..bd1381faf5 100644 --- a/src/compiler/scala/tools/nsc/EvalLoop.scala +++ b/src/compiler/scala/tools/nsc/EvalLoop.scala @@ -5,7 +5,7 @@ package scala.tools.nsc -import annotation.tailrec +import scala.annotation.tailrec import java.io.EOFException trait EvalLoop { diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 9e3f47e8fb..6fb6b1736b 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -7,7 +7,7 @@ package scala.tools.nsc import java.io.{ File, FileOutputStream, PrintWriter, IOException, FileNotFoundException } import java.nio.charset.{ Charset, CharsetDecoder, IllegalCharsetNameException, UnsupportedCharsetException } -import compat.Platform.currentTime +import scala.compat.Platform.currentTime import scala.tools.util.PathResolver import scala.collection.{ mutable, immutable } import io.{ SourceReader, AbstractFile, Path } @@ -29,8 +29,8 @@ import backend.{ ScalaPrimitives, Platform, MSILPlatform, JavaPlatform } import backend.jvm.{GenJVM, GenASM} import backend.opt.{ Inliners, InlineExceptionHandlers, ClosureElimination, DeadCodeElimination } import backend.icode.analysis._ -import language.postfixOps -import reflect.internal.StdAttachments +import scala.language.postfixOps +import scala.reflect.internal.StdAttachments import scala.reflect.ClassTag class Global(var currentSettings: Settings, var reporter: Reporter) @@ -940,7 +940,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) reSync(RootClass, Some(classPath), Some(oldEntries), Some(newEntries), invalidated, failed) } } - def show(msg: String, syms: collection.Traversable[Symbol]) = + def show(msg: String, syms: scala.collection.Traversable[Symbol]) = if (syms.nonEmpty) informProgress(s"$msg: ${syms map (_.fullName) mkString ","}") show("invalidated packages", invalidated) diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index e69382be21..46cdc6a4a0 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -8,7 +8,7 @@ package scala.tools.nsc import java.io.{ BufferedWriter, FileWriter } import scala.collection.mutable -import language.postfixOps +import scala.language.postfixOps /** * PhaseAssembly diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala index d2274b108b..c80be474a6 100644 --- a/src/compiler/scala/tools/nsc/Phases.scala +++ b/src/compiler/scala/tools/nsc/Phases.scala @@ -6,8 +6,8 @@ package scala.tools.nsc import symtab.Flags -import reflect.internal.util.TableDef -import language.postfixOps +import scala.reflect.internal.util.TableDef +import scala.language.postfixOps object Phases { val MaxPhases = 64 diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala index 0b54eda66d..d1faa4d219 100644 --- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala @@ -6,9 +6,9 @@ package scala.tools.nsc package ast -import compat.Platform.EOL +import scala.compat.Platform.EOL import symtab.Flags._ -import language.postfixOps +import scala.language.postfixOps /** The object `nodePrinter` converts the internal tree * representation to a string. diff --git a/src/compiler/scala/tools/nsc/ast/Printers.scala b/src/compiler/scala/tools/nsc/ast/Printers.scala index 885fc3f518..3392b78595 100644 --- a/src/compiler/scala/tools/nsc/ast/Printers.scala +++ b/src/compiler/scala/tools/nsc/ast/Printers.scala @@ -10,7 +10,7 @@ import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } import symtab.Flags._ import symtab.SymbolTable -trait Printers extends reflect.internal.Printers { this: Global => +trait Printers extends scala.reflect.internal.Printers { this: Global => import treeInfo.{ IsTrue, IsFalse } diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 043834ae55..267a5dcefd 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -18,7 +18,7 @@ import scala.concurrent.Lock import scala.text._ import symtab.Flags._ import symtab.SymbolTable -import language.implicitConversions +import scala.language.implicitConversions /** * Tree browsers can show the AST in a graphical and interactive diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index e90d779885..01bd0bbb06 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -9,7 +9,7 @@ package ast import PartialFunction._ import symtab.Flags -import language.implicitConversions +import scala.language.implicitConversions /** A DSL for generating scala code. The goal is that the * code generating code should look a lot like the code it diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index b22681e52b..fc8228f644 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -9,12 +9,12 @@ package ast import scala.collection.mutable.ListBuffer import symtab.Flags._ import symtab.SymbolTable -import language.postfixOps +import scala.language.postfixOps /** XXX to resolve: TreeGen only assumes global is a SymbolTable, but * TreeDSL at the moment expects a Global. Can we get by with SymbolTable? */ -abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { +abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL { val global: Global import global._ diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index e755553e25..9e46155d14 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -6,8 +6,8 @@ package scala.tools.nsc package ast -import reflect.internal.HasFlags -import reflect.internal.Flags._ +import scala.reflect.internal.HasFlags +import scala.reflect.internal.Flags._ import symtab._ /** This class ... @@ -15,7 +15,7 @@ import symtab._ * @author Martin Odersky * @version 1.0 */ -abstract class TreeInfo extends reflect.internal.TreeInfo { +abstract class TreeInfo extends scala.reflect.internal.TreeInfo { val global: Global import global._ diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index bd5c9b2f68..4e643e6f32 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -15,7 +15,7 @@ import scala.reflect.internal.Flags.PRESUPER import scala.reflect.internal.Flags.TRAIT import scala.compat.Platform.EOL -trait Trees extends reflect.internal.Trees { self: Global => +trait Trees extends scala.reflect.internal.Trees { self: Global => def treeLine(t: Tree): String = if (t.pos.isDefined && t.pos.isRange) t.pos.lineContent.drop(t.pos.column - 1).take(t.pos.end - t.pos.start + 1) diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index 146329183c..9466b7222d 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -7,11 +7,11 @@ package scala.tools.nsc package ast.parser import scala.collection.{ mutable, immutable } -import xml.{ EntityRef, Text } -import xml.XML.{ xmlns } +import scala.xml.{ EntityRef, Text } +import scala.xml.XML.{ xmlns } import symtab.Flags.MUTABLE import scala.reflect.internal.util.StringOps.splitWhere -import language.implicitConversions +import scala.language.implicitConversions /** This class builds instance of `Tree` that represent XML. * @@ -144,7 +144,7 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { (buf map convertToTextPat).toList def parseAttribute(pos: Position, s: String): Tree = { - val ts = xml.Utility.parseAttributeValue(s) map { + val ts = scala.xml.Utility.parseAttributeValue(s) map { case Text(s) => text(pos, s) case EntityRef(s) => entityRef(pos, s) } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index 7e7972f9dd..9ce74b2b17 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package ast.parser -import annotation.switch +import scala.annotation.switch /** Common code between JavaTokens and Tokens. Not as much (and not as concrete) * as one might like because JavaTokens for no clear reason chose new numbers for diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 486a43614b..06492e4ac6 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -11,7 +11,7 @@ import scala.collection.{ mutable, immutable } import mutable.{ ListBuffer, ArrayBuffer } import scala.reflect.internal.util.{ Position, NoPosition } import backend.icode.analysis.ProgramPoint -import language.postfixOps +import scala.language.postfixOps trait BasicBlocks { self: ICodes => diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 24662e2ac3..bab658e141 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -13,7 +13,7 @@ import scala.collection.mutable.{ ListBuffer, Buffer } import scala.tools.nsc.symtab._ import scala.annotation.switch import PartialFunction._ -import language.postfixOps +import scala.language.postfixOps /** This class ... * diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala index 1c5c9224f2..4739750daa 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala @@ -231,7 +231,7 @@ trait Linearizers { val handlersByCovered = m.exh.groupBy(_.covered) // number of basic blocks covered by the entire try-catch expression - def size(covered: collection.immutable.Set[BasicBlock]) = { + def size(covered: scala.collection.immutable.Set[BasicBlock]) = { val hs = handlersByCovered(covered) covered.size + (hs :\ 0)((h, s) => h.blocks.length + s) } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 6bd3ac5791..31c2077097 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -640,7 +640,7 @@ abstract class TypeFlowAnalysis { For each of them, its `lastInstruction` (after which no more typeflows are needed) is found. */ - def reinit(m: icodes.IMethod, staleOut: List[BasicBlock], inlined: collection.Set[BasicBlock], staleIn: collection.Set[BasicBlock]) { + def reinit(m: icodes.IMethod, staleOut: List[BasicBlock], inlined: scala.collection.Set[BasicBlock], staleIn: scala.collection.Set[BasicBlock]) { if (this.method == null || this.method.symbol != m.symbol) { init(m) return @@ -691,7 +691,7 @@ abstract class TypeFlowAnalysis { bs foreach enqueue } - private def blankOut(blocks: collection.Set[BasicBlock]) { + private def blankOut(blocks: scala.collection.Set[BasicBlock]) { blocks foreach { b => in(b) = typeFlowLattice.bottom out(b) = typeFlowLattice.bottom diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala index 485864d8e3..ef3e82a75a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala @@ -12,7 +12,7 @@ import scala.tools.nsc.util.ScalaClassLoader import scala.tools.util.JavapClass import java.util.jar.{ JarEntry, JarOutputStream, Attributes } import Attributes.Name -import language.postfixOps +import scala.language.postfixOps /** For the last mile: turning generated bytecode in memory into * something you can use. Has implementations for writing to class diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index ea0a0148e4..1653ca9c2a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -2044,12 +2044,12 @@ abstract class GenASM extends SubComponent with BytecodeWriters { var isModuleInitialized = false - val labels: collection.Map[BasicBlock, asm.Label] = mutable.HashMap(linearization map (_ -> new asm.Label()) : _*) + val labels: scala.collection.Map[BasicBlock, asm.Label] = mutable.HashMap(linearization map (_ -> new asm.Label()) : _*) val onePastLast = new asm.Label // token for the mythical instruction past the last instruction in the method being emitted // maps a BasicBlock b to the Label that corresponds to b's successor in the linearization. The last BasicBlock is mapped to the onePastLast label. - val linNext: collection.Map[BasicBlock, asm.Label] = { + val linNext: scala.collection.Map[BasicBlock, asm.Label] = { val result = mutable.HashMap.empty[BasicBlock, asm.Label] var rest = linearization var prev = rest.head @@ -2227,7 +2227,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } } - def getMerged(): collection.Map[Local, List[Interval]] = { + def getMerged(): scala.collection.Map[Local, List[Interval]] = { // TODO should but isn't: unbalanced start(s) of scope(s) val shouldBeEmpty = pending filter { p => val Pair(k, st) = p; st.nonEmpty }; val merged = mutable.Map[Local, List[Interval]]() @@ -2412,7 +2412,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { import asm.Opcodes (instr.category: @scala.annotation.switch) match { - case icodes.localsCat => + case icodes.localsCat => def genLocalInstr = (instr: @unchecked) match { case THIS(_) => jmethod.visitVarInsn(Opcodes.ALOAD, 0) case LOAD_LOCAL(local) => jcode.load(indexOf(local), local.kind) @@ -2445,7 +2445,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genLocalInstr - case icodes.stackCat => + case icodes.stackCat => def genStackInstr = (instr: @unchecked) match { case LOAD_MODULE(module) => @@ -2473,7 +2473,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { case icodes.arilogCat => genPrimitive(instr.asInstanceOf[CALL_PRIMITIVE].primitive, instr.pos) - case icodes.castsCat => + case icodes.castsCat => def genCastInstr = (instr: @unchecked) match { case IS_INSTANCE(tpe) => @@ -2503,7 +2503,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genCastInstr - case icodes.objsCat => + case icodes.objsCat => def genObjsInstr = (instr: @unchecked) match { case BOX(kind) => @@ -2523,7 +2523,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genObjsInstr - case icodes.fldsCat => + case icodes.fldsCat => def genFldsInstr = (instr: @unchecked) match { case lf @ LOAD_FIELD(field, isStatic) => @@ -2544,7 +2544,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genFldsInstr - case icodes.mthdsCat => + case icodes.mthdsCat => def genMethodsInstr = (instr: @unchecked) match { /** Special handling to access native Array.clone() */ @@ -2557,7 +2557,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genMethodsInstr - case icodes.arraysCat => + case icodes.arraysCat => def genArraysInstr = (instr: @unchecked) match { case LOAD_ARRAY_ITEM(kind) => jcode.aload(kind) case STORE_ARRAY_ITEM(kind) => jcode.astore(kind) @@ -2566,7 +2566,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genArraysInstr - case icodes.jumpsCat => + case icodes.jumpsCat => def genJumpInstr = (instr: @unchecked) match { case sw @ SWITCH(tagss, branches) => @@ -2696,7 +2696,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genJumpInstr - case icodes.retCat => + case icodes.retCat => def genRetInstr = (instr: @unchecked) match { case RETURN(kind) => jcode emitRETURN kind case THROW(_) => emit(Opcodes.ATHROW) @@ -2816,9 +2816,9 @@ abstract class GenASM extends SubComponent with BytecodeWriters { // TODO Logical's 2nd elem should be declared ValueTypeKind, to better approximate its allowed values (isIntSized, its comments appears to convey) // TODO GenICode uses `toTypeKind` to define that elem, `toValueTypeKind` would be needed instead. // TODO How about adding some asserts to Logical and similar ones to capture the remaining constraint (UNIT not allowed). - case Logical(op, kind) => + case Logical(op, kind) => def genLogical = op match { - case AND => + case AND => kind match { case LONG => emit(Opcodes.LAND) case INT => emit(Opcodes.IAND) @@ -2844,8 +2844,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } } genLogical - - case Shift(op, kind) => + + case Shift(op, kind) => def genShift = op match { case LSL => kind match { @@ -2874,7 +2874,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } genShift - case Comparison(op, kind) => + case Comparison(op, kind) => def genCompare = op match { case CMP => (kind: @unchecked) match { @@ -2889,7 +2889,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { (kind: @unchecked) match { case FLOAT => emit(Opcodes.FCMPG) case DOUBLE => emit(Opcodes.DCMPL) // TODO bug? why not DCMPG? http://docs.oracle.com/javase/specs/jvms/se5.0/html/Instructions2.doc3.html - + } } genCompare diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 0f64a55d70..a2151633a7 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -18,7 +18,7 @@ import JAccessFlags._ import JObjectType.{ JAVA_LANG_STRING, JAVA_LANG_OBJECT } import java.util.jar.{ JarEntry, JarOutputStream } import scala.tools.nsc.io.AbstractFile -import language.postfixOps +import scala.language.postfixOps /** This class ... * diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 465a0c61e8..f56aa74d53 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -15,7 +15,7 @@ import scala.tools.nsc.symtab._ import ch.epfl.lamp.compiler.msil.{Type => MsilType, _} import ch.epfl.lamp.compiler.msil.emit._ import ch.epfl.lamp.compiler.msil.util.PECustomMod -import language.postfixOps +import scala.language.postfixOps abstract class GenMSIL extends SubComponent { import global._ diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 62bb23c3a7..e9fb060dda 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -746,7 +746,7 @@ abstract class Inliners extends SubComponent { toBecomePublic: List[Symbol] ) - final class CallerCalleeInfo(val caller: IMethodInfo, val inc: IMethodInfo, fresh: mutable.Map[String, Int], inlinedMethodCount: collection.Map[Symbol, Int]) { + final class CallerCalleeInfo(val caller: IMethodInfo, val inc: IMethodInfo, fresh: mutable.Map[String, Int], inlinedMethodCount: scala.collection.Map[Symbol, Int]) { assert(!caller.isBridge && inc.m.hasCode, "A guard in Inliner.analyzeClass() should have prevented from getting here.") diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index 176c00c025..7f5f412a20 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -3,7 +3,7 @@ package dependencies import symtab.Flags -import collection._ +import scala.collection._ /** A component that describes the possible changes between successive * compilations of a class. diff --git a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala index 317cc28298..cdde768274 100644 --- a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala +++ b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala @@ -2,7 +2,7 @@ package scala.tools.nsc package dependencies import io.Path -import collection._ +import scala.collection._ import symtab.Flags import scala.tools.nsc.io.AbstractFile import scala.reflect.internal.util.SourceFile diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 60cd375175..f5df772d7d 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -8,7 +8,7 @@ package doc import java.io.File import java.lang.System -import language.postfixOps +import scala.language.postfixOps /** An extended version of compiler settings, with additional Scaladoc-specific options. * @param error A function that prints a string to the appropriate error stream diff --git a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala index 7e57f9fd9f..812b62a1c6 100644 --- a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala +++ b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala @@ -5,8 +5,8 @@ package scala.tools.nsc package doc -import language.implicitConversions -import language.postfixOps +import scala.language.implicitConversions +import scala.language.postfixOps /** Some glue between DocParser (which reads source files which can't be compiled) * and the scaladoc model. diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala index 7a74c569f3..f7c5611b8a 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala @@ -10,8 +10,8 @@ package html import model._ import comment._ -import xml.{XML, NodeSeq} -import xml.dtd.{DocType, PublicID} +import scala.xml.{XML, NodeSeq} +import scala.xml.dtd.{DocType, PublicID} import scala.collection._ import java.io.Writer @@ -87,7 +87,7 @@ abstract class HtmlPage extends Page { thisPage => case Title(in, _) =>
{ inlineToHtml(in) }
case Paragraph(in) =>

{ inlineToHtml(in) }

case Code(data) => -
{ SyntaxHigh(data) }
//
{ xml.Text(data) }
+
{ SyntaxHigh(data) }
//
{ scala.xml.Text(data) }
case UnorderedList(items) =>
    { listItemsToHtml(items) }
case OrderedList(items, listStyle) => @@ -119,9 +119,9 @@ abstract class HtmlPage extends Page { thisPage => case Subscript(in) => { inlineToHtml(in) } case Link(raw, title) => { inlineToHtml(title) } case Monospace(in) => { inlineToHtml(in) } - case Text(text) => xml.Text(text) + case Text(text) => scala.xml.Text(text) case Summary(in) => inlineToHtml(in) - case HtmlTag(tag) => xml.Unparsed(tag) + case HtmlTag(tag) => scala.xml.Unparsed(tag) case EntityLink(target, link) => linkToHtml(target, link, true) } @@ -158,11 +158,11 @@ abstract class HtmlPage extends Page { thisPage => if (starts.isEmpty && (inPos == string.length)) NodeSeq.Empty else if (starts.isEmpty) - xml.Text(string.slice(inPos, string.length)) + scala.xml.Text(string.slice(inPos, string.length)) else if (inPos == starts.head) toLinksIn(inPos, starts) else { - xml.Text(string.slice(inPos, starts.head)) ++ toLinksIn(starts.head, starts) + scala.xml.Text(string.slice(inPos, starts.head)) ++ toLinksIn(starts.head, starts) } } def toLinksIn(inPos: Int, starts: List[Int]): NodeSeq = { @@ -173,7 +173,7 @@ abstract class HtmlPage extends Page { thisPage => if (hasLinks) toLinksOut(0, tpe.refEntity.keySet.toList) else - xml.Text(string) + scala.xml.Text(string) } def typesToHtml(tpess: List[model.TypeEntity], hasLinks: Boolean, sep: NodeSeq): NodeSeq = tpess match { @@ -192,10 +192,10 @@ abstract class HtmlPage extends Page { thisPage => if (hasPage(dTpl)) { { if (name eq null) dTpl.name else name } } else { - xml.Text(if (name eq null) dTpl.name else name) + scala.xml.Text(if (name eq null) dTpl.name else name) } case ndTpl: NoDocTemplate => - xml.Text(if (name eq null) ndTpl.name else name) + scala.xml.Text(if (name eq null) ndTpl.name else name) } /** Returns the HTML code that represents the templates in `tpls` as a list of hyperlinked names. */ diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala index 9b0765e394..e21ee07963 100644 --- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -5,7 +5,7 @@ package scala.tools.nsc.doc.html -import xml.NodeSeq +import scala.xml.NodeSeq /** Highlight the syntax of Scala code appearing in a `{{{` wiki block * (see method `HtmlPage.blockToHtml`). @@ -281,6 +281,6 @@ private[html] object SyntaxHigh { } parse("", 0) - xml.Unparsed(out.toString) + scala.xml.Unparsed(out.toString) } } diff --git a/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala b/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala index 6d83b4e6a5..cd76f84a37 100755 --- a/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala @@ -44,7 +44,7 @@ class ReferenceIndex(letter: Char, index: doc.Index, universe: Universe) extends { name } }
{ - for (owner <- occurrences) yield owner ++ xml.Text(" ") + for (owner <- occurrences) yield owner ++ scala.xml.Text(" ") }
} diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Source.scala b/src/compiler/scala/tools/nsc/doc/html/page/Source.scala index a51d66c6cc..edc0736400 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Source.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Source.scala @@ -10,7 +10,7 @@ package page import model._ import comment._ -import xml.{NodeSeq, Unparsed} +import scala.xml.{NodeSeq, Unparsed} import java.io.File class Source(sourceFile: File) extends HtmlPage { diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 24a26b2ad3..d4e52ba120 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -13,7 +13,7 @@ import model.diagram._ import diagram._ import scala.xml.{ NodeSeq, Text, UnprefixedAttribute } -import language.postfixOps +import scala.language.postfixOps import model._ import model.diagram._ @@ -51,7 +51,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp var hash = '{ val p = templateToPath(tpl); (p.tail.reverse ::: List(p.head.replace(".html", ""))).mkString(".") }'; var anchor = window.location.hash; var anchor_opt = ''; - if (anchor.length { scala.xml.Unparsed(">=") /* unless we use Unparsed, it gets escaped and crashes the script */ } 1) + if (anchor.length { scala.xml.Unparsed(">=") /* unless we use Unparsed, it gets escaped and crashes the script */ } 1) anchor_opt = '@' + anchor.substring(1); window.location.href = url + '#' + hash + anchor_opt; }} @@ -93,7 +93,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if (tpl.isRootPackage || tpl.inTemplate.isRootPackage) NodeSeq.Empty else -

{ templatesToHtml(tpl.inTemplate.toRoot.reverse.tail, xml.Text(".")) }

+

{ templatesToHtml(tpl.inTemplate.toRoot.reverse.tail, scala.xml.Text(".")) }

} @@ -152,7 +152,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
Implicitly
-
    { +
      { tpl.conversions.map { conv => val name = conv.conversionQualifiedName val hide = universe.settings.hiddenImplicits(name) @@ -415,14 +415,14 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case Nil => NodeSeq.Empty case List(constraint) => - xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint) ++ xml.Text(".") + scala.xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint) ++ scala.xml.Text(".") case List(constraint1, constraint2) => - xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint1) ++ - xml.Text(" and at the same time ") ++ constraintToHtml(constraint2) ++ xml.Text(".") + scala.xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint1) ++ + scala.xml.Text(" and at the same time ") ++ constraintToHtml(constraint2) ++ scala.xml.Text(".") case constraints =>
      ++ "This conversion will take place only if all of the following constraints are met:" ++
      ++ { var index = 0 - constraints map { constraint => xml.Text({ index += 1; index } + ". ") ++ constraintToHtml(constraint) ++
      } + constraints map { constraint => scala.xml.Text({ index += 1; index } + ". ") ++ constraintToHtml(constraint) ++
      } } } @@ -440,18 +440,18 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case d: Def => d.valueParams map (_ map (_ name) mkString("(", ", ", ")")) mkString case _ => "" // no parameters } -
      ++ xml.Text("To access this member you can use a ") ++ +
      ++ scala.xml.Text("To access this member you can use a ") ++ type ascription ++ xml.Text(":") ++ + target="_blank">type ascription ++ scala.xml.Text(":") ++
      ++
      {"(" + Template.lowerFirstLetter(tpl.name) + ": " + conv.targetType.name + ")." + mbr.name + params }
      } val shadowingWarning: NodeSeq = if (mbr.isShadowedImplicit) - xml.Text("This implicitly inherited member is shadowed by one or more members in this " + + scala.xml.Text("This implicitly inherited member is shadowed by one or more members in this " + "class.") ++ shadowingSuggestion else if (mbr.isAmbiguousImplicit) - xml.Text("This implicitly inherited member is ambiguous. One or more implicitly " + + scala.xml.Text("This implicitly inherited member is ambiguous. One or more implicitly " + "inherited members have similar signatures, so calling this member may produce an ambiguous " + "implicit conversion compiler error.") ++ shadowingSuggestion else NodeSeq.Empty @@ -471,7 +471,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if (fvs.isEmpty || isReduced) NodeSeq.Empty else {
      Attributes
      -
      { fvs map { fv => { inlineToHtml(fv.text) ++ xml.Text(" ") } } }
      +
      { fvs map { fv => { inlineToHtml(fv.text) ++ scala.xml.Text(" ") } } }
      } } @@ -480,7 +480,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if ((inDefTpls.tail.isEmpty && (inDefTpls.head == inTpl)) || isReduced) NodeSeq.Empty else {
      Definition Classes
      -
      { templatesToHtml(inDefTpls, xml.Text(" → ")) }
      +
      { templatesToHtml(inDefTpls, scala.xml.Text(" → ")) }
      } } @@ -628,7 +628,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
      Linear Supertypes
      { - typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) + typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = scala.xml.Text(", ")) }
      case _ => NodeSeq.Empty @@ -639,7 +639,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
      Known Subclasses
      { - templatesToHtml(dtpl.allSubClasses.sortBy(_.name), xml.Text(", ")) + templatesToHtml(dtpl.allSubClasses.sortBy(_.name), scala.xml.Text(", ")) }
      case _ => NodeSeq.Empty @@ -663,7 +663,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp def boundsToHtml(hi: Option[TypeEntity], lo: Option[TypeEntity], hasLinks: Boolean): NodeSeq = { def bound0(bnd: Option[TypeEntity], pre: String): NodeSeq = bnd match { case None => NodeSeq.Empty - case Some(tpe) => xml.Text(pre) ++ typeToHtml(tpe, hasLinks) + case Some(tpe) => scala.xml.Text(pre) ++ typeToHtml(tpe, hasLinks) } bound0(lo, " >: ") ++ bound0(hi, " <: ") } @@ -694,7 +694,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp def inside(hasLinks: Boolean, nameLink: String = ""): NodeSeq = - { mbr.flags.map(flag => inlineToHtml(flag.text) ++ xml.Text(" ")) } + { mbr.flags.map(flag => inlineToHtml(flag.text) ++ scala.xml.Text(" ")) } { kindToString(mbr) } @@ -872,7 +872,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp def argumentsToHtml0(argss: List[ValueArgument]): NodeSeq = argss match { case Nil => NodeSeq.Empty case arg :: Nil => argumentToHtml(arg) - case arg :: args => argumentToHtml(arg) ++ xml.Text(", ") ++ argumentsToHtml0(args) + case arg :: args => argumentToHtml(arg) ++ scala.xml.Text(", ") ++ argumentsToHtml0(args) } ({ argumentsToHtml0(argss) }) } @@ -922,29 +922,29 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp private def constraintToHtml(constraint: Constraint): NodeSeq = constraint match { case ktcc: KnownTypeClassConstraint => - xml.Text(ktcc.typeExplanation(ktcc.typeParamName) + " (" + ktcc.typeParamName + ": ") ++ - templateToHtml(ktcc.typeClassEntity) ++ xml.Text(")") + scala.xml.Text(ktcc.typeExplanation(ktcc.typeParamName) + " (" + ktcc.typeParamName + ": ") ++ + templateToHtml(ktcc.typeClassEntity) ++ scala.xml.Text(")") case tcc: TypeClassConstraint => - xml.Text(tcc.typeParamName + " is ") ++ + scala.xml.Text(tcc.typeParamName + " is ") ++ - context-bounded ++ xml.Text(" by " + tcc.typeClassEntity.qualifiedName + " (" + tcc.typeParamName + ": ") ++ - templateToHtml(tcc.typeClassEntity) ++ xml.Text(")") + context-bounded ++ scala.xml.Text(" by " + tcc.typeClassEntity.qualifiedName + " (" + tcc.typeParamName + ": ") ++ + templateToHtml(tcc.typeClassEntity) ++ scala.xml.Text(")") case impl: ImplicitInScopeConstraint => - xml.Text("an implicit value of type ") ++ typeToHtml(impl.implicitType, true) ++ xml.Text(" is in scope") + scala.xml.Text("an implicit value of type ") ++ typeToHtml(impl.implicitType, true) ++ scala.xml.Text(" is in scope") case eq: EqualTypeParamConstraint => - xml.Text(eq.typeParamName + " is " + eq.rhs.name + " (" + eq.typeParamName + " =:= ") ++ - typeToHtml(eq.rhs, true) ++ xml.Text(")") + scala.xml.Text(eq.typeParamName + " is " + eq.rhs.name + " (" + eq.typeParamName + " =:= ") ++ + typeToHtml(eq.rhs, true) ++ scala.xml.Text(")") case bt: BoundedTypeParamConstraint => - xml.Text(bt.typeParamName + " is a superclass of " + bt.lowerBound.name + " and a subclass of " + + scala.xml.Text(bt.typeParamName + " is a superclass of " + bt.lowerBound.name + " and a subclass of " + bt.upperBound.name + " (" + bt.typeParamName + " >: ") ++ - typeToHtml(bt.lowerBound, true) ++ xml.Text(" <: ") ++ - typeToHtml(bt.upperBound, true) ++ xml.Text(")") + typeToHtml(bt.lowerBound, true) ++ scala.xml.Text(" <: ") ++ + typeToHtml(bt.upperBound, true) ++ scala.xml.Text(")") case lb: LowerBoundedTypeParamConstraint => - xml.Text(lb.typeParamName + " is a superclass of " + lb.lowerBound.name + " (" + lb.typeParamName + " >: ") ++ - typeToHtml(lb.lowerBound, true) ++ xml.Text(")") + scala.xml.Text(lb.typeParamName + " is a superclass of " + lb.lowerBound.name + " (" + lb.typeParamName + " >: ") ++ + typeToHtml(lb.lowerBound, true) ++ scala.xml.Text(")") case ub: UpperBoundedTypeParamConstraint => - xml.Text(ub.typeParamName + " is a subclass of " + ub.upperBound.name + " (" + ub.typeParamName + " <: ") ++ - typeToHtml(ub.upperBound, true) ++ xml.Text(")") + scala.xml.Text(ub.typeParamName + " is a subclass of " + ub.upperBound.name + " (" + ub.typeParamName + " <: ") ++ + typeToHtml(ub.upperBound, true) ++ scala.xml.Text(")") } def makeDiagramHtml(tpl: DocTemplateEntity, diagram: Option[Diagram], description: String, id: String) = { diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index c46c33c1ee..304c534bdc 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -426,7 +426,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { else if (klass.contains("object")) "object" else "" - def getPosition(g: xml.Node, axis: String, offset: Double): Option[Double] = { + def getPosition(g: scala.xml.Node, axis: String, offset: Double): Option[Double] = { val node = g \ "a" \ "text" \ ("@" + axis) if (node.isEmpty) None @@ -508,4 +508,4 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { private val graphAttributesStr = graphAttributes.map{ case (key, value) => key + "=\"" + value + "\";\n" }.mkString private val nodeAttributesStr = flatten(nodeAttributes) private val edgeAttributesStr = flatten(edgeAttributes) -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index ed8541f692..002cf0c5e8 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -154,7 +154,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { if (!sym.isTrait && (sym hasFlag Flags.ABSTRACT)) fgs += Paragraph(Text("abstract")) /* Resetting the DEFERRED flag is a little trick here for refined types: (example from scala.collections) * {{{ - * implicit def traversable2ops[T](t: collection.GenTraversableOnce[T]) = new TraversableOps[T] { + * implicit def traversable2ops[T](t: scala.collection.GenTraversableOnce[T]) = new TraversableOps[T] { * def isParallel = ... * }}} * the type the method returns is TraversableOps, which has all-abstract symbols. But in reality, it couldn't have diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala index 59cdf05957..47eea52095 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala @@ -13,7 +13,7 @@ import scala.collection._ import scala.util.matching.Regex import scala.annotation.switch import scala.reflect.internal.util.{NoPosition, Position} -import language.postfixOps +import scala.language.postfixOps /** The comment parser transforms raw comment strings into `Comment` objects. * Call `parse` to run the parser. Note that the parser is stateless and diff --git a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala index 2645d8fd14..fa698afaa6 100644 --- a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala @@ -4,7 +4,7 @@ package diagram import model._ import comment.CommentFactory -import collection.mutable +import scala.collection.mutable // statistics import html.page.diagram.DiagramStats diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala index e31c5eda31..7067daec26 100644 --- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala @@ -13,7 +13,7 @@ import scala.reflect.internal.util.FakePos import dependencies._ import io.AbstractFile -import language.implicitConversions +import scala.language.implicitConversions trait BuildManager { diff --git a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala index 4a60211254..a906d1454c 100644 --- a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala +++ b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala @@ -5,7 +5,7 @@ package scala.tools.nsc package interactive -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer import scala.reflect.internal.util.Position trait ContextTrees { self: Global => diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index cb2e7d641b..5514983d98 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -20,7 +20,7 @@ import scala.tools.nsc.io.Pickler._ import scala.tools.nsc.typechecker.DivergentImplicit import scala.annotation.tailrec import symtab.Flags.{ACCESSOR, PARAMACCESSOR} -import language.implicitConversions +import scala.language.implicitConversions /** The main class of the presentation compiler in an interactive environment such as an IDE */ diff --git a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala index f57786578a..104a69897d 100644 --- a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala +++ b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala @@ -5,7 +5,7 @@ package scala.tools.nsc package interactive -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer import scala.reflect.internal.util.Position import reporters.Reporter diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala index f4ec03bb47..8ed7a67058 100644 --- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala +++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala @@ -13,7 +13,7 @@ import util.EmptyAction import scala.reflect.internal.util.{Position, RangePosition, NoPosition, OffsetPosition, TransparentPosition} import io.{Pickler, CondPickler} import io.Pickler._ -import collection.mutable +import scala.collection.mutable import mutable.ListBuffer trait Picklers { self: Global => diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index de6974cbb2..40982c62f0 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -220,7 +220,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana } /** Return the set of source files that are invalidated by the given changes. */ - def invalidated(files: Set[AbstractFile], changesOf: collection.Map[Symbol, List[Change]], + def invalidated(files: Set[AbstractFile], changesOf: scala.collection.Map[Symbol, List[Change]], processed: Set[AbstractFile] = Set.empty): Set[AbstractFile] = { val buf = new mutable.HashSet[AbstractFile] diff --git a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala index 0f52258b7e..ca5bdd632f 100644 --- a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package interactive import scala.reflect.internal.util.{SourceFile, Position, NoPosition} -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer trait RichCompilationUnits { self: Global => diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala index 0080cfd753..dfbbb6ff88 100644 --- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -2,8 +2,8 @@ package scala.tools.nsc package interactive import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition} -import collection.mutable.ArrayBuffer -import reflect.internal.Chars.{isLineBreakChar, isWhitespace} +import scala.collection.mutable.ArrayBuffer +import scala.reflect.internal.Chars.{isLineBreakChar, isWhitespace} import ast.parser.Tokens._ trait ScratchPadMaker { self: Global => diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala index deeb398d39..cb46c0fdca 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala @@ -15,7 +15,7 @@ import scala.annotation.migration import scala.reflect.internal.util.Position import scala.reflect.internal.util.SourceFile -import collection.mutable.ListBuffer +import scala.collection.mutable.ListBuffer /** A base class for writing interactive compiler tests. * @@ -127,4 +127,4 @@ abstract class InteractiveTest // the presentation compiler sys.exit(0) } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala index 5270b1971a..aadffe2da5 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala @@ -9,7 +9,7 @@ package tests import scala.reflect.internal.util._ import reporters._ import io.AbstractFile -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer class Tester(ntests: Int, inputs: Array[SourceFile], settings: Settings) { @@ -168,7 +168,7 @@ class Tester(ntests: Int, inputs: Array[SourceFile], settings: Settings) { } case class ErrorTrace( - sfidx: Int, changes: Seq[Change], infos: collection.Set[reporter.Info], content: Array[Char]) { + sfidx: Int, changes: Seq[Change], infos: scala.collection.Set[reporter.Info], content: Array[Char]) { override def toString = "Sourcefile: "+inputs(sfidx)+ "\nChanges:\n "+changes.mkString("\n ")+ diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala index b5ea6ab7ce..ba1722382b 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala @@ -3,7 +3,7 @@ package scala.tools.nsc.interactive.tests.core case class DuplicateTestMarker(msg: String) extends Exception(msg) object TestMarker { - import collection.mutable.Map + import scala.collection.mutable.Map private val markers: Map[String, TestMarker] = Map.empty private def checkForDuplicate(marker: TestMarker) { @@ -24,4 +24,4 @@ object CompletionMarker extends TestMarker("/*!*/") object TypeMarker extends TestMarker("/*?*/") -object HyperlinkMarker extends TestMarker("/*#*/") \ No newline at end of file +object HyperlinkMarker extends TestMarker("/*#*/") diff --git a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala index abf326e746..5475410a84 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala @@ -77,7 +77,7 @@ object CompletionAware { /** Convenience factories. */ def apply(terms: () => List[String]): CompletionAware = apply(terms, _ => None) - def apply(map: collection.Map[String, CompletionAware]): CompletionAware = + def apply(map: scala.collection.Map[String, CompletionAware]): CompletionAware = apply(() => map.keys.toList, map.get _) } diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 4cc58d3f25..864f9bd073 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -23,7 +23,7 @@ import scala.reflect.NameTransformer._ import util.ScalaClassLoader import ScalaClassLoader._ import scala.tools.util._ -import language.{implicitConversions, existentials} +import scala.language.{implicitConversions, existentials} import scala.reflect.{ClassTag, classTag} import scala.tools.reflect.StdRuntimeTags._ @@ -839,7 +839,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) addThunk({ import scala.tools.nsc.io._ import Properties.userHome - import compat.Platform.EOL + import scala.compat.Platform.EOL val autorun = replProps.replAutorunCode.option flatMap (f => io.File(f).safeSlurp()) if (autorun.isDefined) intp.quietRun(autorun.get) }) diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index a2df1494ef..e7c56718f7 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -25,7 +25,7 @@ import scala.util.control.Exception.{ ultimately } import IMain._ import java.util.concurrent.Future import typechecker.Analyzer -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.runtime.{ universe => ru } import scala.reflect.{ ClassTag, classTag } import scala.tools.reflect.StdRuntimeTags._ diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala index edb95f7526..bab3a1e506 100644 --- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -9,7 +9,7 @@ package interpreter import scala.tools.jline._ import scala.tools.jline.console.completer._ import Completion._ -import collection.mutable.ListBuffer +import scala.collection.mutable.ListBuffer // REPL completor - queries supplied interpreter for valid // completions based on current contents of buffer. diff --git a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala index 2dc394a081..f0e643d572 100644 --- a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala @@ -6,12 +6,12 @@ package scala.tools.nsc package interpreter -import collection.{ mutable, immutable } +import scala.collection.{ mutable, immutable } import mutable.ListBuffer -import language.implicitConversions +import scala.language.implicitConversions class ProcessResult(val line: String) { - import sys.process._ + import scala.sys.process._ private val buffer = new ListBuffer[String] val builder = Process(line) diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index c041f02859..bf7204c754 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -10,7 +10,7 @@ import scala.collection.{ mutable, immutable } import scala.PartialFunction.cond import scala.reflect.internal.Chars import scala.reflect.internal.Flags._ -import language.implicitConversions +import scala.language.implicitConversions trait MemberHandlers { val intp: IMain diff --git a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala index a2b42aeefc..3203e2ba49 100644 --- a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala +++ b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package interpreter import NamedParam._ -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.runtime.{universe => ru} import scala.reflect.{ClassTag, classTag} diff --git a/src/compiler/scala/tools/nsc/interpreter/Phased.scala b/src/compiler/scala/tools/nsc/interpreter/Phased.scala index 9124eace05..66d748a9f1 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Phased.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Phased.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package interpreter import scala.collection.{ mutable, immutable } -import language.implicitConversions +import scala.language.implicitConversions /** Mix this into an object and use it as a phasing * swiss army knife. diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index 4ba0c59112..244c04bdf4 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -13,7 +13,7 @@ import session.{ History } import scala.io.Codec import java.net.{ URL, MalformedURLException } import io.{ Path } -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.runtime.{universe => ru} import scala.reflect.{ClassTag, classTag} diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala index cb10de7dca..f27c4a8123 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package interpreter -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.base.{Universe => BaseUniverse} import scala.reflect.runtime.{universe => ru} diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala index 9dcc4006a3..5642566cf7 100644 --- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala @@ -14,7 +14,7 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.{ClassTag, classTag} import typechecker.DestructureTypes import scala.reflect.internal.util.StringOps.ojoin -import language.implicitConversions +import scala.language.implicitConversions /** A more principled system for turning types into strings. */ @@ -256,4 +256,4 @@ trait TypeStrings { ) } -object TypeStrings extends TypeStrings { } \ No newline at end of file +object TypeStrings extends TypeStrings { } diff --git a/src/compiler/scala/tools/nsc/interpreter/package.scala b/src/compiler/scala/tools/nsc/interpreter/package.scala index 98129aded8..89006be8e2 100644 --- a/src/compiler/scala/tools/nsc/interpreter/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/package.scala @@ -5,7 +5,7 @@ package scala.tools.nsc -import language.implicitConversions +import scala.language.implicitConversions /** The main REPL related classes and values are as follows. * In addition to standard compiler classes Global and Settings, there are: @@ -38,7 +38,7 @@ package object interpreter extends ReplConfig with ReplStrings { implicit def postfixOps = language.postfixOps // make all postfix ops in this package compile without warning private[interpreter] implicit def javaCharSeqCollectionToScala(xs: JCollection[_ <: CharSequence]): List[String] = { - import collection.JavaConverters._ + import scala.collection.JavaConverters._ xs.asScala.toList map ("" + _) } diff --git a/src/compiler/scala/tools/nsc/interpreter/session/package.scala b/src/compiler/scala/tools/nsc/interpreter/session/package.scala index c1cd599941..58232e6b9a 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/package.scala @@ -5,7 +5,7 @@ package scala.tools.nsc package interpreter -import language.implicitConversions +import scala.language.implicitConversions /** Files having to do with the state of a repl session: * lines of text entered, types and terms defined, etc. diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala index 12ba3e4bd7..f66f3daa32 100644 --- a/src/compiler/scala/tools/nsc/io/Jar.scala +++ b/src/compiler/scala/tools/nsc/io/Jar.scala @@ -8,10 +8,10 @@ package io import java.io.{ InputStream, OutputStream, IOException, FileNotFoundException, FileInputStream, DataOutputStream } import java.util.jar._ -import collection.JavaConverters._ +import scala.collection.JavaConverters._ import Attributes.Name import util.ClassPath -import language.implicitConversions +import scala.language.implicitConversions // Attributes.Name instances: // diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala index 48361cd157..b03a921e87 100644 --- a/src/compiler/scala/tools/nsc/io/Pickler.scala +++ b/src/compiler/scala/tools/nsc/io/Pickler.scala @@ -1,10 +1,10 @@ package scala.tools.nsc.io -import annotation.unchecked +import scala.annotation.unchecked import Lexer._ import java.io.Writer -import language.implicitConversions -import reflect.ClassTag +import scala.language.implicitConversions +import scala.reflect.ClassTag /** An abstract class for writing and reading Scala objects to and * from a legible representation. The presesentation follows the following grammar: diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala index 3c4f004198..6385706830 100644 --- a/src/compiler/scala/tools/nsc/io/package.scala +++ b/src/compiler/scala/tools/nsc/io/package.scala @@ -8,7 +8,7 @@ package scala.tools.nsc import java.util.concurrent.{ Future, Callable } import java.util.{ Timer, TimerTask } import java.util.jar.{ Attributes } -import language.implicitConversions +import scala.language.implicitConversions package object io { implicit def postfixOps = language.postfixOps // make all postfix ops in this package compile without warning diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index c5da8822d5..a30ae1cb36 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -12,7 +12,7 @@ import scala.reflect.internal.util.OffsetPosition import scala.collection.mutable.ListBuffer import symtab.Flags import JavaTokens._ -import language.implicitConversions +import scala.language.implicitConversions trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { val global : Global diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index 0367119547..7aeae485d0 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -11,7 +11,7 @@ import scala.reflect.internal.util._ import scala.reflect.internal.Chars._ import JavaTokens._ import scala.annotation.switch -import language.implicitConversions +import scala.language.implicitConversions // Todo merge these better with Scanners trait JavaScanners extends ast.parser.ScannersCommon { diff --git a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala index 6d8c80d1d0..be8f1e3d9e 100644 --- a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala +++ b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala @@ -9,8 +9,8 @@ package matching import transform.ExplicitOuter import ast.{ Printers, Trees } import java.io.{ StringWriter, PrintWriter } -import annotation.elidable -import language.postfixOps +import scala.annotation.elidable +import scala.language.postfixOps /** Ancillary bits of ParallelMatching which are better off * out of the way. diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index 1cf4bccb40..93e936fe1f 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -9,7 +9,7 @@ package matching import transform.ExplicitOuter import symtab.Flags import scala.collection.mutable -import language.implicitConversions +import scala.language.implicitConversions trait Matrix extends MatrixAdditions { self: ExplicitOuter with ParallelMatching => diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 71deb2d356..1d21e4952f 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -13,8 +13,8 @@ import scala.reflect.internal.util.Position import transform.ExplicitOuter import symtab.Flags import mutable.ListBuffer -import annotation.elidable -import language.postfixOps +import scala.annotation.elidable +import scala.language.postfixOps trait ParallelMatching extends ast.TreeDSL with MatchSupport diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index 8e043613b8..ee96f15f40 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -8,7 +8,7 @@ package matching import transform.ExplicitOuter import PartialFunction._ -import language.postfixOps +import scala.language.postfixOps trait PatternBindings extends ast.TreeDSL { diff --git a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala index 67ff916b11..f7ad39bd95 100644 --- a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala +++ b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala @@ -5,7 +5,7 @@ import java.io.{FileInputStream, InputStreamReader, IOException} import scala.runtime.ScalaRunTime.stringOf import java.lang.reflect.InvocationTargetException import scala.reflect.runtime.ReflectionUtils._ -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer class Mixer { diff --git a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala index 1c4fad5511..5eeab53fca 100644 --- a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala +++ b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala @@ -3,8 +3,7 @@ package scratchpad import java.io.Writer import scala.reflect.internal.util.SourceFile - -import reflect.internal.Chars._ +import scala.reflect.internal.Chars._ object SourceInserter { def stripRight(cs: Array[Char]): Array[Char] = { diff --git a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala index 120ada965a..78b56a8596 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala @@ -15,7 +15,7 @@ trait AbsSettings extends scala.reflect.internal.settings.AbsSettings { type Setting <: AbsSetting // Fix to the concrete Setting type type ResultOfTryToSet // List[String] in mutable, (Settings, List[String]) in immutable def errorFn: String => Unit - protected def allSettings: collection.Set[Setting] + protected def allSettings: scala.collection.Set[Setting] // settings minus internal usage settings def visibleSettings = allSettings filterNot (_.isInternalOnly) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 19392ec23a..3ff7af791b 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -8,10 +8,10 @@ package scala.tools package nsc package settings -import annotation.elidable +import scala.annotation.elidable import scala.tools.util.PathResolver.Defaults import scala.collection.mutable -import language.{implicitConversions, existentials} +import scala.language.{implicitConversions, existentials} trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 8e77f8b6f4..f7c3a55954 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -10,9 +10,9 @@ import java.io.IOException import scala.compat.Platform.currentTime import scala.tools.nsc.util.{ ClassPath } import classfile.ClassfileParser -import reflect.internal.Flags._ -import reflect.internal.MissingRequirementError -import reflect.internal.util.Statistics +import scala.reflect.internal.Flags._ +import scala.reflect.internal.MissingRequirementError +import scala.reflect.internal.util.Statistics import scala.tools.nsc.io.{ AbstractFile, MsilFile } /** This class ... @@ -300,6 +300,6 @@ abstract class SymbolLoaders { } object SymbolLoadersStats { - import reflect.internal.TypesStats.typerNanos + import scala.reflect.internal.TypesStats.typerNanos val classReadNanos = Statistics.newSubTimer ("time classfilereading", typerNanos) } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala index c6bd236e8a..7e2741f6bc 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala @@ -6,4 +6,4 @@ package scala.tools.nsc package symtab -abstract class SymbolTable extends reflect.internal.SymbolTable \ No newline at end of file +abstract class SymbolTable extends scala.reflect.internal.SymbolTable diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index c596eb014a..d9d25bf95a 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -7,8 +7,8 @@ package scala.tools.nsc package symtab import scala.collection.{ mutable, immutable } -import language.implicitConversions -import language.postfixOps +import scala.language.implicitConversions +import scala.language.postfixOps /** Printing the symbol graph (for those symbols attached to an AST node) * after each phase. diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index fcd5e369f5..903b3095de 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -1164,7 +1164,7 @@ abstract class ClassfileParser { originalName + " in " + outerName + "(" + externalName +")" } - object innerClasses extends collection.mutable.HashMap[Name, InnerClassEntry] { + object innerClasses extends scala.collection.mutable.HashMap[Name, InnerClassEntry] { /** Return the Symbol of the top level class enclosing `name`, * or 'name's symbol if no entry found for `name`. */ diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 3c34cf1c80..b30969d451 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -512,7 +512,7 @@ abstract class Pickler extends SubComponent { private def writeName(name: Name) { ensureCapacity(name.length * 3) val utfBytes = Codec toUTF8 name.toString - compat.Platform.arraycopy(utfBytes, 0, bytes, writeIndex, utfBytes.length) + scala.compat.Platform.arraycopy(utfBytes, 0, bytes, writeIndex, utfBytes.length) writeIndex += utfBytes.length } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/package.scala b/src/compiler/scala/tools/nsc/symtab/classfile/package.scala index fe66c515de..1f9a823bb4 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/package.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/package.scala @@ -2,6 +2,6 @@ package scala.tools.nsc.symtab package object classfile { - val ClassfileConstants = reflect.internal.ClassfileConstants + val ClassfileConstants = scala.reflect.internal.ClassfileConstants } diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 5e52415ab2..18b95ba191 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -12,7 +12,7 @@ import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, import scala.collection.{ mutable, immutable } import scala.reflect.internal.pickling.UnPickler import ch.epfl.lamp.compiler.msil.Type.TMVarUsage -import language.implicitConversions +import scala.language.implicitConversions /** * @author Nikolay Mihaylov diff --git a/src/compiler/scala/tools/nsc/symtab/package.scala b/src/compiler/scala/tools/nsc/symtab/package.scala index 1cf0d2c2ae..0e6719f225 100644 --- a/src/compiler/scala/tools/nsc/symtab/package.scala +++ b/src/compiler/scala/tools/nsc/symtab/package.scala @@ -2,6 +2,6 @@ package scala.tools.nsc package object symtab { - val Flags = reflect.internal.Flags + val Flags = scala.reflect.internal.Flags } diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 4a668d4c61..ab0a8756a4 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -9,7 +9,7 @@ package transform import symtab._ import Flags._ import scala.collection.{ mutable, immutable } -import collection.mutable.ListBuffer +import scala.collection.mutable.ListBuffer abstract class AddInterfaces extends InfoTransform { self: Erasure => import global._ // the global environment diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 972debb900..dff9a65649 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -9,7 +9,7 @@ package transform import symtab._ import Flags._ import scala.collection._ -import language.postfixOps +import scala.language.postfixOps abstract class CleanUp extends Transform with ast.TreeDSL { import global._ @@ -351,8 +351,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /** Normal non-Array call */ def genDefaultCall = { // reflective method call machinery - val invokeName = MethodClass.tpe member nme.invoke_ // reflect.Method.invoke(...) - def cache = REF(reflectiveMethodCache(ad.symbol.name.toString, paramTypes)) // cache Symbol + val invokeName = MethodClass.tpe member nme.invoke_ // scala.reflect.Method.invoke(...) + def cache = REF(reflectiveMethodCache(ad.symbol.name.toString, paramTypes)) // cache Symbol def lookup = Apply(cache, List(qual1() GETCLASS)) // get Method object from cache def invokeArgs = ArrayValue(TypeTree(ObjectClass.tpe), params) // args for invocation def invocation = (lookup DOT invokeName)(qual1(), invokeArgs) // .invoke(qual1, ...) diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 37e452dc6a..7dafc9b467 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -12,7 +12,7 @@ import symtab._ import Flags._ abstract class Erasure extends AddInterfaces - with reflect.internal.transform.Erasure + with scala.reflect.internal.transform.Erasure with typechecker.Analyzer with TypingTransformers with ast.TreeDSL diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 79b24e826d..2b0520592b 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -430,7 +430,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * * Such fields will be nulled after the initializer has memoized the lazy value. */ - def singleUseFields(templ: Template): collection.Map[Symbol, List[Symbol]] = { + def singleUseFields(templ: Template): scala.collection.Map[Symbol, List[Symbol]] = { val usedIn = mutable.HashMap[Symbol, List[Symbol]]() withDefaultValue Nil object SingleUseTraverser extends Traverser { diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala index 4401e3bd3e..f9d8d19b10 100644 --- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala +++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala @@ -9,7 +9,7 @@ package transform import scala.collection.mutable import symtab.Flags._ import util.HashSet -import annotation.tailrec +import scala.annotation.tailrec /** A class that yields a kind of iterator (`Cursor`), * which yields all pairs of overriding/overridden symbols diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 86cdc59303..0fa50a255b 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -8,8 +8,8 @@ package transform import scala.tools.nsc.symtab.Flags import scala.collection.{ mutable, immutable } -import language.postfixOps -import language.existentials +import scala.language.postfixOps +import scala.language.existentials /** Specialize code on types. * diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index a97b7ab907..5a3db26e30 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -8,7 +8,7 @@ package transform import symtab.Flags._ import scala.collection.{ mutable, immutable } -import language.postfixOps +import scala.language.postfixOps /* */ /** - uncurry all symbol and tree types (@see UnCurryPhase) -- this includes normalizing all proper types. @@ -44,7 +44,7 @@ import language.postfixOps */ /* */ abstract class UnCurry extends InfoTransform - with reflect.internal.transform.UnCurry + with scala.reflect.internal.transform.UnCurry with TypingTransformers with ast.TreeDSL { val global: Global // need to repeat here because otherwise last mixin defines global as // SymbolTable. If we had DOT this would not be an issue @@ -684,16 +684,16 @@ abstract class UnCurry extends InfoTransform else tree } - + def isThrowable(pat: Tree): Boolean = pat match { - case Typed(Ident(nme.WILDCARD), tpt) => + case Typed(Ident(nme.WILDCARD), tpt) => tpt.tpe =:= ThrowableClass.tpe - case Bind(_, pat) => + case Bind(_, pat) => isThrowable(pat) case _ => false } - + def isDefaultCatch(cdef: CaseDef) = isThrowable(cdef.pat) && cdef.guard.isEmpty def postTransformTry(tree: Try) = { @@ -757,10 +757,10 @@ abstract class UnCurry extends InfoTransform case tree: Try => postTransformTry(tree) - + case Apply(Apply(fn, args), args1) => treeCopy.Apply(tree, fn, args ::: args1) - + case Ident(name) => assert(name != tpnme.WILDCARD_STAR, tree) applyUnary() diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index ab8836f339..399f9a1eac 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package typechecker -import reflect.internal.util.Statistics +import scala.reflect.internal.util.Statistics /** The main attribution phase. */ @@ -72,7 +72,7 @@ trait Analyzer extends AnyRef } object typerFactory extends SubComponent { - import reflect.internal.TypesStats.typerNanos + import scala.reflect.internal.TypesStats.typerNanos val global: Analyzer.this.global.type = Analyzer.this.global val phaseName = "typer" val runsAfter = List[String]() diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 6a908c6c65..dbf769c79f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -8,7 +8,7 @@ package typechecker import symtab.Flags._ import scala.collection.mutable.{LinkedHashSet, Set} -import annotation.tailrec +import scala.annotation.tailrec /** * @author Martin Odersky diff --git a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala index 5802d36878..6a21639391 100644 --- a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala +++ b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package typechecker -import language.implicitConversions +import scala.language.implicitConversions /** A generic means of breaking down types into their subcomponents. * Types are decomposed top down, and recognizable substructure is diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala index 070f083a89..97e86d183e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala @@ -29,7 +29,7 @@ abstract class Duplicators extends Analyzer { * the old class with the new class, and map symbols through the given 'env'. The * environment is a map from type skolems to concrete types (see SpecializedTypes). */ - def retyped(context: Context, tree: Tree, oldThis: Symbol, newThis: Symbol, env: collection.Map[Symbol, Type]): Tree = { + def retyped(context: Context, tree: Tree, oldThis: Symbol, newThis: Symbol, env: scala.collection.Map[Symbol, Type]): Tree = { if (oldThis ne newThis) { oldClassOwner = oldThis newClassOwner = newThis diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 08978ef4b5..e3f0756b6c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -11,13 +11,13 @@ package scala.tools.nsc package typechecker -import annotation.tailrec +import scala.annotation.tailrec import scala.collection.{ mutable, immutable } import mutable.{ LinkedHashMap, ListBuffer } import scala.util.matching.Regex import symtab.Flags._ import scala.reflect.internal.util.Statistics -import language.implicitConversions +import scala.language.implicitConversions /** This trait provides methods to find various kinds of implicits. * @@ -1217,14 +1217,14 @@ trait Implicits { private val ManifestSymbols = Set[Symbol](PartialManifestClass, FullManifestClass, OptManifestClass) /** Creates a tree that calls the relevant factory method in object - * reflect.Manifest for type 'tp'. An EmptyTree is returned if + * scala.reflect.Manifest for type 'tp'. An EmptyTree is returned if * no manifest is found. todo: make this instantiate take type params as well? */ private def manifestOfType(tp: Type, flavor: Symbol): SearchResult = { val full = flavor == FullManifestClass val opt = flavor == OptManifestClass - /** Creates a tree that calls the factory method called constructor in object reflect.Manifest */ + /** Creates a tree that calls the factory method called constructor in object scala.reflect.Manifest */ def manifestFactoryCall(constructor: String, tparg: Type, args: Tree*): Tree = if (args contains EmptyTree) EmptyTree else typedPos(tree.pos.focus) { @@ -1472,7 +1472,7 @@ trait Implicits { interpolate(msg, Map((typeParamNames zip typeArgs): _*)) // TODO: give access to the name and type of the implicit argument, etc? def validate: Option[String] = { - import scala.util.matching.Regex; import collection.breakOut + import scala.util.matching.Regex; import scala.collection.breakOut // is there a shorter way to avoid the intermediate toList? val refs = """\$\{([^}]+)\}""".r.findAllIn(msg).matchData.map(_ group 1).toSet val decls = typeParamNames.toSet @@ -1492,7 +1492,7 @@ trait Implicits { object ImplicitsStats { - import reflect.internal.TypesStats._ + import scala.reflect.internal.TypesStats._ val rawTypeImpl = Statistics.newSubCounter (" of which in implicits", rawTypeCount) val subtypeImpl = Statistics.newSubCounter(" of which in implicit", subtypeCount) diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 27a88a3683..7e9b288853 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -7,7 +7,7 @@ import scala.tools.nsc.util.ClassPath._ import scala.reflect.runtime.ReflectionUtils import scala.collection.mutable.ListBuffer import scala.compat.Platform.EOL -import reflect.internal.util.Statistics +import scala.reflect.internal.util.Statistics import scala.reflect.macros.util._ import java.lang.{Class => jClass} import java.lang.reflect.{Array => jArray, Method => jMethod} @@ -832,7 +832,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { var hasPendingMacroExpansions = false private val delayed = perRunCaches.newWeakMap[Tree, collection.mutable.Set[Int]] private def isDelayed(expandee: Tree) = delayed contains expandee - private def calculateUndetparams(expandee: Tree): collection.mutable.Set[Int] = + private def calculateUndetparams(expandee: Tree): scala.collection.mutable.Set[Int] = delayed.get(expandee).getOrElse { val calculated = collection.mutable.Set[Symbol]() expandee foreach (sub => { @@ -886,7 +886,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { } object MacrosStats { - import reflect.internal.TypesStats.typerNanos + import scala.reflect.internal.TypesStats.typerNanos val macroExpandCount = Statistics.newCounter ("#macro expansions", "typer") val macroExpandNanos = Statistics.newSubTimer("time spent in macroExpand", typerNanos) } diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 83740f1658..91dcd90962 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -10,7 +10,7 @@ import scala.collection.{ mutable, immutable } import scala.reflect.internal.util.StringOps.{ ojoin } import scala.reflect.ClassTag import scala.reflect.runtime.{ universe => ru } -import language.higherKinds +import scala.language.higherKinds /** Logic related to method synthesis which involves cooperation between * Namer and Typer. diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index c60118a8b4..237d17887d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -9,12 +9,12 @@ package typechecker import symtab._ import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC, ARTIFACT} -import language.postfixOps +import scala.language.postfixOps import scala.tools.nsc.transform.TypingTransformers import scala.tools.nsc.transform.Transform import scala.collection.mutable.HashSet import scala.collection.mutable.HashMap -import reflect.internal.util.Statistics +import scala.reflect.internal.util.Statistics import scala.reflect.internal.Types /** Translate pattern matching. @@ -2941,7 +2941,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL } // node in the tree that describes how to construct a counter-example - case class VariableAssignment(variable: Var, equalTo: List[Const], notEqualTo: List[Const], fields: collection.mutable.Map[Symbol, VariableAssignment]) { + case class VariableAssignment(variable: Var, equalTo: List[Const], notEqualTo: List[Const], fields: scala.collection.mutable.Map[Symbol, VariableAssignment]) { // need to prune since the model now incorporates all super types of a constant (needed for reachability) private lazy val uniqueEqualTo = equalTo filterNot (subsumed => equalTo.exists(better => (better ne subsumed) && instanceOfTpImplies(better.tp, subsumed.tp))) private lazy val prunedEqualTo = uniqueEqualTo filterNot (subsumed => variable.staticTpCheckable <:< subsumed.tp) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index d515934c58..84ec86b194 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -7,10 +7,10 @@ package scala.tools.nsc package typechecker import symtab.Flags._ -import collection.{ mutable, immutable } +import scala.collection.{ mutable, immutable } import transform.InfoTransform import scala.collection.mutable.ListBuffer -import language.postfixOps +import scala.language.postfixOps /**

      * Post-attribution checking and transformation. @@ -38,7 +38,7 @@ import language.postfixOps * * @todo Check whether we always check type parameter bounds. */ -abstract class RefChecks extends InfoTransform with reflect.internal.transform.RefChecks { +abstract class RefChecks extends InfoTransform with scala.reflect.internal.transform.RefChecks { val global: Global // need to repeat here because otherwise last mixin defines global as // SymbolTable. If we had DOT this would not be an issue @@ -509,7 +509,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } } } - + def checkOverrideDeprecated() { if (other.hasDeprecatedOverridingAnnotation) { val suffix = other.deprecatedOverridingMessage map (": " + _) getOrElse "" diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d0722f7b98..8a3c509e81 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -13,10 +13,9 @@ package scala.tools.nsc package typechecker import scala.collection.mutable -import scala.reflect.internal.util.BatchSourceFile +import scala.reflect.internal.util.{ BatchSourceFile, Statistics } import mutable.ListBuffer import symtab.Flags._ -import reflect.internal.util.Statistics // Suggestion check whether we can do without priming scopes with symbols of outer scopes, // like the IDE does. @@ -779,7 +778,7 @@ trait Typers extends Modes with Adaptations with Tags { var raw = featureDesc + " " + req + " be enabled\n" + "by making the implicit value language." + featureName + " visible." if (!(currentRun.reportedFeature contains featureTrait)) - raw += "\nThis can be achieved by adding the import clause 'import language." + featureName + "'\n" + + raw += "\nThis can be achieved by adding the import clause 'import scala.language." + featureName + "'\n" + "or by setting the compiler option -language:" + featureName + ".\n" + "See the Scala docs for value scala.language." + featureName + " for a discussion\n" + "why the feature " + req + " be explicitly enabled." @@ -5558,8 +5557,8 @@ trait Typers extends Modes with Adaptations with Tags { } object TypersStats { - import reflect.internal.TypesStats._ - import reflect.internal.BaseTypeSeqsStats._ + import scala.reflect.internal.TypesStats._ + import scala.reflect.internal.BaseTypeSeqsStats._ val typedIdentCount = Statistics.newCounter("#typechecked identifiers") val typedSelectCount = Statistics.newCounter("#typechecked selections") val typedApplyCount = Statistics.newCounter("#typechecked applications") diff --git a/src/compiler/scala/tools/nsc/util/Exceptional.scala b/src/compiler/scala/tools/nsc/util/Exceptional.scala index 90d032518a..34344263e8 100644 --- a/src/compiler/scala/tools/nsc/util/Exceptional.scala +++ b/src/compiler/scala/tools/nsc/util/Exceptional.scala @@ -4,7 +4,7 @@ package util import java.util.concurrent.ExecutionException import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableException } import scala.reflect.internal.util.StringOps._ -import language.implicitConversions +import scala.language.implicitConversions object Exceptional { def unwrap(x: Throwable): Throwable = x match { diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index 25caae9ecb..9de3a2427f 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -14,7 +14,7 @@ import java.net.URL import scala.reflect.runtime.ReflectionUtils.unwrapHandler import ScalaClassLoader._ import scala.util.control.Exception.{ catching } -import language.implicitConversions +import scala.language.implicitConversions import scala.reflect.{ ClassTag, classTag } trait HasClassPath { diff --git a/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala b/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala index 8cdb96c586..3682b9fb54 100644 --- a/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala +++ b/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala @@ -6,13 +6,13 @@ package scala.tools.nsc package util -import reflect.internal.util.Statistics +import scala.reflect.internal.util.Statistics abstract class StatisticsInfo { val global: Global import global._ - import reflect.internal.TreesStats.nodeByType + import scala.reflect.internal.TreesStats.nodeByType val phasesShown = List("parser", "typer", "patmat", "erasure", "cleanup") @@ -35,4 +35,4 @@ abstract class StatisticsInfo { for (q <- quants if q.showAt(phase.name)) inform(q.line) } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index d6bed0c6d1..38e4e3c9f1 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -13,7 +13,7 @@ trait FastTrack { import global._ import definitions._ - import language.implicitConversions + import scala.language.implicitConversions private implicit def context2taggers(c0: MacroContext): Taggers { val c: c0.type } = new { val c: c0.type = c0 } with Taggers private implicit def context2macroimplementations(c0: MacroContext): MacroImplementations { val c: c0.type } = new { val c: c0.type = c0 } with MacroImplementations @@ -38,4 +38,4 @@ trait FastTrack { StringContext_f bindTo { case (c, app@Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args, app.pos) } registry } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/reflect/package.scala b/src/compiler/scala/tools/reflect/package.scala index 3008930823..d5569e448d 100644 --- a/src/compiler/scala/tools/reflect/package.scala +++ b/src/compiler/scala/tools/reflect/package.scala @@ -6,7 +6,7 @@ package scala.tools import scala.reflect.api.JavaUniverse -import language.implicitConversions +import scala.language.implicitConversions package object reflect extends FrontEnds { // [todo: can we generalize this? diff --git a/src/compiler/scala/tools/util/Javap.scala b/src/compiler/scala/tools/util/Javap.scala index ce149a5aa0..70f71a222a 100644 --- a/src/compiler/scala/tools/util/Javap.scala +++ b/src/compiler/scala/tools/util/Javap.scala @@ -12,7 +12,7 @@ import scala.tools.nsc.util.ScalaClassLoader import java.io.{ InputStream, PrintWriter, ByteArrayInputStream, FileNotFoundException } import scala.tools.nsc.io.File import Javap._ -import language.reflectiveCalls +import scala.language.reflectiveCalls trait Javap { def loader: ScalaClassLoader diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 739878c282..f6dc92f96e 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -13,7 +13,7 @@ import nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader } import nsc.io.{ File, Directory, Path, AbstractFile } import ClassPath.{ JavaContext, DefaultJavaContext, join, split } import PartialFunction.condOpt -import language.postfixOps +import scala.language.postfixOps // Loosely based on the draft specification at: // https://wiki.scala-lang.org/display/SW/Classpath diff --git a/src/compiler/scala/tools/util/VerifyClass.scala b/src/compiler/scala/tools/util/VerifyClass.scala index e0e089d0b2..d208a9f9c2 100644 --- a/src/compiler/scala/tools/util/VerifyClass.scala +++ b/src/compiler/scala/tools/util/VerifyClass.scala @@ -2,7 +2,7 @@ package scala.tools.util import scala.tools.nsc.io._ import java.net.URLClassLoader -import collection.JavaConverters._ +import scala.collection.JavaConverters._ object VerifyClass { diff --git a/src/continuations/library/scala/util/continuations/ControlContext.scala b/src/continuations/library/scala/util/continuations/ControlContext.scala index 910ca60eb0..37e3f45a4f 100644 --- a/src/continuations/library/scala/util/continuations/ControlContext.scala +++ b/src/continuations/library/scala/util/continuations/ControlContext.scala @@ -8,7 +8,7 @@ package scala.util.continuations -import annotation.{ Annotation, StaticAnnotation, TypeConstraint } +import scala.annotation.{ Annotation, StaticAnnotation, TypeConstraint } /** This annotation is used to mark a parameter as part of a continuation * context. diff --git a/src/detach/library/scala/remoting/Channel.scala b/src/detach/library/scala/remoting/Channel.scala index 54b8fb100e..18944a152d 100644 --- a/src/detach/library/scala/remoting/Channel.scala +++ b/src/detach/library/scala/remoting/Channel.scala @@ -116,7 +116,7 @@ class Channel protected (socket: Socket) { * the expected type. */ @throws(classOf[ChannelException]) - def receive[T](implicit expected: reflect.ClassTag[T]): T = { + def receive[T](implicit expected: scala.reflect.ClassTag[T]): T = { val found = in.readObject().asInstanceOf[reflect.ClassTag[_]] info("receive: found="+found+", expected="+expected) import scala.reflect.ClassTag @@ -144,11 +144,11 @@ class Channel protected (socket: Socket) { /** ? method may throw either an * ClassNotFoundException or an IOException. */ - def ?[T](implicit t: reflect.ClassTag[T]): T = receive[T](t) + def ?[T](implicit t: scala.reflect.ClassTag[T]): T = receive[T](t) /** send method may throw an IOException. */ - def send[T](x: T)(implicit t: reflect.ClassTag[T]) { + def send[T](x: T)(implicit t: scala.reflect.ClassTag[T]) { out writeObject t x match { case x: Unit => // nop @@ -168,7 +168,7 @@ class Channel protected (socket: Socket) { /** ! method may throw an IOException. */ - def ![T](x: T)(implicit m: reflect.ClassTag[T]) { send(x)(m) } + def ![T](x: T)(implicit m: scala.reflect.ClassTag[T]) { send(x)(m) } def close() { try { socket.close() } diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index de61d40cd5..c61a255e3b 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -11,7 +11,7 @@ package scala import scala.collection.generic._ import scala.collection.{ mutable, immutable } import mutable.{ ArrayBuilder, ArraySeq } -import compat.Platform.arraycopy +import scala.compat.Platform.arraycopy import scala.reflect.ClassTag import scala.runtime.ScalaRunTime.{ array_apply, array_update } diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index 014928d986..440e546f19 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Boolean` (equivalent to Java's `boolean` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Boolean` are not diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index 6f54f6cedf..df0d2c73b1 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Byte`, a 8-bit signed integer (equivalent to Java's `byte` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Byte` are not diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index b681ae1693..1fa0c0d9e8 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Char`, a 16-bit unsigned integer (equivalent to Java's `char` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Char` are not diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 510de92a2a..f058d7c26b 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Double` are not diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index b9c116da0b..d942acec23 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Float`, a 32-bit IEEE-754 floating point number (equivalent to Java's `float` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Float` are not diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index b2a4f93253..ae36413469 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Int`, a 32-bit signed integer (equivalent to Java's `int` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Int` are not diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 40932a65a7..4ee9383c2a 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Long`, a 64-bit signed integer (equivalent to Java's `long` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Long` are not diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala index 8c49d2f67b..7697a7367a 100644 --- a/src/library/scala/LowPriorityImplicits.scala +++ b/src/library/scala/LowPriorityImplicits.scala @@ -12,7 +12,7 @@ import scala.collection.{ mutable, immutable, generic } import mutable.WrappedArray import immutable.WrappedString import generic.CanBuildFrom -import language.implicitConversions +import scala.language.implicitConversions /** The `LowPriorityImplicits` class provides implicit values that * are valid in all Scala compilation units without explicit qualification, diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index b7420f4447..945b0a0c3b 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -10,7 +10,7 @@ package scala object Option { - import language.implicitConversions + import scala.language.implicitConversions /** An implicit conversion that converts an option to an iterable value */ diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index d0a339bdd5..7c6e2d2e3e 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -211,8 +211,8 @@ object PartialFunction { @inline private final def checkFallback[B] = fallback_pf.asInstanceOf[PartialFunction[Any, B]] @inline private final def fallbackOccurred[B](x: B) = (fallback_pf eq x.asInstanceOf[AnyRef]) - private final class Lifted[-A, +B] (val pf: PartialFunction[A, B]) - extends runtime.AbstractFunction1[A, Option[B]] { + private final class Lifted[-A, +B] (val pf: PartialFunction[A, B]) + extends scala.runtime.AbstractFunction1[A, Option[B]] { def apply(x: A): Option[B] = { val z = pf.applyOrElse(x, checkFallback[B]) @@ -220,7 +220,7 @@ object PartialFunction { } } - private final class Unlifted[A, B] (f: A => Option[B]) extends runtime.AbstractPartialFunction[A, B] { + private final class Unlifted[A, B] (f: A => Option[B]) extends scala.runtime.AbstractPartialFunction[A, B] { def isDefinedAt(x: A): Boolean = f(x).isDefined override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = { diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index f3d36473dd..4792de6bf5 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -12,9 +12,9 @@ import scala.collection.{ mutable, immutable, generic } import immutable.StringOps import mutable.ArrayOps import generic.CanBuildFrom -import annotation.{ elidable, implicitNotFound } -import annotation.elidable.ASSERTION -import language.{implicitConversions, existentials} +import scala.annotation.{ elidable, implicitNotFound } +import scala.annotation.elidable.ASSERTION +import scala.language.{implicitConversions, existentials} /** The `Predef` object provides definitions that are accessible in all Scala * compilation units without explicit qualification. @@ -301,7 +301,7 @@ object Predef extends LowPriorityImplicits { implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc) implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)) = new runtime.Tuple2Zipped.Ops(x) implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)) = new runtime.Tuple3Zipped.Ops(x) - implicit def seqToCharSequence(xs: collection.IndexedSeq[Char]): CharSequence = new runtime.SeqCharSequence(xs) + implicit def seqToCharSequence(xs: scala.collection.IndexedSeq[Char]): CharSequence = new runtime.SeqCharSequence(xs) implicit def arrayToCharSequence(xs: Array[Char]): CharSequence = new runtime.ArrayCharSequence(xs, 0, xs.length) implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs match { diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala index 0cb924c3d4..f59aa94bd7 100644 --- a/src/library/scala/SerialVersionUID.scala +++ b/src/library/scala/SerialVersionUID.scala @@ -12,4 +12,4 @@ package scala * Annotation for specifying the `static SerialVersionUID` field * of a serializable class. */ -class SerialVersionUID(uid: Long) extends annotation.StaticAnnotation +class SerialVersionUID(uid: Long) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 687b198a11..35c5fe3ff0 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Short`, a 16-bit signed integer (equivalent to Java's `short` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Short` are not diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 4156071f29..dc67e60314 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -10,7 +10,7 @@ package scala -import language.implicitConversions +import scala.language.implicitConversions /** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type diff --git a/src/library/scala/annotation/bridge.scala b/src/library/scala/annotation/bridge.scala index a56129fb96..c3a7f47e62 100644 --- a/src/library/scala/annotation/bridge.scala +++ b/src/library/scala/annotation/bridge.scala @@ -11,4 +11,4 @@ package scala.annotation /** If this annotation is present on a method, it will be treated as a bridge method. */ @deprecated("Reconsider whether using this annotation will accomplish anything", "2.10.0") -private[scala] class bridge extends annotation.StaticAnnotation +private[scala] class bridge extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/cloneable.scala b/src/library/scala/annotation/cloneable.scala index aa45e8325f..dc2031ba8d 100644 --- a/src/library/scala/annotation/cloneable.scala +++ b/src/library/scala/annotation/cloneable.scala @@ -12,4 +12,4 @@ package scala.annotation * An annotation that designates the class to which it is applied as cloneable */ @deprecated("instead of `@cloneable class C`, use `class C extends Cloneable`", "2.10.0") -class cloneable extends annotation.StaticAnnotation +class cloneable extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/elidable.scala b/src/library/scala/annotation/elidable.scala index 18be2450f5..0b4f5ac4b2 100644 --- a/src/library/scala/annotation/elidable.scala +++ b/src/library/scala/annotation/elidable.scala @@ -22,7 +22,7 @@ import java.util.logging.Level * @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: * @@ -33,10 +33,10 @@ import java.util.logging.Level * T >: Null null * T >: Nothing Predef.??? * }}} - * + * * Complete example: {{{ - import annotation._, elidable._ + import scala.annotation._, elidable._ object Test extends App { def expensiveComputation(): Int = { Thread.sleep(1000) ; 172 } @@ -62,7 +62,7 @@ import java.util.logging.Level * @author Paul Phillips * @since 2.8 */ -final class elidable(final val level: Int) extends annotation.StaticAnnotation {} +final class elidable(final val level: Int) extends scala.annotation.StaticAnnotation {} /** This useless appearing code was necessary to allow people to use * named constants for the elidable annotation. This is what it takes diff --git a/src/library/scala/annotation/implicitNotFound.scala b/src/library/scala/annotation/implicitNotFound.scala index 0c6a5d610f..993e99d382 100644 --- a/src/library/scala/annotation/implicitNotFound.scala +++ b/src/library/scala/annotation/implicitNotFound.scala @@ -15,4 +15,4 @@ package scala.annotation * @author Adriaan Moors * @since 2.8.1 */ -final class implicitNotFound(msg: String) extends annotation.StaticAnnotation {} \ No newline at end of file +final class implicitNotFound(msg: String) extends scala.annotation.StaticAnnotation {} diff --git a/src/library/scala/annotation/meta/beanGetter.scala b/src/library/scala/annotation/meta/beanGetter.scala index 040a3f415a..48eccf9337 100644 --- a/src/library/scala/annotation/meta/beanGetter.scala +++ b/src/library/scala/annotation/meta/beanGetter.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class beanGetter extends annotation.StaticAnnotation +final class beanGetter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/beanSetter.scala b/src/library/scala/annotation/meta/beanSetter.scala index 45ea063169..c9f68449fc 100644 --- a/src/library/scala/annotation/meta/beanSetter.scala +++ b/src/library/scala/annotation/meta/beanSetter.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class beanSetter extends annotation.StaticAnnotation +final class beanSetter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/companionClass.scala b/src/library/scala/annotation/meta/companionClass.scala index 8e53f6caf9..d165f37bad 100644 --- a/src/library/scala/annotation/meta/companionClass.scala +++ b/src/library/scala/annotation/meta/companionClass.scala @@ -12,6 +12,6 @@ package scala.annotation.meta * conversion method for it. Annotations `@companionClass` and `@companionMethod` * control where an annotation on the implicit class will go. By default, annotations * on an implicit class end up only on the class. - * + * */ -final class companionClass extends annotation.StaticAnnotation +final class companionClass extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/companionMethod.scala b/src/library/scala/annotation/meta/companionMethod.scala index 379c4f3385..c069b47f04 100644 --- a/src/library/scala/annotation/meta/companionMethod.scala +++ b/src/library/scala/annotation/meta/companionMethod.scala @@ -12,6 +12,6 @@ package scala.annotation.meta * conversion method for it. Annotations `@companionClass` and `@companionMethod` * control where an annotation on the implicit class will go. By default, annotations * on an implicit class end up only on the class. - * + * */ -final class companionMethod extends annotation.StaticAnnotation +final class companionMethod extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/companionObject.scala b/src/library/scala/annotation/meta/companionObject.scala index d329df5c42..5bd58f6365 100644 --- a/src/library/scala/annotation/meta/companionObject.scala +++ b/src/library/scala/annotation/meta/companionObject.scala @@ -11,4 +11,4 @@ package scala.annotation.meta * Currently unused; intended as an annotation target for classes such as case classes * that automatically generate a companion object */ -final class companionObject extends annotation.StaticAnnotation +final class companionObject extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/field.scala b/src/library/scala/annotation/meta/field.scala index 78f4a98544..96ed13abc4 100644 --- a/src/library/scala/annotation/meta/field.scala +++ b/src/library/scala/annotation/meta/field.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class field extends annotation.StaticAnnotation +final class field extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/getter.scala b/src/library/scala/annotation/meta/getter.scala index 07e4512f00..0a28a5bb52 100644 --- a/src/library/scala/annotation/meta/getter.scala +++ b/src/library/scala/annotation/meta/getter.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class getter extends annotation.StaticAnnotation +final class getter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/languageFeature.scala b/src/library/scala/annotation/meta/languageFeature.scala index 23acc01b51..2e0ddb91cf 100644 --- a/src/library/scala/annotation/meta/languageFeature.scala +++ b/src/library/scala/annotation/meta/languageFeature.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * An annotation giving particulars for a language feature in object `scala.language`. */ -final class languageFeature(feature: String, enableRequired: Boolean) extends annotation.StaticAnnotation +final class languageFeature(feature: String, enableRequired: Boolean) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/param.scala b/src/library/scala/annotation/meta/param.scala index d9ebcc76d3..ef535d79c6 100644 --- a/src/library/scala/annotation/meta/param.scala +++ b/src/library/scala/annotation/meta/param.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class param extends annotation.StaticAnnotation +final class param extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/setter.scala b/src/library/scala/annotation/meta/setter.scala index c27cee2985..87ee2e28f4 100644 --- a/src/library/scala/annotation/meta/setter.scala +++ b/src/library/scala/annotation/meta/setter.scala @@ -10,4 +10,4 @@ package scala.annotation.meta /** * Consult the documentation in package [[scala.annotation.meta]]. */ -final class setter extends annotation.StaticAnnotation +final class setter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/migration.scala b/src/library/scala/annotation/migration.scala index 8ab12a7c8e..f60c827620 100644 --- a/src/library/scala/annotation/migration.scala +++ b/src/library/scala/annotation/migration.scala @@ -24,7 +24,7 @@ package scala.annotation * * @since 2.8 */ - private[scala] final class migration(message: String, changedIn: String) extends annotation.StaticAnnotation { + private[scala] final class migration(message: String, changedIn: String) extends scala.annotation.StaticAnnotation { @deprecated("Use the constructor taking two Strings instead.", "2.10") def this(majorVersion: Int, minorVersion: Int, message: String) = this(message, majorVersion + "." + minorVersion) - } \ No newline at end of file + } diff --git a/src/library/scala/annotation/serializable.scala b/src/library/scala/annotation/serializable.scala index 5a0d1261d6..e300ae9010 100644 --- a/src/library/scala/annotation/serializable.scala +++ b/src/library/scala/annotation/serializable.scala @@ -12,4 +12,4 @@ package scala.annotation * An annotation that designates the class to which it is applied as serializable */ @deprecated("instead of `@serializable class C`, use `class C extends Serializable`", "2.9.0") -class serializable extends annotation.StaticAnnotation +class serializable extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/strictfp.scala b/src/library/scala/annotation/strictfp.scala index e4efa6e663..4c33ea9678 100644 --- a/src/library/scala/annotation/strictfp.scala +++ b/src/library/scala/annotation/strictfp.scala @@ -15,4 +15,4 @@ package scala.annotation * @version 2.9 * @since 2.9 */ -class strictfp extends annotation.StaticAnnotation +class strictfp extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/switch.scala b/src/library/scala/annotation/switch.scala index ee068f50d4..a867783455 100644 --- a/src/library/scala/annotation/switch.scala +++ b/src/library/scala/annotation/switch.scala @@ -26,4 +26,4 @@ package scala.annotation * @author Paul Phillips * @since 2.8 */ -final class switch extends annotation.StaticAnnotation +final class switch extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/tailrec.scala b/src/library/scala/annotation/tailrec.scala index 14775535e8..020f0c4325 100644 --- a/src/library/scala/annotation/tailrec.scala +++ b/src/library/scala/annotation/tailrec.scala @@ -16,4 +16,4 @@ package scala.annotation * * @since 2.8 */ -final class tailrec extends annotation.StaticAnnotation +final class tailrec extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/unchecked/uncheckedStable.scala b/src/library/scala/annotation/unchecked/uncheckedStable.scala index 13b500fe44..8162a3ab11 100644 --- a/src/library/scala/annotation/unchecked/uncheckedStable.scala +++ b/src/library/scala/annotation/unchecked/uncheckedStable.scala @@ -12,4 +12,4 @@ package scala.annotation.unchecked * * @since 2.7 */ -final class uncheckedStable extends annotation.StaticAnnotation {} +final class uncheckedStable extends scala.annotation.StaticAnnotation {} diff --git a/src/library/scala/annotation/unchecked/uncheckedVariance.scala b/src/library/scala/annotation/unchecked/uncheckedVariance.scala index 51433be79f..61a0ebc6b8 100644 --- a/src/library/scala/annotation/unchecked/uncheckedVariance.scala +++ b/src/library/scala/annotation/unchecked/uncheckedVariance.scala @@ -12,4 +12,4 @@ package scala.annotation.unchecked * * @since 2.7 */ -final class uncheckedVariance extends annotation.StaticAnnotation {} +final class uncheckedVariance extends scala.annotation.StaticAnnotation {} diff --git a/src/library/scala/annotation/unspecialized.scala b/src/library/scala/annotation/unspecialized.scala index 28d9aa169c..717ca1597d 100644 --- a/src/library/scala/annotation/unspecialized.scala +++ b/src/library/scala/annotation/unspecialized.scala @@ -14,4 +14,4 @@ package scala.annotation * * @since 2.10 */ -class unspecialized extends annotation.StaticAnnotation +class unspecialized extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/varargs.scala b/src/library/scala/annotation/varargs.scala index 1d7a2f7183..b44f8c505e 100644 --- a/src/library/scala/annotation/varargs.scala +++ b/src/library/scala/annotation/varargs.scala @@ -14,4 +14,4 @@ package scala.annotation * * @since 2.9 */ -final class varargs extends annotation.StaticAnnotation +final class varargs extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/beans/BeanDescription.scala b/src/library/scala/beans/BeanDescription.scala index d6c9b0c736..5e1d3b873e 100644 --- a/src/library/scala/beans/BeanDescription.scala +++ b/src/library/scala/beans/BeanDescription.scala @@ -15,5 +15,5 @@ package scala.beans * * @author Ross Judson (rjudson@managedobjects.com) */ -class BeanDescription(val description: String) extends annotation.Annotation +class BeanDescription(val description: String) extends scala.annotation.Annotation diff --git a/src/library/scala/beans/BeanDisplayName.scala b/src/library/scala/beans/BeanDisplayName.scala index fbbfa08ffc..2c862e3700 100644 --- a/src/library/scala/beans/BeanDisplayName.scala +++ b/src/library/scala/beans/BeanDisplayName.scala @@ -14,5 +14,5 @@ package scala.beans * * @author Ross Judson (rjudson@managedobjects.com) */ -class BeanDisplayName(val name: String) extends annotation.Annotation +class BeanDisplayName(val name: String) extends scala.annotation.Annotation diff --git a/src/library/scala/beans/BeanInfo.scala b/src/library/scala/beans/BeanInfo.scala index 1a1d8defa4..23a55edfc5 100644 --- a/src/library/scala/beans/BeanInfo.scala +++ b/src/library/scala/beans/BeanInfo.scala @@ -17,4 +17,4 @@ package scala.beans * * @author Ross Judson (rjudson@managedobjects.com) */ -class BeanInfo extends annotation.Annotation +class BeanInfo extends scala.annotation.Annotation diff --git a/src/library/scala/beans/BeanInfoSkip.scala b/src/library/scala/beans/BeanInfoSkip.scala index 23adf74924..f08dde99d9 100644 --- a/src/library/scala/beans/BeanInfoSkip.scala +++ b/src/library/scala/beans/BeanInfoSkip.scala @@ -15,4 +15,4 @@ package scala.beans * * @author Ross Judson (rjudson@managedobjects.com) */ -class BeanInfoSkip extends annotation.Annotation +class BeanInfoSkip extends scala.annotation.Annotation diff --git a/src/library/scala/beans/BeanProperty.scala b/src/library/scala/beans/BeanProperty.scala index 4a2fb716c7..ab63e92c6f 100644 --- a/src/library/scala/beans/BeanProperty.scala +++ b/src/library/scala/beans/BeanProperty.scala @@ -23,4 +23,4 @@ package scala.beans * use the `scala.beans.BooleanBeanProperty` annotation instead. */ @scala.annotation.meta.field -class BeanProperty extends annotation.StaticAnnotation +class BeanProperty extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/beans/BooleanBeanProperty.scala b/src/library/scala/beans/BooleanBeanProperty.scala index 1c85a88c84..972d8fb77e 100644 --- a/src/library/scala/beans/BooleanBeanProperty.scala +++ b/src/library/scala/beans/BooleanBeanProperty.scala @@ -13,4 +13,4 @@ package scala.beans * named `isFieldName` instead of `getFieldName`. */ @scala.annotation.meta.field -class BooleanBeanProperty extends annotation.StaticAnnotation +class BooleanBeanProperty extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 9b04256c8d..987f124f55 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -10,7 +10,7 @@ package scala.collection import generic._ -import annotation.migration +import scala.annotation.migration /** A template trait for all traversable collections upon which operations diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index 4e0f71ee8b..a872bc0948 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -11,7 +11,7 @@ package scala.collection import scala.reflect.ClassTag import scala.collection.generic.CanBuildFrom import scala.annotation.unchecked.{ uncheckedVariance => uV } -import language.higherKinds +import scala.language.higherKinds /** A template trait for all traversable-once objects which may be * traversed in parallel. @@ -507,7 +507,7 @@ trait GenTraversableOnce[+A] extends Any { * $willNotTerminateInf * @return a buffer containing all elements of this $coll. */ - def toBuffer[A1 >: A]: collection.mutable.Buffer[A1] + def toBuffer[A1 >: A]: scala.collection.mutable.Buffer[A1] /** Converts this $coll to an unspecified Traversable. Will return * the same collection if this instance is already Traversable. @@ -565,7 +565,7 @@ trait GenTraversableOnce[+A] extends Any { /** Converts this $coll into another by copying all elements. * @tparam Col The collection type to build. * @return a new collection containing all elements of this $coll. - * + * * @usecase def to[Col[_]]: Col[A] * @inheritdoc * $willNotTerminateInf diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index ac6d754f9e..7ef3b39576 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import immutable.{ List, Stream } -import annotation.unchecked.uncheckedVariance +import scala.annotation.unchecked.uncheckedVariance /** A template trait for iterable collections of type `Iterable[A]`. * $iterableInfo diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index e0c8b21d09..d9ccb3f011 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import TraversableView.NoBuilder import immutable.Stream -import language.implicitConversions +import scala.language.implicitConversions /** A template trait for non-strict views of iterable collections. * $iterableViewInfo diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 5f369de3b7..9989a8d9e8 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -9,7 +9,7 @@ package scala.collection import mutable.ArrayBuffer -import annotation.migration +import scala.annotation.migration import immutable.Stream import scala.collection.generic.CanBuildFrom import scala.annotation.unchecked.{ uncheckedVariance => uV } @@ -393,7 +393,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def next() = if (hasNext) { hdDefined = false; hd } else empty.next() } - + /** Tests whether every element of this iterator relates to the * corresponding element of another collection by satisfying a test predicate. * @@ -1140,7 +1140,7 @@ trait Iterator[+A] extends TraversableOnce[A] { def toStream: Stream[A] = if (self.hasNext) Stream.cons(self.next, self.toStream) else Stream.empty[A] - + /** Converts this iterator to a string. * diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala index bfe27ef94a..8e72c5618c 100644 --- a/src/library/scala/collection/LinearSeqLike.scala +++ b/src/library/scala/collection/LinearSeqLike.scala @@ -13,7 +13,7 @@ import generic._ import mutable.ListBuffer import immutable.List import scala.util.control.Breaks._ -import annotation.tailrec +import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]`. * diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index ed2a877631..3877f07089 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import mutable.{ Builder, MapBuilder } -import annotation.{migration, bridge} +import scala.annotation.{migration, bridge} import parallel.ParMap /** A template trait for maps, which associate keys with values. @@ -226,21 +226,21 @@ self => */ def default(key: A): B = throw new NoSuchElementException("key not found: " + key) - + protected class FilteredKeys(p: A => Boolean) extends AbstractMap[A, B] with DefaultMap[A, B] { override def foreach[C](f: ((A, B)) => C): Unit = for (kv <- self) if (p(kv._1)) f(kv) def iterator = self.iterator.filter(kv => p(kv._1)) override def contains(key: A) = self.contains(key) && p(key) def get(key: A) = if (!p(key)) None else self.get(key) } - + /** Filters this map by retaining only keys satisfying a predicate. * @param p the predicate used to test keys * @return an immutable map consisting only of those key value pairs of this map where the key satisfies * the predicate `p`. The resulting map wraps the original map without copying any elements. */ def filterKeys(p: A => Boolean): Map[A, B] = new FilteredKeys(p) - + protected class MappedValues[C](f: B => C) extends AbstractMap[A, C] with DefaultMap[A, C] { override def foreach[D](g: ((A, C)) => D): Unit = for ((k, v) <- self) g((k, f(v))) def iterator = for ((k, v) <- self.iterator) yield (k, f(v)) @@ -248,7 +248,7 @@ self => override def contains(key: A) = self.contains(key) def get(key: A) = self.get(key).map(f) } - + /** Transforms this map by applying a function to every retrieved value. * @param f the function used to transform values of this map. * @return a map view which maps every key of this map diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index 04ec4af830..b359044f0d 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import mutable.{ Builder, SetBuilder } -import annotation.{migration, bridge} +import scala.annotation.{migration, bridge} import parallel.ParSet /** A template trait for sets. diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index b2051bf209..411d17e935 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -10,10 +10,10 @@ package scala.collection import generic._ import mutable.{ Builder } -import annotation.{tailrec, migration, bridge} -import annotation.unchecked.{ uncheckedVariance => uV } +import scala.annotation.{tailrec, migration, bridge} +import scala.annotation.unchecked.{ uncheckedVariance => uV } import parallel.ParIterable -import language.higherKinds +import scala.language.higherKinds /** A template trait for traversable collections of type `Traversable[A]`. * diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index fb73805cc5..d77d278fca 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -10,9 +10,9 @@ package scala.collection import mutable.{ Buffer, Builder, ListBuffer, ArrayBuffer } import generic.CanBuildFrom -import annotation.unchecked.{ uncheckedVariance => uV } -import language.{implicitConversions, higherKinds} -import reflect.ClassTag +import scala.annotation.unchecked.{ uncheckedVariance => uV } +import scala.language.{implicitConversions, higherKinds} +import scala.reflect.ClassTag /** A template trait for collections which can be traversed either once only * or one or more times. @@ -374,12 +374,12 @@ object TraversableOnce { implicit def alternateImplicit[A](trav: TraversableOnce[A]) = new ForceImplicitAmbiguity implicit def flattenTraversableOnce[A, CC[_]](travs: TraversableOnce[CC[A]])(implicit ev: CC[A] => TraversableOnce[A]) = new FlattenOps[A](travs map ev) - + /* Functionality reused in Iterator.CanBuildFrom */ private[collection] abstract class BufferedCanBuildFrom[A, Coll[X] <: TraversableOnce[X]] extends generic.CanBuildFrom[Coll[_], A, Coll[A]] { def bufferToColl[B](buff: ArrayBuffer[B]): Coll[B] def traversableToColl[B](t: GenTraversable[B]): Coll[B] - + def newIterator: Builder[A, Coll[A]] = new ArrayBuffer[A] mapResult bufferToColl /** Creates a new builder on request of a collection. @@ -398,7 +398,7 @@ object TraversableOnce { */ def apply() = newIterator } - + /** With the advent of `TraversableOnce`, it can be useful to have a builder which * operates on `Iterator`s so they can be treated uniformly along with the collections. * See `scala.util.Random.shuffle` or `scala.concurrent.Future.sequence` for an example. @@ -407,10 +407,10 @@ object TraversableOnce { def bufferToColl[B](buff: ArrayBuffer[B]) = buff.iterator def traversableToColl[B](t: GenTraversable[B]) = t.seq } - + /** Evidence for building collections from `TraversableOnce` collections */ implicit def OnceCanBuildFrom[A] = new OnceCanBuildFrom[A] - + class FlattenOps[A](travs: TraversableOnce[TraversableOnce[A]]) { def flatten: Iterator[A] = new AbstractIterator[A] { val its = travs.toIterator diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala index 74b30e0faf..b7be87b125 100644 --- a/src/library/scala/collection/TraversableProxyLike.scala +++ b/src/library/scala/collection/TraversableProxyLike.scala @@ -12,7 +12,7 @@ package scala.collection import generic._ import mutable.{Buffer, StringBuilder} -import reflect.ClassTag +import scala.reflect.ClassTag // Methods could be printed by cat TraversableLike.scala | egrep '^ (override )?def' diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 7fbcf1374b..5ee32e90b2 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -11,8 +11,8 @@ package scala.collection import generic._ import mutable.{ Builder, ArrayBuffer } import TraversableView.NoBuilder -import annotation.migration -import language.implicitConversions +import scala.annotation.migration +import scala.language.implicitConversions trait ViewMkString[+A] { self: Traversable[A] => diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 3d0aa6fd07..7609910b65 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -9,17 +9,14 @@ package scala.collection package concurrent - - import java.util.concurrent.atomic._ -import collection.immutable.{ ListMap => ImmutableListMap } -import collection.parallel.mutable.ParTrieMap -import util.hashing.Hashing +import scala.collection.immutable.{ ListMap => ImmutableListMap } +import scala.collection.parallel.mutable.ParTrieMap +import scala.util.hashing.Hashing +import scala.util.control.ControlThrowable import generic._ -import annotation.tailrec -import annotation.switch - - +import scala.annotation.tailrec +import scala.annotation.switch private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends INodeBase[K, V](g) { import INodeBase._ @@ -647,22 +644,22 @@ extends scala.collection.concurrent.Map[K, V] def hashing = hashingobj def equality = equalityobj @volatile var root = r - + def this(hashf: Hashing[K], ef: Equiv[K]) = this( INode.newRootNode, AtomicReferenceFieldUpdater.newUpdater(classOf[TrieMap[K, V]], classOf[AnyRef], "root"), hashf, ef ) - + def this() = this(Hashing.default, Equiv.universal) - + /* internal methods */ private def writeObject(out: java.io.ObjectOutputStream) { out.writeObject(hashf) out.writeObject(ef) - + val it = iterator while (it.hasNext) { val (k, v) = it.next() @@ -678,7 +675,7 @@ extends scala.collection.concurrent.Map[K, V] hashingobj = in.readObject().asInstanceOf[Hashing[K]] equalityobj = in.readObject().asInstanceOf[Equiv[K]] - + var obj: AnyRef = null do { obj = in.readObject() @@ -816,7 +813,7 @@ extends scala.collection.concurrent.Map[K, V] * * This method is used by other methods such as `size` and `iterator`. */ - @tailrec final def readOnlySnapshot(): collection.Map[K, V] = { + @tailrec final def readOnlySnapshot(): scala.collection.Map[K, V] = { val r = RDCSS_READ_ROOT() val expmain = r.gcasRead(this) if (RDCSS_ROOT(r, expmain, r.copyToGen(new Gen, this))) new TrieMap(r, null, hashing, equality) @@ -827,10 +824,10 @@ extends scala.collection.concurrent.Map[K, V] val r = RDCSS_READ_ROOT() if (!RDCSS_ROOT(r, r.gcasRead(this), INode.newRootNode[K, V])) clear() } - + @inline def computeHash(k: K) = hashingobj.hash(k) - + final def lookup(k: K): V = { val hc = computeHash(k) lookuphc(k, hc).asInstanceOf[V] @@ -917,11 +914,11 @@ object TrieMap extends MutableMapFactory[TrieMap] { implicit def canBuildFrom[K, V]: CanBuildFrom[Coll, (K, V), TrieMap[K, V]] = new MapCanBuildFrom[K, V] def empty[K, V]: TrieMap[K, V] = new TrieMap[K, V] - + class MangledHashing[K] extends Hashing[K] { def hash(k: K) = util.hashing.byteswap32(k.##) } - + } @@ -1058,7 +1055,7 @@ private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: } -private[concurrent] object RestartException extends util.control.ControlThrowable +private[concurrent] object RestartException extends ControlThrowable /** Only used for ctrie serialization. */ @@ -1067,7 +1064,7 @@ private[concurrent] case object TrieMapSerializationEnd private[concurrent] object Debug { - import collection._ + import scala.collection._ lazy val logbuffer = new java.util.concurrent.ConcurrentLinkedQueue[AnyRef] @@ -1083,13 +1080,3 @@ private[concurrent] object Debug { } } - - - - - - - - - - diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala index bde13f2830..e14769739d 100644 --- a/src/library/scala/collection/convert/DecorateAsJava.scala +++ b/src/library/scala/collection/convert/DecorateAsJava.scala @@ -12,7 +12,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Decorators._ import WrapAsJava._ -import language.implicitConversions +import scala.language.implicitConversions /** A collection of decorators that allow to convert between diff --git a/src/library/scala/collection/convert/DecorateAsScala.scala b/src/library/scala/collection/convert/DecorateAsScala.scala index 539584b148..4ee7e2d1c7 100644 --- a/src/library/scala/collection/convert/DecorateAsScala.scala +++ b/src/library/scala/collection/convert/DecorateAsScala.scala @@ -12,7 +12,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Decorators._ import WrapAsScala._ -import language.implicitConversions +import scala.language.implicitConversions trait DecorateAsScala { /** diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala index fcfe402a68..c79c651e96 100644 --- a/src/library/scala/collection/convert/WrapAsJava.scala +++ b/src/library/scala/collection/convert/WrapAsJava.scala @@ -11,7 +11,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Wrappers._ -import language.implicitConversions +import scala.language.implicitConversions trait WrapAsJava { /** @@ -253,7 +253,7 @@ trait WrapAsJava { case JConcurrentMapDeprecatedWrapper(wrapped) => wrapped case _ => new ConcurrentMapDeprecatedWrapper(m) } - + /** * Implicitly converts a Scala mutable `concurrent.Map` to a Java * `ConcurrentMap`. diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala index c2994a0986..6ef4243d0d 100644 --- a/src/library/scala/collection/convert/WrapAsScala.scala +++ b/src/library/scala/collection/convert/WrapAsScala.scala @@ -11,7 +11,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Wrappers._ -import language.implicitConversions +import scala.language.implicitConversions trait LowPriorityWrapAsScala { this: WrapAsScala => diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 7c97972c48..a459aa15be 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -178,12 +178,12 @@ private[collection] trait Wrappers { var prev : Option[A] = None def hasNext = ui.hasNext - + def next() = { val (k, v) = ui.next prev = Some(k) new ju.Map.Entry[A, B] { - import util.hashing.byteswap32 + import scala.util.hashing.byteswap32 def getKey = k def getValue = v def setValue(v1 : B) = self.put(k, v1) diff --git a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala index 95835d3e90..c9c75a5f23 100644 --- a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala +++ b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala @@ -9,8 +9,8 @@ package scala.collection package generic -import language.higherKinds -import reflect.ClassTag +import scala.language.higherKinds +import scala.reflect.ClassTag /** A template for companion objects of `ClassTagTraversable` and * subclasses thereof. diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala index 31fe4e100d..6ce99646e8 100644 --- a/src/library/scala/collection/generic/GenMapFactory.scala +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic import mutable.{Builder, MapBuilder} -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenSeqFactory.scala b/src/library/scala/collection/generic/GenSeqFactory.scala index 19eeba9b1d..bb352f707c 100644 --- a/src/library/scala/collection/generic/GenSeqFactory.scala +++ b/src/library/scala/collection/generic/GenSeqFactory.scala @@ -11,7 +11,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of Seq and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala index 4f812b337c..526927ce26 100644 --- a/src/library/scala/collection/generic/GenSetFactory.scala +++ b/src/library/scala/collection/generic/GenSetFactory.scala @@ -12,7 +12,7 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `Set` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 2aaf93de05..6b347db7a0 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `Traversable` and subclasses thereof. * This class provides a set of operations to create `$Coll` objects. diff --git a/src/library/scala/collection/generic/GenericClassTagCompanion.scala b/src/library/scala/collection/generic/GenericClassTagCompanion.scala index 8cce592627..fd5a3bae4c 100644 --- a/src/library/scala/collection/generic/GenericClassTagCompanion.scala +++ b/src/library/scala/collection/generic/GenericClassTagCompanion.scala @@ -10,8 +10,8 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds -import reflect.ClassTag +import scala.language.higherKinds +import scala.reflect.ClassTag /** This class represents companions of classes which require ClassTags * for their element types. diff --git a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala index d368d0007b..d5d6c53c1e 100644 --- a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala @@ -10,9 +10,9 @@ package scala.collection package generic import mutable.Builder -import annotation.unchecked.uncheckedVariance -import language.higherKinds -import reflect.ClassTag +import scala.annotation.unchecked.uncheckedVariance +import scala.language.higherKinds +import scala.reflect.ClassTag /** This trait represents collections classes which require class * tags for their element types. diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala index 1844542315..d4e77f68f5 100644 --- a/src/library/scala/collection/generic/GenericCompanion.scala +++ b/src/library/scala/collection/generic/GenericCompanion.scala @@ -10,7 +10,7 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds +import scala.language.higherKinds /** A template class for companion objects of "regular" collection classes * represent an unconstrained higher-kinded type. Typically diff --git a/src/library/scala/collection/generic/GenericOrderedCompanion.scala b/src/library/scala/collection/generic/GenericOrderedCompanion.scala index 290dc435c8..ba432f012a 100644 --- a/src/library/scala/collection/generic/GenericOrderedCompanion.scala +++ b/src/library/scala/collection/generic/GenericOrderedCompanion.scala @@ -10,7 +10,7 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds +import scala.language.higherKinds /** This class represents companions of classes which require the ordered trait * for their element types. diff --git a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala index 6e04420315..b041670161 100644 --- a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala @@ -12,8 +12,8 @@ package scala.collection package generic import mutable.Builder -import annotation.unchecked.uncheckedVariance -import language.higherKinds +import scala.annotation.unchecked.uncheckedVariance +import scala.language.higherKinds /** This trait represents collections classes which require * ordered element types. diff --git a/src/library/scala/collection/generic/GenericParCompanion.scala b/src/library/scala/collection/generic/GenericParCompanion.scala index 484da5c6d9..aea7d8f25a 100644 --- a/src/library/scala/collection/generic/GenericParCompanion.scala +++ b/src/library/scala/collection/generic/GenericParCompanion.scala @@ -11,7 +11,7 @@ package scala.collection.generic import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterable import scala.collection.parallel.ParMap -import language.higherKinds +import scala.language.higherKinds /** A template class for companion objects of parallel collection classes. * They should be mixed in together with `GenericCompanion` type. diff --git a/src/library/scala/collection/generic/GenericParTemplate.scala b/src/library/scala/collection/generic/GenericParTemplate.scala index fc1c3f5eaa..3dfdc98133 100644 --- a/src/library/scala/collection/generic/GenericParTemplate.scala +++ b/src/library/scala/collection/generic/GenericParTemplate.scala @@ -13,8 +13,8 @@ import scala.collection.parallel.ParIterable import scala.collection.parallel.ParMap import scala.collection.parallel.TaskSupport -import annotation.unchecked.uncheckedVariance -import language.higherKinds +import scala.annotation.unchecked.uncheckedVariance +import scala.language.higherKinds /** A template trait for collections having a companion. * @@ -29,7 +29,7 @@ extends GenericTraversableTemplate[A, CC] { def companion: GenericCompanion[CC] with GenericParCompanion[CC] - protected[this] override def newBuilder: collection.mutable.Builder[A, CC[A]] = newCombiner + protected[this] override def newBuilder: scala.collection.mutable.Builder[A, CC[A]] = newCombiner protected[this] override def newCombiner: Combiner[A, CC[A]] = { val cb = companion.newCombiner[A] diff --git a/src/library/scala/collection/generic/GenericSeqCompanion.scala b/src/library/scala/collection/generic/GenericSeqCompanion.scala index 90063c1ca2..63fca78a98 100644 --- a/src/library/scala/collection/generic/GenericSeqCompanion.scala +++ b/src/library/scala/collection/generic/GenericSeqCompanion.scala @@ -10,7 +10,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds trait GenericSeqCompanion[CC[X] <: Traversable[X]] - extends GenericCompanion[CC] \ No newline at end of file + extends GenericCompanion[CC] diff --git a/src/library/scala/collection/generic/GenericSetTemplate.scala b/src/library/scala/collection/generic/GenericSetTemplate.scala index 221bcfb379..cf7259100d 100644 --- a/src/library/scala/collection/generic/GenericSetTemplate.scala +++ b/src/library/scala/collection/generic/GenericSetTemplate.scala @@ -8,7 +8,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds /** * @since 2.8 */ diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 7cb0e812d8..62e7061237 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -12,9 +12,9 @@ package scala.collection package generic import mutable.Builder -import annotation.migration -import annotation.unchecked.uncheckedVariance -import language.higherKinds +import scala.annotation.migration +import scala.annotation.unchecked.uncheckedVariance +import scala.language.higherKinds /** A template class for companion objects of ``regular`` collection classes * that represent an unconstrained higher-kinded type. @@ -128,7 +128,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew * @usecase def flatten[B]: $Coll[B] * * @inheritdoc - * + * * The resulting collection's type will be guided by the * static type of $coll. For example: * @@ -138,7 +138,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew * * val ys = Set(List(1, 2, 3), List(3, 2, 1)) * // ys == Set(1, 2, 3) - * }}} + * }}} */ def flatten[B](implicit asTraversable: A => /*<: GenTraversableLike[Char, String]] } - implicit def genTraversableLikeRepr[C[_], A0](implicit conv: C[A0] => GenTraversableLike[A0,C[A0]]): IsTraversableLike[C[A0]] { type A = A0 } = + implicit def genTraversableLikeRepr[C[_], A0](implicit conv: C[A0] => GenTraversableLike[A0,C[A0]]): IsTraversableLike[C[A0]] { type A = A0 } = new IsTraversableLike[C[A0]] { type A = A0 val conversion = conv diff --git a/src/library/scala/collection/generic/IsTraversableOnce.scala b/src/library/scala/collection/generic/IsTraversableOnce.scala index b336553231..49675b4d5e 100644 --- a/src/library/scala/collection/generic/IsTraversableOnce.scala +++ b/src/library/scala/collection/generic/IsTraversableOnce.scala @@ -45,7 +45,7 @@ trait IsTraversableOnce[Repr] { } object IsTraversableOnce { - import language.higherKinds + import scala.language.higherKinds implicit val stringRepr: IsTraversableOnce[String] { type A = Char } = new IsTraversableOnce[String] { @@ -53,7 +53,7 @@ object IsTraversableOnce { val conversion = implicitly[String => GenTraversableOnce[Char]] } - implicit def genTraversableLikeRepr[C[_], A0](implicit conv: C[A0] => GenTraversableOnce[A0]): IsTraversableOnce[C[A0]] { type A = A0 } = + implicit def genTraversableLikeRepr[C[_], A0](implicit conv: C[A0] => GenTraversableOnce[A0]): IsTraversableOnce[C[A0]] { type A = A0 } = new IsTraversableOnce[C[A0]] { type A = A0 val conversion = conv diff --git a/src/library/scala/collection/generic/IterableForwarder.scala b/src/library/scala/collection/generic/IterableForwarder.scala index 89b67a6c18..d1ba252ba7 100644 --- a/src/library/scala/collection/generic/IterableForwarder.scala +++ b/src/library/scala/collection/generic/IterableForwarder.scala @@ -11,7 +11,7 @@ package scala.collection.generic import scala.collection._ -import collection.mutable.Buffer +import scala.collection.mutable.Buffer /** This trait implements a forwarder for iterable objects. It forwards * all calls to a different iterable object, except for diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala index ce44ae9bf4..cbf5e06202 100644 --- a/src/library/scala/collection/generic/MapFactory.scala +++ b/src/library/scala/collection/generic/MapFactory.scala @@ -11,7 +11,7 @@ package generic import mutable.{Builder, MapBuilder} -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/MutableMapFactory.scala b/src/library/scala/collection/generic/MutableMapFactory.scala index 8b38b4ddd5..3b3d6d1946 100644 --- a/src/library/scala/collection/generic/MutableMapFactory.scala +++ b/src/library/scala/collection/generic/MutableMapFactory.scala @@ -12,7 +12,7 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `mutable.Map` and subclasses thereof. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/MutableSetFactory.scala b/src/library/scala/collection/generic/MutableSetFactory.scala index f130489814..516cbd722d 100644 --- a/src/library/scala/collection/generic/MutableSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSetFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic import mutable.{ Builder, GrowingBuilder } -import language.higherKinds +import scala.language.higherKinds abstract class MutableSetFactory[CC[X] <: mutable.Set[X] with mutable.SetLike[X, CC[X]]] extends SetFactory[CC] { diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala index 0e90ed999c..e5a69779f3 100644 --- a/src/library/scala/collection/generic/MutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic import scala.collection.mutable.{ Builder, GrowingBuilder } -import language.higherKinds +import scala.language.higherKinds /** * @define Coll `mutable.SortedSet` diff --git a/src/library/scala/collection/generic/OrderedTraversableFactory.scala b/src/library/scala/collection/generic/OrderedTraversableFactory.scala index 92f166ae08..b3d096ccd2 100644 --- a/src/library/scala/collection/generic/OrderedTraversableFactory.scala +++ b/src/library/scala/collection/generic/OrderedTraversableFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds abstract class OrderedTraversableFactory[CC[X] <: Traversable[X] with GenericOrderedTraversableTemplate[X, CC]] extends GenericOrderedCompanion[CC] { diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index 41dca8fbe9..9624aafd06 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -10,7 +10,7 @@ package scala.collection.generic import scala.collection.parallel.ParIterable import scala.collection.parallel.Combiner -import language.higherKinds +import scala.language.higherKinds /** A template class for companion objects of `ParIterable` and subclasses * thereof. This class extends `TraversableFactory` and provides a set of diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala index 5aedf67924..fdf23581f7 100644 --- a/src/library/scala/collection/generic/ParMapFactory.scala +++ b/src/library/scala/collection/generic/ParMapFactory.scala @@ -12,7 +12,7 @@ import scala.collection.parallel.ParMap import scala.collection.parallel.ParMapLike import scala.collection.parallel.Combiner import scala.collection.mutable.Builder -import language.higherKinds +import scala.language.higherKinds /** A template class for companion objects of `ParMap` and subclasses thereof. * This class extends `TraversableFactory` and provides a set of operations diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala index 30a36a734a..e6db6f4721 100644 --- a/src/library/scala/collection/generic/ParSetFactory.scala +++ b/src/library/scala/collection/generic/ParSetFactory.scala @@ -8,11 +8,11 @@ package scala.collection.generic -import collection.mutable.Builder -import collection.parallel.Combiner -import collection.parallel.ParSet -import collection.parallel.ParSetLike -import language.higherKinds +import scala.collection.mutable.Builder +import scala.collection.parallel.Combiner +import scala.collection.parallel.ParSet +import scala.collection.parallel.ParSetLike +import scala.language.higherKinds /** * @author Aleksandar Prokopec diff --git a/src/library/scala/collection/generic/SeqFactory.scala b/src/library/scala/collection/generic/SeqFactory.scala index 3f61de6ceb..e943b93ef0 100644 --- a/src/library/scala/collection/generic/SeqFactory.scala +++ b/src/library/scala/collection/generic/SeqFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of Seq and subclasses thereof. * diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala index 646e99dd1e..f386596c26 100644 --- a/src/library/scala/collection/generic/SetFactory.scala +++ b/src/library/scala/collection/generic/SetFactory.scala @@ -12,7 +12,7 @@ package scala.collection package generic import mutable.Builder -import language.higherKinds +import scala.language.higherKinds abstract class SetFactory[CC[X] <: Set[X] with SetLike[X, CC[X]]] - extends GenSetFactory[CC] with GenericSeqCompanion[CC] \ No newline at end of file + extends GenSetFactory[CC] with GenericSeqCompanion[CC] diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala index f038c8b09b..2781cbcc15 100644 --- a/src/library/scala/collection/generic/SortedMapFactory.scala +++ b/src/library/scala/collection/generic/SortedMapFactory.scala @@ -12,7 +12,7 @@ package scala.collection package generic import mutable.{Builder, MapBuilder} -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of mutable.Map and subclasses thereof. * diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala index bb261803a9..4abccd3827 100644 --- a/src/library/scala/collection/generic/SortedSetFactory.scala +++ b/src/library/scala/collection/generic/SortedSetFactory.scala @@ -12,7 +12,7 @@ package scala.collection package generic import mutable.{Builder, SetBuilder} -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of Set and subclasses thereof. * diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index 254a6a224f..a09b92a75b 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -10,7 +10,7 @@ package scala.collection package generic -import language.higherKinds +import scala.language.higherKinds /** A template for companion objects of `Traversable` and subclasses thereof. * This class provides a set of operations to create `$Coll` objects. diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala index 5c55c27983..62c1dc095b 100644 --- a/src/library/scala/collection/generic/TraversableForwarder.scala +++ b/src/library/scala/collection/generic/TraversableForwarder.scala @@ -11,7 +11,7 @@ package scala.collection.generic import scala.collection._ import mutable.{ Buffer, StringBuilder } import immutable.{ List, Stream } -import reflect.ClassTag +import scala.reflect.ClassTag /** This trait implements a forwarder for traversable objects. It forwards * all calls to a different traversable, except for: diff --git a/src/library/scala/collection/generic/package.scala b/src/library/scala/collection/generic/package.scala index 6eecb5e3ff..dd47b7ace6 100644 --- a/src/library/scala/collection/generic/package.scala +++ b/src/library/scala/collection/generic/package.scala @@ -1,7 +1,7 @@ package scala.collection import generic.CanBuildFrom -import language.higherKinds +import scala.language.higherKinds package object generic { type CanBuild[-Elem, +To] = CanBuildFrom[Nothing, Elem, To] diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index b41327ed95..01372aa618 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -10,7 +10,7 @@ package scala.collection package immutable import generic._ -import annotation.unchecked.{ uncheckedVariance=> uV } +import scala.annotation.unchecked.{ uncheckedVariance=> uV } import parallel.immutable.ParHashMap /** This class implements immutable maps using a hash trie. @@ -72,7 +72,7 @@ class HashMap[A, +B] extends AbstractMap[A, B] } private[collection] def computeHash(key: A) = improve(elemHashCode(key)) - + import HashMap.{Merger, MergeFunction, liftMerger} private[collection] def get0(key: A, hash: Int, level: Int): Option[B] = None @@ -88,22 +88,22 @@ class HashMap[A, +B] extends AbstractMap[A, B] @deprecated("Use the `merged` method instead.", "2.10.0") def merge[B1 >: B](that: HashMap[A, B1], mergef: MergeFunction[A, B1] = null): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef)) - + /** Creates a new map which is the merge of this and the argument hash map. - * + * * Uses the specified collision resolution function if two keys are the same. * The collision resolution function will always take the first argument from * `this` hash map and the second from `that`. - * + * * The `merged` method is on average more performant than doing a traversal and reconstructing a * new immutable hash map from scratch, or `++`. - * + * * @tparam B1 the value type of the other hash map * @param that the other hash map * @param mergef the merge function or null if the first key-value pair is to be picked */ def merged[B1 >: B](that: HashMap[A, B1])(mergef: MergeFunction[A, B1]): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef)) - + protected def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = that override def par = ParHashMap.fromTrie(this) @@ -118,7 +118,7 @@ class HashMap[A, +B] extends AbstractMap[A, B] * @since 2.3 */ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int { - + private abstract class Merger[A, B] { def apply(kv1: (A, B), kv2: (A, B)): (A, B) def invert: Merger[A, B] @@ -139,7 +139,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int { def invert: Merger[A1, B1] = self } } - + /** $mapCanBuildFromInfo */ implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), HashMap[A, B]] = new MapCanBuildFrom[A, B] def empty[A, B]: HashMap[A, B] = EmptyHashMap.asInstanceOf[HashMap[A, B]] diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index d9ce7a68f7..03af4deaae 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -11,9 +11,9 @@ package scala.collection package immutable -import annotation.unchecked.{ uncheckedVariance => uV } +import scala.annotation.unchecked.{ uncheckedVariance => uV } import generic._ -import collection.parallel.immutable.ParHashSet +import scala.collection.parallel.immutable.ParHashSet /** This class implements immutable sets using a hash trie. * diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 87b58005cf..b77e8b4c7c 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -13,7 +13,7 @@ package immutable import generic._ import mutable.{Builder, ListBuffer} -import annotation.tailrec +import scala.annotation.tailrec import java.io._ /** A class for immutable linked lists representing ordered collections @@ -330,7 +330,7 @@ case object Nil extends List[Nothing] { throw new UnsupportedOperationException("tail of empty list") // Removal of equals method here might lead to an infinite recursion similar to IntMap.equals. override def equals(that: Any) = that match { - case that1: collection.GenSeq[_] => that1.isEmpty + case that1: scala.collection.GenSeq[_] => that1.isEmpty case _ => false } } diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index c21032603f..13282101b3 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -12,7 +12,7 @@ package scala.collection package immutable import generic._ -import annotation.{tailrec, bridge} +import scala.annotation.{tailrec, bridge} /** $factoryInfo * @since 1 diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index 4dd0d62fc0..6dcdee8938 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -10,7 +10,7 @@ package scala.collection package immutable import generic._ -import annotation.{tailrec, bridge} +import scala.annotation.{tailrec, bridge} import mutable.{ ListBuffer, Builder } /** $factoryInfo diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index e73da01ac4..17951e73fd 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -76,7 +76,7 @@ object Map extends ImmutableMapFactory[Map] { def empty[A, B]: Map[A, B] = EmptyMap.asInstanceOf[Map[A, B]] - class WithDefault[A, +B](underlying: Map[A, B], d: A => B) extends collection.Map.WithDefault[A, B](underlying, d) with Map[A, B] { + class WithDefault[A, +B](underlying: Map[A, B], d: A => B) extends scala.collection.Map.WithDefault[A, B](underlying, d) with Map[A, B] { override def empty = new WithDefault(underlying.empty, d) override def updated[B1 >: B](key: A, value: B1): WithDefault[A, B1] = new WithDefault[A, B1](underlying.updated[B1](key, value), d) override def + [B1 >: B](kv: (A, B1)): WithDefault[A, B1] = updated(kv._1, kv._2) diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 7d373b7b39..8975b440d2 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -13,7 +13,7 @@ package immutable import java.io._ import scala.util.matching.Regex -import reflect.ClassTag +import scala.reflect.ClassTag /** The `PagedSeq` object defines a lazy implementations of * a random access sequence. diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index e980dda847..8d82f4932f 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -11,7 +11,7 @@ package immutable import generic._ import mutable.{ Builder, ListBuffer } -import annotation.tailrec +import scala.annotation.tailrec /** `Queue` objects implement data structures that allow to * insert and retrieve elements in a first-in-first-out (FIFO) manner. diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 7607837491..a2875ec3fb 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -43,9 +43,9 @@ import scala.collection.parallel.immutable.ParRange */ @SerialVersionUID(7618862778670199309L) class Range(val start: Int, val end: Int, val step: Int) -extends collection.AbstractSeq[Int] +extends scala.collection.AbstractSeq[Int] with IndexedSeq[Int] - with collection.CustomParallelizable[Int, ParRange] + with scala.collection.CustomParallelizable[Int, ParRange] with Serializable { override def par = new ParRange(this) @@ -78,19 +78,19 @@ extends collection.AbstractSeq[Int] final val terminalElement = start + numRangeElements * step override def last = if (isEmpty) Nil.last else lastElement - + override def min[A1 >: Int](implicit ord: Ordering[A1]): Int = if (ord eq Ordering.Int) { if (step > 0) start else last } else super.min(ord) - - override def max[A1 >: Int](implicit ord: Ordering[A1]): Int = + + override def max[A1 >: Int](implicit ord: Ordering[A1]): Int = if (ord eq Ordering.Int) { if (step > 0) last else start } else super.max(ord) - + protected def copy(start: Int, end: Int, step: Int): Range = new Range(start, end, step) /** Create a new range with the `start` and `end` values of this range and diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala index 4b573511d1..9eeebb641e 100644 --- a/src/library/scala/collection/immutable/RedBlackTree.scala +++ b/src/library/scala/collection/immutable/RedBlackTree.scala @@ -11,8 +11,8 @@ package scala.collection package immutable -import annotation.tailrec -import annotation.meta.getter +import scala.annotation.tailrec +import scala.annotation.meta.getter /** An object containing the RedBlack tree implementation used by for `TreeMaps` and `TreeSets`. * diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala index f147b673f7..c0a1e0fec9 100644 --- a/src/library/scala/collection/immutable/SortedMap.scala +++ b/src/library/scala/collection/immutable/SortedMap.scala @@ -13,7 +13,7 @@ package immutable import generic._ import mutable.Builder -import annotation.unchecked.uncheckedVariance +import scala.annotation.unchecked.uncheckedVariance /** A map whose keys are sorted. * @@ -78,17 +78,17 @@ self => */ override def ++[B1 >: B](xs: GenTraversableOnce[(A, B1)]): SortedMap[A, B1] = ((repr: SortedMap[A, B1]) /: xs.seq) (_ + _) - + override def filterKeys(p: A => Boolean): SortedMap[A, B] = new FilteredKeys(p) with SortedMap.Default[A, B] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, B] = self.rangeImpl(from, until).filterKeys(p) } - + override def mapValues[C](f: B => C): SortedMap[A, C] = new MappedValues(f) with SortedMap.Default[A, C] { implicit def ordering: Ordering[A] = self.ordering override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, C] = self.rangeImpl(from, until).mapValues(f) } - + } /** $factoryInfo @@ -99,8 +99,8 @@ object SortedMap extends ImmutableSortedMapFactory[SortedMap] { /** $sortedMapCanBuildFromInfo */ implicit def canBuildFrom[A, B](implicit ord: Ordering[A]): CanBuildFrom[Coll, (A, B), SortedMap[A, B]] = new SortedMapCanBuildFrom[A, B] def empty[A, B](implicit ord: Ordering[A]): SortedMap[A, B] = TreeMap.empty[A, B] - - private[collection] trait Default[A, +B] extends SortedMap[A, B] with collection.SortedMap.Default[A, B] { + + private[collection] trait Default[A, +B] extends SortedMap[A, B] with scala.collection.SortedMap.Default[A, B] { self => override def +[B1 >: B](kv: (A, B1)): SortedMap[A, B1] = { val b = SortedMap.newBuilder[A, B1] @@ -108,7 +108,7 @@ object SortedMap extends ImmutableSortedMapFactory[SortedMap] { b += ((kv._1, kv._2)) b.result } - + override def - (key: A): SortedMap[A, B] = { val b = newBuilder for (kv <- this; if kv._1 != key) b += kv diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 97707d4f7c..bac90341ec 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -13,7 +13,7 @@ import generic._ import mutable.{Builder, StringBuilder, LazyBuilder, ListBuffer} import scala.annotation.tailrec import Stream.cons -import language.implicitConversions +import scala.language.implicitConversions /** The class `Stream` implements lazy lists where elements * are only evaluated when they are needed. Here is an example: @@ -631,7 +631,7 @@ self => * // (5,6) * }}} */ - override final def zip[A1 >: A, B, That](that: collection.GenIterable[B])(implicit bf: CanBuildFrom[Stream[A], (A1, B), That]): That = + override final def zip[A1 >: A, B, That](that: scala.collection.GenIterable[B])(implicit bf: CanBuildFrom[Stream[A], (A1, B), That]): That = // we assume there is no other builder factory on streams and therefore know that That = Stream[(A1, B)] if (isStreamBuilder(bf)) asThat( if (this.isEmpty || that.isEmpty) Stream.Empty diff --git a/src/library/scala/collection/immutable/StreamViewLike.scala b/src/library/scala/collection/immutable/StreamViewLike.scala index 3fd92aaff9..bb378bc337 100644 --- a/src/library/scala/collection/immutable/StreamViewLike.scala +++ b/src/library/scala/collection/immutable/StreamViewLike.scala @@ -51,19 +51,19 @@ extends SeqView[A, Coll] /** boilerplate */ protected override def newForced[B](xs: => collection.GenSeq[B]): Transformed[B] = new { val forced = xs } with AbstractTransformed[B] with Forced[B] - protected override def newAppended[B >: A](that: collection.GenTraversable[B]): Transformed[B] = new { val rest = that } with AbstractTransformed[B] with Appended[B] + protected override def newAppended[B >: A](that: scala.collection.GenTraversable[B]): Transformed[B] = new { val rest = that } with AbstractTransformed[B] with Appended[B] protected override def newMapped[B](f: A => B): Transformed[B] = new { val mapping = f } with AbstractTransformed[B] with Mapped[B] protected override def newFlatMapped[B](f: A => collection.GenTraversableOnce[B]): Transformed[B] = new { val mapping = f } with AbstractTransformed[B] with FlatMapped[B] protected override def newFiltered(p: A => Boolean): Transformed[A] = new { val pred = p } with AbstractTransformed[A] with Filtered protected override def newSliced(_endpoints: SliceInterval): Transformed[A] = new { val endpoints = _endpoints } with AbstractTransformed[A] with Sliced protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new { val pred = p } with AbstractTransformed[A] with DroppedWhile protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new { val pred = p } with AbstractTransformed[A] with TakenWhile - protected override def newZipped[B](that: collection.GenIterable[B]): Transformed[(A, B)] = new { val other = that } with AbstractTransformed[(A, B)] with Zipped[B] - protected override def newZippedAll[A1 >: A, B](that: collection.GenIterable[B], _thisElem: A1, _thatElem: B): Transformed[(A1, B)] = { + protected override def newZipped[B](that: scala.collection.GenIterable[B]): Transformed[(A, B)] = new { val other = that } with AbstractTransformed[(A, B)] with Zipped[B] + protected override def newZippedAll[A1 >: A, B](that: scala.collection.GenIterable[B], _thisElem: A1, _thatElem: B): Transformed[(A1, B)] = { new { val other = that; val thisElem = _thisElem; val thatElem = _thatElem } with AbstractTransformed[(A1, B)] with ZippedAll[A1, B] } protected override def newReversed: Transformed[A] = new Reversed { } - protected override def newPatched[B >: A](_from: Int, _patch: collection.GenSeq[B], _replaced: Int): Transformed[B] = { + protected override def newPatched[B >: A](_from: Int, _patch: scala.collection.GenSeq[B], _replaced: Int): Transformed[B] = { new { val from = _from; val patch = _patch; val replaced = _replaced } with AbstractTransformed[B] with Patched[B] } protected override def newPrepended[B >: A](elem: B): Transformed[B] = new { protected[this] val fst = elem } with AbstractTransformed[B] with Prepended[B] diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index af7662d2e0..4d28bf9518 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -13,7 +13,7 @@ import generic._ import mutable.Builder import scala.util.matching.Regex import scala.math.ScalaNumber -import reflect.ClassTag +import scala.reflect.ClassTag /** A companion object for the `StringLike` containing some constants. * @since 2.8 @@ -41,7 +41,7 @@ import StringLike._ * @define mayNotTerminateInf * @define willNotTerminateInf */ -trait StringLike[+Repr] extends Any with collection.IndexedSeqOptimized[Char, Repr] with Ordered[String] { +trait StringLike[+Repr] extends Any with scala.collection.IndexedSeqOptimized[Char, Repr] with Ordered[String] { self => /** Creates a string builder buffer as builder for this class */ diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala index ead1a8c744..e8e904f1f9 100644 --- a/src/library/scala/collection/immutable/TrieIterator.scala +++ b/src/library/scala/collection/immutable/TrieIterator.scala @@ -11,7 +11,7 @@ package immutable import HashMap.{ HashTrieMap, HashMapCollision1, HashMap1 } import HashSet.{ HashTrieSet, HashSetCollision1, HashSet1 } -import annotation.unchecked.{ uncheckedVariance => uV } +import scala.annotation.unchecked.{ uncheckedVariance => uV } import scala.annotation.tailrec /** Abandons any pretense of type safety for speed. You can't say I diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 4dfe147a65..82acf4ebbb 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -10,7 +10,7 @@ package scala.collection package immutable import scala.annotation.unchecked.uncheckedVariance -import compat.Platform +import scala.compat.Platform import scala.collection.generic._ import scala.collection.mutable.Builder import scala.collection.parallel.immutable.ParVector @@ -21,9 +21,9 @@ object Vector extends SeqFactory[Vector] { private[collection] class VectorReusableCBF extends GenericCanBuildFrom[Nothing] { override def apply() = newBuilder[Nothing] } - + private val VectorReusableCBF: GenericCanBuildFrom[Nothing] = new VectorReusableCBF - + @inline implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] = VectorReusableCBF.asInstanceOf[CanBuildFrom[Coll, A, Vector[A]]] def newBuilder[A]: Builder[A, Vector[A]] = new VectorBuilder[A] diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index d5308c3b1a..90b7ca03de 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -66,7 +66,7 @@ class ArrayBuffer[A](override protected val initialSize: Int) override def sizeHint(len: Int) { if (len > size && len >= 1) { val newarray = new Array[AnyRef](len) - compat.Platform.arraycopy(array, 0, newarray, 0, size0) + scala.compat.Platform.arraycopy(array, 0, newarray, 0, size0) array = newarray } } @@ -93,7 +93,7 @@ class ArrayBuffer[A](override protected val initialSize: Int) * @return the updated buffer. */ override def ++=(xs: TraversableOnce[A]): this.type = xs match { - case v: collection.IndexedSeqLike[_, _] => + case v: scala.collection.IndexedSeqLike[_, _] => val n = v.length ensureSize(size0 + n) v.copyToArray(array.asInstanceOf[scala.Array[Any]], size0, n) diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index b3cd6a95c5..c87feaddc5 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -9,7 +9,7 @@ package scala.collection package mutable -import compat.Platform.arraycopy +import scala.compat.Platform.arraycopy import scala.reflect.ClassTag import scala.runtime.ScalaRunTime._ import parallel.mutable.ParArray @@ -62,7 +62,7 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza */ def flatten[U](implicit asTrav: T => collection.Traversable[U], m: ClassTag[U]): Array[U] = { val b = Array.newBuilder[U] - b.sizeHint(map{case is: collection.IndexedSeq[_] => is.size case _ => 0}.sum) + b.sizeHint(map{case is: scala.collection.IndexedSeq[_] => is.size case _ => 0}.sum) for (xs <- this) b ++= asTrav(xs) b.result diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index 8f834d265b..e408d74353 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -10,7 +10,7 @@ package scala.collection package mutable import generic._ -import reflect.ClassTag +import scala.reflect.ClassTag /** Factory object for the `ArrayStack` class. * diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index e77c1256a0..91983ba0d2 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -13,7 +13,7 @@ package mutable import generic._ import script._ -import annotation.{migration, bridge} +import scala.annotation.{migration, bridge} /** A template trait for buffers of type `Buffer[A]`. * @@ -93,7 +93,7 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] * @throws IndexOutOfBoundsException if the index `n` is not in the valid range * `0 <= n <= length`. */ - def insertAll(n: Int, elems: collection.Traversable[A]) + def insertAll(n: Int, elems: scala.collection.Traversable[A]) /** Removes the element at a given index from this buffer. * diff --git a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala index ebccacf976..feff48cca3 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala @@ -11,7 +11,7 @@ package scala.collection package mutable -import annotation.migration +import scala.annotation.migration /** This extensible class may be used as a basis for implementing double * linked lists. Type variable `A` refers to the element type diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index bf640cdb90..da486f4042 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -98,12 +98,12 @@ extends AbstractMap[A, B] override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f(e.key, e.value)) /* Override to avoid tuple allocation in foreach */ - override def keySet: collection.Set[A] = new DefaultKeySet { + override def keySet: scala.collection.Set[A] = new DefaultKeySet { override def foreach[C](f: A => C) = foreachEntry(e => f(e.key)) } /* Override to avoid tuple allocation in foreach */ - override def values: collection.Iterable[B] = new DefaultValuesIterable { + override def values: scala.collection.Iterable[B] = new DefaultValuesIterable { override def foreach[C](f: B => C) = foreachEntry(e => f(e.value)) } diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala index e040d1e421..b263b46d36 100644 --- a/src/library/scala/collection/mutable/HashSet.scala +++ b/src/library/scala/collection/mutable/HashSet.scala @@ -12,7 +12,7 @@ package scala.collection package mutable import generic._ -import collection.parallel.mutable.ParHashSet +import scala.collection.parallel.mutable.ParHashSet /** This class implements mutable sets using a hashtable. * diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 97e794f06e..67e7348672 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -452,7 +452,7 @@ private[collection] object HashTable { val seedvalue: Int, val sizemap: Array[Int] ) { - import collection.DebugUtils._ + import scala.collection.DebugUtils._ private[collection] def debugInformation = buildString { append => append("Hash table contents") diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala index 3232179dbb..1a3b7119a9 100644 --- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala +++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala @@ -11,7 +11,7 @@ package scala.collection package mutable -import annotation.migration +import scala.annotation.migration /** This class can be used as an adaptor to create mutable maps from * immutable map implementations. Only method `empty` has @@ -42,17 +42,17 @@ extends AbstractMap[A, B] override def isDefinedAt(key: A) = imap.isDefinedAt(key) - override def keySet: collection.Set[A] = imap.keySet + override def keySet: scala.collection.Set[A] = imap.keySet override def keysIterator: Iterator[A] = imap.keysIterator @migration("`keys` returns Iterable[A] rather than Iterator[A].", "2.8.0") - override def keys: collection.Iterable[A] = imap.keys + override def keys: scala.collection.Iterable[A] = imap.keys override def valuesIterator: Iterator[B] = imap.valuesIterator @migration("`values` returns Iterable[B] rather than Iterator[B].", "2.8.0") - override def values: collection.Iterable[B] = imap.values + override def values: scala.collection.Iterable[B] = imap.values def iterator: Iterator[(A, B)] = imap.iterator diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index a0de2ec8ad..ab3d0ec312 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -14,7 +14,7 @@ package mutable import generic._ import TraversableView.NoBuilder -import language.implicitConversions +import scala.language.implicitConversions /** A non-strict view of a mutable `IndexedSeq`. * $viewInfo diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala index 59004a3de6..307836907c 100644 --- a/src/library/scala/collection/mutable/LinkedListLike.scala +++ b/src/library/scala/collection/mutable/LinkedListLike.scala @@ -12,7 +12,7 @@ package scala.collection package mutable import generic._ -import annotation.tailrec +import scala.annotation.tailrec /** This extensible class may be used as a basis for implementing linked * list. Type variable `A` refers to the element type of the diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index 207b3f3324..8ae3f20cc8 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -71,7 +71,7 @@ object Map extends MutableMapFactory[Map] { def empty[A, B]: Map[A, B] = new HashMap[A, B] - class WithDefault[A, B](underlying: Map[A, B], d: A => B) extends collection.Map.WithDefault(underlying, d) with Map[A, B] { + class WithDefault[A, B](underlying: Map[A, B], d: A => B) extends scala.collection.Map.WithDefault(underlying, d) with Map[A, B] { override def += (kv: (A, B)) = {underlying += kv; this} def -= (key: A) = {underlying -= key; this} override def empty = new WithDefault(underlying.empty, d) diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala index 3046207533..56be5adcca 100644 --- a/src/library/scala/collection/mutable/MapLike.scala +++ b/src/library/scala/collection/mutable/MapLike.scala @@ -11,7 +11,7 @@ package scala.collection package mutable import generic._ -import annotation.{migration, bridge} +import scala.annotation.{migration, bridge} import parallel.mutable.ParMap /** A template trait for mutable maps. diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index 6b5079e402..aaf26327b2 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -70,8 +70,8 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa def undo() { throw new UnsupportedOperationException("cannot undo") } }) } - - abstract override def insertAll(n: Int, elems: collection.Traversable[A]) { + + abstract override def insertAll(n: Int, elems: scala.collection.Traversable[A]) { super.insertAll(n, elems) var curr = n - 1 val msg = elems.foldLeft(new Script[A]() with Undoable { @@ -83,5 +83,5 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa } publish(msg) } - + } diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala index c7d10573c9..54bf93252f 100644 --- a/src/library/scala/collection/mutable/ResizableArray.scala +++ b/src/library/scala/collection/mutable/ResizableArray.scala @@ -96,7 +96,7 @@ trait ResizableArray[A] extends IndexedSeq[A] newsize = newsize * 2 val newar: Array[AnyRef] = new Array(newsize) - compat.Platform.arraycopy(array, 0, newar, 0, size0) + scala.compat.Platform.arraycopy(array, 0, newar, 0, size0) array = newar } } @@ -112,7 +112,7 @@ trait ResizableArray[A] extends IndexedSeq[A] /** Move parts of the array. */ protected def copy(m: Int, n: Int, len: Int) { - compat.Platform.arraycopy(array, m, array, n, len) + scala.compat.Platform.arraycopy(array, m, array, n, len) } } diff --git a/src/library/scala/collection/mutable/SetBuilder.scala b/src/library/scala/collection/mutable/SetBuilder.scala index 582ca898c7..0a95a18392 100644 --- a/src/library/scala/collection/mutable/SetBuilder.scala +++ b/src/library/scala/collection/mutable/SetBuilder.scala @@ -19,7 +19,7 @@ import generic._ * @param empty The empty element of the collection. * @since 2.8 */ -class SetBuilder[A, Coll <: collection.Set[A] with collection.SetLike[A, Coll]](empty: Coll) extends Builder[A, Coll] { +class SetBuilder[A, Coll <: scala.collection.Set[A] with scala.collection.SetLike[A, Coll]](empty: Coll) extends Builder[A, Coll] { protected var elems: Coll = empty def +=(x: A): this.type = { elems = elems + x; this } def clear() { elems = empty } diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala index 37313c8ca3..38342d4454 100644 --- a/src/library/scala/collection/mutable/SetLike.scala +++ b/src/library/scala/collection/mutable/SetLike.scala @@ -11,7 +11,7 @@ package mutable import generic._ import script._ -import annotation.{ migration, bridge } +import scala.annotation.{ migration, bridge } import parallel.mutable.ParSet /** A template trait for mutable sets of type `mutable.Set[A]`. diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala index 78d12f3d64..809f584f4d 100644 --- a/src/library/scala/collection/mutable/SortedSet.scala +++ b/src/library/scala/collection/mutable/SortedSet.scala @@ -20,7 +20,7 @@ import generic._ * @author Lucien Pereira * */ -trait SortedSet[A] extends collection.SortedSet[A] with collection.SortedSetLike[A,SortedSet[A]] +trait SortedSet[A] extends scala.collection.SortedSet[A] with scala.collection.SortedSetLike[A,SortedSet[A]] with mutable.Set[A] with mutable.SetLike[A, SortedSet[A]] { /** Needs to be overridden in subclasses. */ diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index db9e48d1cf..1ba531ac82 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -12,9 +12,9 @@ package scala.collection package mutable import generic._ -import collection.immutable.{List, Nil} -import collection.Iterator -import annotation.migration +import scala.collection.immutable.{List, Nil} +import scala.collection.Iterator +import scala.annotation.migration /** Factory object for the `mutable.Stack` class. * diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index 08c881dbb8..92506548e9 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -10,7 +10,7 @@ package scala.collection package mutable import java.lang.{ StringBuilder => JavaStringBuilder } -import annotation.migration +import scala.annotation.migration import immutable.StringLike /** A builder for mutable sequence of characters. This class provides an API diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala index 037b8ec5f5..6b3264a66d 100644 --- a/src/library/scala/collection/mutable/SynchronizedMap.scala +++ b/src/library/scala/collection/mutable/SynchronizedMap.scala @@ -11,7 +11,7 @@ package scala.collection package mutable -import annotation.migration +import scala.annotation.migration /** This class should be used as a mixin. It synchronizes the `Map` * functions of the class into which it is mixed in. @@ -41,14 +41,14 @@ trait SynchronizedMap[A, B] extends Map[A, B] { override def transform(f: (A, B) => B): this.type = synchronized[this.type] { super.transform(f) } override def retain(p: (A, B) => Boolean): this.type = synchronized[this.type] { super.retain(p) } @migration("`values` returns `Iterable[B]` rather than `Iterator[B]`.", "2.8.0") - override def values: collection.Iterable[B] = synchronized { super.values } + override def values: scala.collection.Iterable[B] = synchronized { super.values } override def valuesIterator: Iterator[B] = synchronized { super.valuesIterator } override def clone(): Self = synchronized { super.clone() } override def foreach[U](f: ((A, B)) => U) = synchronized { super.foreach(f) } override def apply(key: A): B = synchronized { super.apply(key) } - override def keySet: collection.Set[A] = synchronized { super.keySet } + override def keySet: scala.collection.Set[A] = synchronized { super.keySet } @migration("`keys` returns `Iterable[A]` rather than `Iterator[A]`.", "2.8.0") - override def keys: collection.Iterable[A] = synchronized { super.keys } + override def keys: scala.collection.Iterable[A] = synchronized { super.keys } override def keysIterator: Iterator[A] = synchronized { super.keysIterator } override def isEmpty: Boolean = synchronized { super.isEmpty } override def contains(key: A): Boolean = synchronized {super.contains(key) } diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala index 6785aba10d..1c913c7ce7 100644 --- a/src/library/scala/collection/mutable/UnrolledBuffer.scala +++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala @@ -8,11 +8,11 @@ package scala.collection.mutable -import collection.AbstractIterator -import collection.Iterator -import collection.generic._ -import annotation.tailrec -import reflect.ClassTag +import scala.collection.AbstractIterator +import scala.collection.Iterator +import scala.collection.generic._ +import scala.annotation.tailrec +import scala.reflect.ClassTag /** A buffer that stores elements in an unrolled linked list. * @@ -43,11 +43,11 @@ import reflect.ClassTag */ @SerialVersionUID(1L) class UnrolledBuffer[T](implicit val tag: ClassTag[T]) -extends collection.mutable.AbstractBuffer[T] - with collection.mutable.Buffer[T] - with collection.mutable.BufferLike[T, UnrolledBuffer[T]] +extends scala.collection.mutable.AbstractBuffer[T] + with scala.collection.mutable.Buffer[T] + with scala.collection.mutable.BufferLike[T, UnrolledBuffer[T]] with GenericClassTagTraversableTemplate[T, UnrolledBuffer] - with collection.mutable.Builder[T, UnrolledBuffer[T]] + with scala.collection.mutable.Builder[T, UnrolledBuffer[T]] with Serializable { import UnrolledBuffer.Unrolled @@ -153,7 +153,7 @@ extends collection.mutable.AbstractBuffer[T] this } - def insertAll(idx: Int, elems: collection.Traversable[T]) = + def insertAll(idx: Int, elems: scala.collection.Traversable[T]) = if (idx >= 0 && idx <= sz) { headptr.insertAll(idx, elems, this) sz += elems.size @@ -181,7 +181,7 @@ extends collection.mutable.AbstractBuffer[T] } override def clone(): UnrolledBuffer[T] = new UnrolledBuffer[T] ++= this - + override def stringPrefix = "UnrolledBuffer" } @@ -285,7 +285,7 @@ object UnrolledBuffer extends ClassTagTraversableFactory[UnrolledBuffer] { if (next eq null) true else false // checks if last node was thrown out } else false - @tailrec final def insertAll(idx: Int, t: collection.Traversable[T], buffer: UnrolledBuffer[T]): Unit = if (idx < size) { + @tailrec final def insertAll(idx: Int, t: scala.collection.Traversable[T], buffer: UnrolledBuffer[T]): Unit = if (idx < size) { // divide this node at the appropriate position and insert all into head // update new next val newnextnode = new Unrolled[T](0, new Array(array.length), null, buff) diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index ef693ab7ca..1959aab056 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -24,13 +24,13 @@ import scala.collection.GenIterable import scala.collection.GenTraversableOnce import scala.collection.GenTraversable import immutable.HashMapCombiner -import reflect.{ClassTag, classTag} +import scala.reflect.{ClassTag, classTag} import java.util.concurrent.atomic.AtomicBoolean -import annotation.unchecked.uncheckedVariance -import annotation.unchecked.uncheckedStable -import language.{ higherKinds, implicitConversions } +import scala.annotation.unchecked.uncheckedVariance +import scala.annotation.unchecked.uncheckedStable +import scala.language.{ higherKinds, implicitConversions } /** A template trait for parallel collections of type `ParIterable[T]`. @@ -263,7 +263,7 @@ self: ParIterableLike[T, Repr, Sequential] => /** The `newBuilder` operation returns a parallel builder assigned to this collection's fork/join pool. * This method forwards the call to `newCombiner`. */ - //protected[this] def newBuilder: collection.mutable.Builder[T, Repr] = newCombiner + //protected[this] def newBuilder: scala.collection.mutable.Builder[T, Repr] = newCombiner /** Optionally reuses an existing combiner for better performance. By default it doesn't - subclasses may override this behaviour. * The provided combiner `oldc` that can potentially be reused will be either some combiner from the previous computational task, or `None` if there @@ -859,7 +859,7 @@ self: ParIterableLike[T, Repr, Sequential] => override def toList: List[T] = seq.toList - override def toIndexedSeq: collection.immutable.IndexedSeq[T] = seq.toIndexedSeq + override def toIndexedSeq: scala.collection.immutable.IndexedSeq[T] = seq.toIndexedSeq override def toStream: Stream[T] = seq.toStream @@ -867,7 +867,7 @@ self: ParIterableLike[T, Repr, Sequential] => // the methods below are overridden - override def toBuffer[U >: T]: collection.mutable.Buffer[U] = seq.toBuffer // have additional, parallel buffers? + override def toBuffer[U >: T]: scala.collection.mutable.Buffer[U] = seq.toBuffer // have additional, parallel buffers? override def toTraversable: GenTraversable[T] = this.asInstanceOf[GenTraversable[T]] @@ -1496,7 +1496,7 @@ self: ParIterableLike[T, Repr, Sequential] => debugBuffer += s } - import collection.DebugUtils._ + import scala.collection.DebugUtils._ private[parallel] def printDebugBuffer() = println(buildString { append => for (s <- debugBuffer) { diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index 91eefc2aa5..4f6962ff05 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -18,7 +18,7 @@ import scala.collection.GenSeq import scala.collection.generic.{ CanBuildFrom, SliceInterval } import scala.collection.generic.CanCombineFrom import scala.collection.parallel.immutable.ParRange -import language.implicitConversions +import scala.language.implicitConversions diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala index afd1f30903..8bf7334c5f 100644 --- a/src/library/scala/collection/parallel/ParMapLike.scala +++ b/src/library/scala/collection/parallel/ParMapLike.scala @@ -16,7 +16,7 @@ import scala.collection.MapLike import scala.collection.GenMapLike import scala.collection.Map import scala.collection.mutable.Builder -import annotation.unchecked.uncheckedVariance +import scala.annotation.unchecked.uncheckedVariance import scala.collection.generic.IdleSignalling import scala.collection.generic.Signalling diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index 7a0116b3b3..67552e1c89 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -16,7 +16,7 @@ import scala.concurrent.forkjoin._ import scala.concurrent.ExecutionContext import scala.util.control.Breaks._ -import annotation.unchecked.uncheckedVariance +import scala.annotation.unchecked.uncheckedVariance @@ -534,11 +534,11 @@ trait AdaptiveWorkStealingThreadPoolTasks extends ThreadPoolTasks with AdaptiveW trait ExecutionContextTasks extends Tasks { - + def executionContext = environment - + val environment: ExecutionContext - + // this part is a hack which allows switching val driver: Tasks = executionContext match { case eci: scala.concurrent.impl.ExecutionContextImpl => eci.executor match { @@ -548,13 +548,13 @@ trait ExecutionContextTasks extends Tasks { } case _ => ??? } - + def execute[R, Tp](task: Task[R, Tp]): () => R = driver execute task - + def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R = driver executeAndWaitResult task - + def parallelismLevel = driver.parallelismLevel - + } diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index c9876c4d74..7f5255f5a3 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -20,8 +20,8 @@ import scala.collection.generic.CanCombineFrom import scala.collection.generic.GenericParMapTemplate import scala.collection.generic.GenericParMapCompanion import scala.collection.immutable.{ HashMap, TrieIterator } -import annotation.unchecked.uncheckedVariance -import collection.parallel.Task +import scala.annotation.unchecked.uncheckedVariance +import scala.collection.parallel.Task @@ -118,9 +118,9 @@ self => def remaining = sz - i override def toString = "HashTrieIterator(" + sz + ")" } - + /* debug */ - + private[parallel] def printDebugInfo() { println("Parallel hash trie") println("Top level inner trie type: " + trie.getClass) @@ -159,7 +159,7 @@ object ParHashMap extends ParMapFactory[ParHashMap] { private[parallel] abstract class HashMapCombiner[K, V] -extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), HashMapCombiner[K, V]](HashMapCombiner.rootsize) { +extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), HashMapCombiner[K, V]](HashMapCombiner.rootsize) { //self: EnvironmentPassingCombiner[(K, V), ParHashMap[K, V]] => import HashMapCombiner._ val emptyTrie = HashMap.empty[K, V] @@ -202,7 +202,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], (K, V), Has def groupByKey[Repr](cbf: () => Combiner[V, Repr]): ParHashMap[K, Repr] = { val bucks = buckets.filter(_ != null).map(_.headPtr) val root = new Array[HashMap[K, AnyRef]](bucks.length) - + combinerTaskSupport.executeAndWaitResult(new CreateGroupedTrie(cbf, bucks, root, 0, bucks.length)) var bitmap = 0 diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index d1899601d7..42d00623ab 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -21,7 +21,7 @@ import scala.collection.generic.GenericParTemplate import scala.collection.generic.GenericParCompanion import scala.collection.generic.GenericCompanion import scala.collection.immutable.{ HashSet, TrieIterator } -import collection.parallel.Task +import scala.collection.parallel.Task @@ -132,7 +132,7 @@ object ParHashSet extends ParSetFactory[ParHashSet] { private[immutable] abstract class HashSetCombiner[T] -extends collection.parallel.BucketCombiner[T, ParHashSet[T], Any, HashSetCombiner[T]](HashSetCombiner.rootsize) { +extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], Any, HashSetCombiner[T]](HashSetCombiner.rootsize) { //self: EnvironmentPassingCombiner[T, ParHashSet[T]] => import HashSetCombiner._ val emptyTrie = HashSet.empty[T] diff --git a/src/library/scala/collection/parallel/immutable/ParIterable.scala b/src/library/scala/collection/parallel/immutable/ParIterable.scala index 349f4fa44c..4b0773ce7b 100644 --- a/src/library/scala/collection/parallel/immutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/immutable/ParIterable.scala @@ -31,7 +31,7 @@ import scala.collection.GenIterable */ trait ParIterable[+T] extends collection/*.immutable*/.GenIterable[T] - with collection.parallel.ParIterable[T] + with scala.collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], collection.immutable.Iterable[T]] with Immutable diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala index 5060b36e7a..74b2672e67 100644 --- a/src/library/scala/collection/parallel/immutable/ParMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParMap.scala @@ -56,7 +56,7 @@ self => * @param d the function mapping keys to values, used for non-present keys * @return a wrapper of the map with a default value */ - def withDefault[U >: V](d: K => U): collection.parallel.immutable.ParMap[K, U] = new ParMap.WithDefault[K, U](this, d) + def withDefault[U >: V](d: K => U): scala.collection.parallel.immutable.ParMap[K, U] = new ParMap.WithDefault[K, U](this, d) /** The same map with a given default value. * @@ -65,7 +65,7 @@ self => * @param d the function mapping keys to values, used for non-present keys * @return a wrapper of the map with a default value */ - def withDefaultValue[U >: V](d: U): collection.parallel.immutable.ParMap[K, U] = new ParMap.WithDefault[K, U](this, x => d) + def withDefaultValue[U >: V](d: U): scala.collection.parallel.immutable.ParMap[K, U] = new ParMap.WithDefault[K, U](this, x => d) } @@ -79,7 +79,7 @@ object ParMap extends ParMapFactory[ParMap] { implicit def canBuildFrom[K, V]: CanCombineFrom[Coll, (K, V), ParMap[K, V]] = new CanCombineFromMap[K, V] class WithDefault[K, +V](underlying: ParMap[K, V], d: K => V) - extends collection.parallel.ParMap.WithDefault[K, V](underlying, d) with ParMap[K, V] { + extends scala.collection.parallel.ParMap.WithDefault[K, V](underlying, d) with ParMap[K, V] { override def empty = new WithDefault(underlying.empty, d) override def updated[U >: V](key: K, value: U): WithDefault[K, U] = new WithDefault[K, U](underlying.updated[U](key, value), d) override def + [U >: V](kv: (K, U)): WithDefault[K, U] = updated(kv._1, kv._2) diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala index dde6533c82..300efe9a58 100644 --- a/src/library/scala/collection/parallel/immutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala @@ -29,7 +29,7 @@ import scala.collection.GenSeq */ trait ParSeq[+T] extends collection/*.immutable*/.GenSeq[T] - with collection.parallel.ParSeq[T] + with scala.collection.parallel.ParSeq[T] with ParIterable[T] with GenericParTemplate[T, ParSeq] with ParSeqLike[T, ParSeq[T], collection.immutable.Seq[T]] diff --git a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala index 3694f40477..44ae7e2ce9 100644 --- a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala @@ -22,7 +22,7 @@ import scala.collection.parallel.Combiner * @tparam Buff the type of the buffers that contain leaf results and this combiner chains together */ trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing] extends Combiner[Elem, To] { -//self: collection.parallel.EnvironmentPassingCombiner[Elem, To] => +//self: scala.collection.parallel.EnvironmentPassingCombiner[Elem, To] => val chain: ArrayBuffer[Buff] val lastbuff = chain.last def +=(elem: Elem) = { lastbuff += elem; this } diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala index d0c7f6050e..c7f025207c 100644 --- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala @@ -9,7 +9,7 @@ package scala.collection package parallel.mutable -import collection.parallel.IterableSplitter +import scala.collection.parallel.IterableSplitter /** Parallel flat hash table. * @@ -19,13 +19,13 @@ import collection.parallel.IterableSplitter * * @author Aleksandar Prokopec */ -trait ParFlatHashTable[T] extends collection.mutable.FlatHashTable[T] { +trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] { override def alwaysInitSizeMap = true abstract class ParFlatHashTableIterator(var idx: Int, val until: Int, val totalsize: Int) extends IterableSplitter[T] with SizeMapUtils { - import collection.DebugUtils._ + import scala.collection.DebugUtils._ private var traversed = 0 private val itertable = table diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 8d39d6e0de..33a39e6038 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -12,12 +12,12 @@ package mutable -import collection.generic._ -import collection.mutable.DefaultEntry -import collection.mutable.HashEntry -import collection.mutable.HashTable -import collection.mutable.UnrolledBuffer -import collection.parallel.Task +import scala.collection.generic._ +import scala.collection.mutable.DefaultEntry +import scala.collection.mutable.HashEntry +import scala.collection.mutable.HashTable +import scala.collection.mutable.UnrolledBuffer +import scala.collection.parallel.Task @@ -157,8 +157,8 @@ object ParHashMap extends ParMapFactory[ParHashMap] { private[mutable] abstract class ParHashMapCombiner[K, V](private val tableLoadFactor: Int) -extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntry[K, V], ParHashMapCombiner[K, V]](ParHashMapCombiner.numblocks) - with collection.mutable.HashTable.HashUtils[K] +extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntry[K, V], ParHashMapCombiner[K, V]](ParHashMapCombiner.numblocks) + with scala.collection.mutable.HashTable.HashUtils[K] { private var mask = ParHashMapCombiner.discriminantmask private var nonmasklen = ParHashMapCombiner.nonmasklength diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 783f8dce77..870cae75de 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -10,11 +10,11 @@ package scala.collection.parallel.mutable -import collection.generic._ -import collection.mutable.FlatHashTable -import collection.parallel.Combiner -import collection.mutable.UnrolledBuffer -import collection.parallel.Task +import scala.collection.generic._ +import scala.collection.mutable.FlatHashTable +import scala.collection.parallel.Combiner +import scala.collection.mutable.UnrolledBuffer +import scala.collection.parallel.Task @@ -88,7 +88,7 @@ extends ParSet[T] init(in, x => x) } - import collection.DebugUtils._ + import scala.collection.DebugUtils._ override def debugInformation = buildString { append => append("Parallel flat hash table set") @@ -117,8 +117,8 @@ object ParHashSet extends ParSetFactory[ParHashSet] { private[mutable] abstract class ParHashSetCombiner[T](private val tableLoadFactor: Int) -extends collection.parallel.BucketCombiner[T, ParHashSet[T], Any, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks) -with collection.mutable.FlatHashTable.HashUtils[T] { +extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], Any, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks) +with scala.collection.mutable.FlatHashTable.HashUtils[T] { //self: EnvironmentPassingCombiner[T, ParHashSet[T]] => private var mask = ParHashSetCombiner.discriminantmask private var nonmasklen = ParHashSetCombiner.nonmasklength diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala index 8c93732427..7cf464c287 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala @@ -13,8 +13,8 @@ package parallel.mutable -import collection.mutable.HashEntry -import collection.parallel.IterableSplitter +import scala.collection.mutable.HashEntry +import scala.collection.parallel.IterableSplitter @@ -22,7 +22,7 @@ import collection.parallel.IterableSplitter * enriching the data structure by fulfilling certain requirements * for their parallel construction and iteration. */ -trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends collection.mutable.HashTable[K, Entry] { +trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends scala.collection.mutable.HashTable[K, Entry] { override def alwaysInitSizeMap = true diff --git a/src/library/scala/collection/parallel/mutable/ParIterable.scala b/src/library/scala/collection/parallel/mutable/ParIterable.scala index b5747a31cf..a2847c3beb 100644 --- a/src/library/scala/collection/parallel/mutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/mutable/ParIterable.scala @@ -27,7 +27,7 @@ import scala.collection.GenIterable * @since 2.9 */ trait ParIterable[T] extends collection/*.mutable*/.GenIterable[T] - with collection.parallel.ParIterable[T] + with scala.collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], Iterable[T]] with Mutable { @@ -39,7 +39,7 @@ trait ParIterable[T] extends collection/*.mutable*/.GenIterable[T] override def toSeq: ParSeq[T] = toParCollection[T, ParSeq[T]](() => ParSeq.newCombiner[T]) - def seq: collection.mutable.Iterable[T] + def seq: scala.collection.mutable.Iterable[T] } /** $factoryInfo diff --git a/src/library/scala/collection/parallel/mutable/ParMap.scala b/src/library/scala/collection/parallel/mutable/ParMap.scala index 4b3eae4ad1..9ad14f15f8 100644 --- a/src/library/scala/collection/parallel/mutable/ParMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParMap.scala @@ -12,8 +12,8 @@ package scala.collection.parallel.mutable -import collection.generic._ -import collection.parallel.Combiner +import scala.collection.generic._ +import scala.collection.parallel.Combiner @@ -29,7 +29,7 @@ import collection.parallel.Combiner */ trait ParMap[K, V] extends collection/*.mutable*/.GenMap[K, V] - with collection.parallel.ParMap[K, V] + with scala.collection.parallel.ParMap[K, V] with /* mutable */ ParIterable[(K, V)] with GenericParMapTemplate[K, V, ParMap] with /* mutable */ ParMapLike[K, V, ParMap[K, V], collection.mutable.Map[K, V]] @@ -41,7 +41,7 @@ extends collection/*.mutable*/.GenMap[K, V] override def empty: ParMap[K, V] = new ParHashMap[K, V] - def seq: collection.mutable.Map[K, V] + def seq: scala.collection.mutable.Map[K, V] override def updated [U >: V](key: K, value: U): ParMap[K, U] = this + ((key, value)) @@ -53,7 +53,7 @@ extends collection/*.mutable*/.GenMap[K, V] * @param d the function mapping keys to values, used for non-present keys * @return a wrapper of the map with a default value */ - def withDefault(d: K => V): collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, d) + def withDefault(d: K => V): scala.collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, d) /** The same map with a given default value. * @@ -62,7 +62,7 @@ extends collection/*.mutable*/.GenMap[K, V] * @param d the function mapping keys to values, used for non-present keys * @return a wrapper of the map with a default value */ - def withDefaultValue(d: V): collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, x => d) + def withDefaultValue(d: V): scala.collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, x => d) } @@ -76,7 +76,7 @@ object ParMap extends ParMapFactory[ParMap] { implicit def canBuildFrom[K, V]: CanCombineFrom[Coll, (K, V), ParMap[K, V]] = new CanCombineFromMap[K, V] class WithDefault[K, V](underlying: ParMap[K, V], d: K => V) - extends collection.parallel.ParMap.WithDefault(underlying, d) with ParMap[K, V] { + extends scala.collection.parallel.ParMap.WithDefault(underlying, d) with ParMap[K, V] { override def += (kv: (K, V)) = {underlying += kv; this} def -= (key: K) = {underlying -= key; this} override def empty = new WithDefault(underlying.empty, d) diff --git a/src/library/scala/collection/parallel/mutable/ParMapLike.scala b/src/library/scala/collection/parallel/mutable/ParMapLike.scala index 5c69c2e045..675b20949f 100644 --- a/src/library/scala/collection/parallel/mutable/ParMapLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParMapLike.scala @@ -11,11 +11,11 @@ package mutable -import collection.generic._ -import collection.mutable.Builder -import collection.mutable.Cloneable -import collection.generic.Growable -import collection.generic.Shrinkable +import scala.collection.generic._ +import scala.collection.mutable.Builder +import scala.collection.mutable.Cloneable +import scala.collection.generic.Growable +import scala.collection.generic.Shrinkable @@ -33,9 +33,9 @@ import collection.generic.Shrinkable trait ParMapLike[K, V, +Repr <: ParMapLike[K, V, Repr, Sequential] with ParMap[K, V], - +Sequential <: collection.mutable.Map[K, V] with collection.mutable.MapLike[K, V, Sequential]] -extends collection.GenMapLike[K, V, Repr] - with collection.parallel.ParMapLike[K, V, Repr, Sequential] + +Sequential <: scala.collection.mutable.Map[K, V] with scala.collection.mutable.MapLike[K, V, Sequential]] +extends scala.collection.GenMapLike[K, V, Repr] + with scala.collection.parallel.ParMapLike[K, V, Repr, Sequential] with Growable[(K, V)] with Shrinkable[K] with Cloneable[Repr] diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala index f46b369494..15f8d1d0b5 100644 --- a/src/library/scala/collection/parallel/mutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala @@ -29,9 +29,9 @@ import scala.collection.GenSeq * @define Coll `mutable.ParSeq` * @define coll mutable parallel sequence */ -trait ParSeq[T] extends collection/*.mutable*/.GenSeq[T] // was: collection.mutable.Seq[T] +trait ParSeq[T] extends collection/*.mutable*/.GenSeq[T] // was: scala.collection.mutable.Seq[T] with ParIterable[T] - with collection.parallel.ParSeq[T] + with scala.collection.parallel.ParSeq[T] with GenericParTemplate[T, ParSeq] with ParSeqLike[T, ParSeq[T], collection.mutable.Seq[T]] { self => @@ -40,7 +40,7 @@ self => def update(i: Int, elem: T): Unit - def seq: collection.mutable.Seq[T] + def seq: scala.collection.mutable.Seq[T] override def toSeq: ParSeq[T] = this } diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala index 6da4c8a7bc..689ce3436f 100644 --- a/src/library/scala/collection/parallel/mutable/ParSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParSet.scala @@ -29,14 +29,14 @@ import scala.collection.GenSet trait ParSet[T] extends collection/*.mutable*/.GenSet[T] with ParIterable[T] - with collection.parallel.ParSet[T] + with scala.collection.parallel.ParSet[T] with GenericParTemplate[T, ParSet] with ParSetLike[T, ParSet[T], collection.mutable.Set[T]] { self => override def companion: GenericCompanion[ParSet] with GenericParCompanion[ParSet] = ParSet override def empty: ParSet[T] = ParHashSet() - def seq: collection.mutable.Set[T] + def seq: scala.collection.mutable.Set[T] } diff --git a/src/library/scala/collection/parallel/mutable/ParSetLike.scala b/src/library/scala/collection/parallel/mutable/ParSetLike.scala index 969fc2a405..e41d779a4d 100644 --- a/src/library/scala/collection/parallel/mutable/ParSetLike.scala +++ b/src/library/scala/collection/parallel/mutable/ParSetLike.scala @@ -35,8 +35,8 @@ trait ParSetLike[T, +Repr <: ParSetLike[T, Repr, Sequential] with ParSet[T], +Sequential <: mutable.Set[T] with mutable.SetLike[T, Sequential]] extends GenSetLike[T, Repr] - with collection.parallel.ParIterableLike[T, Repr, Sequential] - with collection.parallel.ParSetLike[T, Repr, Sequential] + with scala.collection.parallel.ParIterableLike[T, Repr, Sequential] + with scala.collection.parallel.ParSetLike[T, Repr, Sequential] with Growable[T] with Shrinkable[T] with Cloneable[Repr] diff --git a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala index 359c35f1dd..5c452f628c 100644 --- a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala @@ -34,7 +34,7 @@ import scala.collection.concurrent.TrieMapIterator * @author Aleksandar Prokopec * @since 2.10 * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_concurrent_tries Scala's Parallel Collections Library overview]] - * section on `ParTrieMap` for more information. + * section on `ParTrieMap` for more information. */ final class ParTrieMap[K, V] private[collection] (private val ctrie: TrieMap[K, V]) extends ParMap[K, V] @@ -130,7 +130,7 @@ extends TrieMapIterator[K, V](lev, ct, mustInit) protected override def newIterator(_lev: Int, _ct: TrieMap[K, V], _mustInit: Boolean) = new ParTrieMapSplitter[K, V](_lev, _ct, _mustInit) - override def shouldSplitFurther[S](coll: collection.parallel.ParIterable[S], parallelismLevel: Int) = { + override def shouldSplitFurther[S](coll: scala.collection.parallel.ParIterable[S], parallelismLevel: Int) = { val maxsplits = 3 + Integer.highestOneBit(parallelismLevel) level < maxsplits } diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala index e3124af12e..30b4c0c914 100644 --- a/src/library/scala/collection/parallel/package.scala +++ b/src/library/scala/collection/parallel/package.scala @@ -12,8 +12,8 @@ import scala.collection.generic.CanBuildFrom import scala.collection.generic.CanCombineFrom import scala.collection.parallel.mutable.ParArray import scala.collection.mutable.UnrolledBuffer -import annotation.unchecked.uncheckedVariance -import language.implicitConversions +import scala.annotation.unchecked.uncheckedVariance +import scala.language.implicitConversions /** Package object for parallel collections. */ @@ -48,7 +48,7 @@ package object parallel { } else new ThreadPoolTaskSupport val defaultTaskSupport: TaskSupport = getTaskSupport - + def setTaskSupport[Coll](c: Coll, t: TaskSupport): Coll = { c match { case pc: ParIterableLike[_, _, _] => pc.tasksupport = t @@ -56,7 +56,7 @@ package object parallel { } c } - + /* implicit conversions */ implicit def factory2ops[From, Elem, To](bf: CanBuildFrom[From, Elem, To]) = new FactoryOps[From, Elem, To] { @@ -66,7 +66,7 @@ package object parallel { def otherwise(notbody: => R) = if (isParallel) isbody(asParallel) else notbody } } - implicit def traversable2ops[T](t: collection.GenTraversableOnce[T]) = new TraversableOps[T] { + implicit def traversable2ops[T](t: scala.collection.GenTraversableOnce[T]) = new TraversableOps[T] { def isParallel = t.isInstanceOf[Parallel] def isParIterable = t.isInstanceOf[ParIterable[_]] def asParIterable = t.asInstanceOf[ParIterable[T]] @@ -149,7 +149,7 @@ package parallel { * Automatically forwards the signal delegate when splitting. */ private[parallel] class BufferSplitter[T] - (private val buffer: collection.mutable.ArrayBuffer[T], private var index: Int, private val until: Int, _sigdel: collection.generic.Signalling) + (private val buffer: scala.collection.mutable.ArrayBuffer[T], private var index: Int, private val until: Int, _sigdel: scala.collection.generic.Signalling) extends IterableSplitter[T] { signalDelegate = _sigdel def hasNext = index < until diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index a5d9cdd5d1..111900e7bc 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -8,7 +8,7 @@ package scala.concurrent -import language.higherKinds +import scala.language.higherKinds import java.util.concurrent.{ ConcurrentLinkedQueue, TimeUnit, Callable } import java.util.concurrent.TimeUnit.{ NANOSECONDS => NANOS, MILLISECONDS ⇒ MILLIS } @@ -212,7 +212,7 @@ trait Future[+T] extends Awaitable[T] { * this future, or the 'f' function to the failed result. If there is any non-fatal * exception thrown when 's' or 'f' is applied, that exception will be propagated * to the resulting future. - * + * * @param s function that transforms a successful result of the receiver into a * successful result of the returned future * @param f function that transforms a failure of the receiver into a failure of @@ -428,7 +428,7 @@ trait Future[+T] extends Awaitable[T] { */ def zip[U](that: Future[U]): Future[(T, U)] = { val p = Promise[(T, U)]() - + this onComplete { case f: Failure[_] => p complete f.asInstanceOf[Failure[(T, U)]] case Success(r) => @@ -439,7 +439,7 @@ trait Future[+T] extends Awaitable[T] { case f => p failure f } } - + p.future } @@ -555,7 +555,7 @@ trait Future[+T] extends Awaitable[T] { * Note: using this method yields nondeterministic dataflow programs. */ object Future { - + private[concurrent] val toBoxed = Map[Class[_], Class[_]]( classOf[Boolean] -> classOf[java.lang.Boolean], classOf[Byte] -> classOf[java.lang.Byte], @@ -569,19 +569,19 @@ object Future { ) /** Creates an already completed Future with the specified exception. - * + * * @tparam T the type of the value in the future * @return the newly created `Future` object */ def failed[T](exception: Throwable): Future[T] = Promise.failed(exception).future /** Creates an already completed Future with the specified result. - * + * * @tparam T the type of the value in the future * @return the newly created `Future` object */ def successful[T](result: T): Future[T] = Promise.successful(result).future - + /** Starts an asynchronous computation and returns a `Future` object with the result of that computation. * * The result becomes available once the asynchronous computation is completed. diff --git a/src/library/scala/concurrent/FutureTaskRunner.scala b/src/library/scala/concurrent/FutureTaskRunner.scala index d7f1e1c2f9..eeadaddb5e 100644 --- a/src/library/scala/concurrent/FutureTaskRunner.scala +++ b/src/library/scala/concurrent/FutureTaskRunner.scala @@ -8,7 +8,7 @@ package scala.concurrent -import language.{implicitConversions, higherKinds} +import scala.language.{implicitConversions, higherKinds} /** The `FutureTaskRunner trait is a base trait of task runners * that provide some sort of future abstraction. diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala index ffb9926fef..f66d64bc3b 100644 --- a/src/library/scala/concurrent/JavaConversions.scala +++ b/src/library/scala/concurrent/JavaConversions.scala @@ -9,7 +9,7 @@ package scala.concurrent import java.util.concurrent.{ExecutorService, Executor} -import language.implicitConversions +import scala.language.implicitConversions /** The `JavaConversions` object provides implicit converstions supporting * interoperability between Scala and Java concurrency classes. diff --git a/src/library/scala/concurrent/TaskRunner.scala b/src/library/scala/concurrent/TaskRunner.scala index 2e11ac42b0..2037c43cf8 100644 --- a/src/library/scala/concurrent/TaskRunner.scala +++ b/src/library/scala/concurrent/TaskRunner.scala @@ -8,7 +8,7 @@ package scala.concurrent -import language.{higherKinds, implicitConversions} +import scala.language.{higherKinds, implicitConversions} /** The `TaskRunner` trait... * diff --git a/src/library/scala/concurrent/ThreadPoolRunner.scala b/src/library/scala/concurrent/ThreadPoolRunner.scala index 594555d49b..4b777ba069 100644 --- a/src/library/scala/concurrent/ThreadPoolRunner.scala +++ b/src/library/scala/concurrent/ThreadPoolRunner.scala @@ -9,7 +9,7 @@ package scala.concurrent import java.util.concurrent.{ExecutorService, Callable, TimeUnit} -import language.implicitConversions +import scala.language.implicitConversions /** The `ThreadPoolRunner` trait uses a `java.util.concurrent.ExecutorService` * to run submitted tasks. diff --git a/src/library/scala/concurrent/ThreadRunner.scala b/src/library/scala/concurrent/ThreadRunner.scala index ab709e0210..067269a911 100644 --- a/src/library/scala/concurrent/ThreadRunner.scala +++ b/src/library/scala/concurrent/ThreadRunner.scala @@ -9,7 +9,7 @@ package scala.concurrent import java.lang.Thread -import language.implicitConversions +import scala.language.implicitConversions /** The `ThreadRunner` trait... * diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index 1a4bc1323d..3f8b98831e 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -11,7 +11,7 @@ package scala.concurrent.util import java.util.concurrent.TimeUnit import TimeUnit._ import java.lang.{ Double => JDouble, Long => JLong } -import language.implicitConversions +import scala.language.implicitConversions /** * This class stores a deadline, as obtained via `Deadline.now` or the @@ -100,7 +100,7 @@ object Duration { * Infinite inputs (and NaN) are converted into [[Duration.Inf]], [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. * * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] - */ + */ def apply(length: Double, unit: TimeUnit): Duration = fromNanos(unit.toNanos(1) * length) /** * Construct a finite duration from the given length and time unit. The unit given is retained @@ -117,7 +117,7 @@ object Duration { def apply(length: Long, unit: String): FiniteDuration = new FiniteDuration(length, Duration.timeUnit(unit)) // Double stores 52 bits mantissa, but there is an implied '1' in front, making the limit 2^53 - final val maxPreciseDouble = 9007199254740992d + final val maxPreciseDouble = 9007199254740992d /** * Parse String into Duration. Format is `""`, where @@ -183,13 +183,13 @@ object Duration { /** * Construct a possibly infinite or undefined Duration from the given number of nanoseconds. - * + * * - `Double.PositiveInfinity` is mapped to [[Duration.Inf]] * - `Double.NegativeInfinity` is mapped to [[Duration.MinusInf]] * - `Double.NaN` is mapped to [[Duration.Undefined]] * - `-0d` is mapped to [[Duration.Zero]] (exactly like `0d`) * - * The semantics of the resulting Duration objects matches the semantics of their Double + * The semantics of the resulting Duration objects matches the semantics of their Double * counterparts with respect to arithmetic operations. * * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] @@ -300,7 +300,7 @@ object Duration { /** * Infinite duration: greater than any other (apart from Undefined) and not equal to any other - * but itself. This value closely corresponds to Double.PositiveInfinity, + * but itself. This value closely corresponds to Double.PositiveInfinity, * matching its semantics in arithmetic operations. */ val Inf: Infinite = new Infinite { @@ -316,7 +316,7 @@ object Duration { /** * Infinite duration: less than any other and not equal to any other - * but itself. This value closely corresponds to Double.NegativeInfinity, + * but itself. This value closely corresponds to Double.NegativeInfinity, * matching its semantics in arithmetic operations. */ val MinusInf: Infinite = new Infinite { @@ -342,7 +342,7 @@ object Duration { * Infinite inputs (and NaN) are converted into [[Duration.Inf]], [[Duration.MinusInf]] and [[Duration.Undefined]], respectively. * * @throws IllegalArgumentException if the length was finite but the resulting duration cannot be expressed as a [[FiniteDuration]] - */ + */ def create(length: Double, unit: TimeUnit): Duration = apply(length, unit) /** * Construct a finite duration from the given length and time unit, where the latter is @@ -390,7 +390,7 @@ object Duration { * duration < 1.second * duration <= Duration.Inf * }}} - * + * * '''''Invoking inexpressible conversions (like calling `toSeconds` on an infinite duration) will throw an IllegalArgumentException.''''' * *

      @@ -425,7 +425,7 @@ object Duration { * - exact addition/subtraction with nanosecond resolution for finite durations, independent of the summands' magnitude * - isomorphic to `java.lang.Double` when it comes to infinite or undefined values * - * The conversion between Duration and Double is done using [[Duration.toUnit]] (with unit NANOSECONDS) + * The conversion between Duration and Double is done using [[Duration.toUnit]] (with unit NANOSECONDS) * and [[Duration$.fromNanos(Double):Duration Duration.fromNanos(Double)]]. * *

      Ordering

      @@ -531,7 +531,7 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { */ def /(factor: Double): Duration /** - * Return the quotient of this and that duration as floating-point number. The semantics are + * Return the quotient of this and that duration as floating-point number. The semantics are * determined by Double as if calculating the quotient of the nanosecond lengths of both factors. */ def /(other: Duration): Double @@ -540,7 +540,7 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { */ def unary_- : Duration /** - * This method returns whether this duration is finite, which is not the same as + * This method returns whether this duration is finite, which is not the same as * `!isInfinite` for Double because this method also returns `false` for [[Duration.Undefined]]. */ def isFinite(): Boolean @@ -563,7 +563,7 @@ sealed abstract class Duration extends Serializable with Ordered[Duration] { */ def div(factor: Double) = this / factor /** - * Return the quotient of this and that duration as floating-point number. The semantics are + * Return the quotient of this and that duration as floating-point number. The semantics are * determined by Double as if calculating the quotient of the nanosecond lengths of both factors. */ def div(other: Duration) = this / other @@ -685,7 +685,7 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio case _ => other } - def *(factor: Double) = + def *(factor: Double) = if (!factor.isInfinite) fromNanos(toNanos * factor) else if (factor.isNaN) Undefined else if ((factor > 0) ^ (this < Zero)) Inf diff --git a/src/library/scala/concurrent/util/duration/package.scala b/src/library/scala/concurrent/util/duration/package.scala index e3cf229c61..d5ae3f1544 100644 --- a/src/library/scala/concurrent/util/duration/package.scala +++ b/src/library/scala/concurrent/util/duration/package.scala @@ -1,7 +1,7 @@ package scala.concurrent.util import java.util.concurrent.TimeUnit -import language.implicitConversions +import scala.language.implicitConversions package object duration { diff --git a/src/library/scala/deprecated.scala b/src/library/scala/deprecated.scala index 111affc904..5ad61b811a 100644 --- a/src/library/scala/deprecated.scala +++ b/src/library/scala/deprecated.scala @@ -8,7 +8,7 @@ package scala -import annotation.meta._ +import scala.annotation.meta._ /** An annotation that designates that a definition is deprecated. * Access to the member then generates a deprecated warning. @@ -18,4 +18,4 @@ import annotation.meta._ * @since 2.3 */ @getter @setter @beanGetter @beanSetter -class deprecated(message: String = "", since: String = "") extends annotation.StaticAnnotation +class deprecated(message: String = "", since: String = "") extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala index ca1b586223..eb241d0d04 100644 --- a/src/library/scala/deprecatedInheritance.scala +++ b/src/library/scala/deprecatedInheritance.scala @@ -19,4 +19,4 @@ package scala * @see [[scala.deprecatedOverriding]] */ private[scala] // for now, this needs to be generalized to communicate other modifier deltas -class deprecatedInheritance(message: String = "", since: String = "") extends annotation.StaticAnnotation +class deprecatedInheritance(message: String = "", since: String = "") extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/deprecatedName.scala b/src/library/scala/deprecatedName.scala index cc36be6775..07b35d1a61 100644 --- a/src/library/scala/deprecatedName.scala +++ b/src/library/scala/deprecatedName.scala @@ -8,7 +8,7 @@ package scala -import annotation.meta._ +import scala.annotation.meta._ /** * An annotation that designates the name of the parameter to which it is @@ -29,4 +29,4 @@ import annotation.meta._ * @since 2.8.1 */ @param -class deprecatedName(name: Symbol) extends annotation.StaticAnnotation +class deprecatedName(name: Symbol) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/deprecatedOverriding.scala b/src/library/scala/deprecatedOverriding.scala index 566cb59431..c9fd3af91b 100644 --- a/src/library/scala/deprecatedOverriding.scala +++ b/src/library/scala/deprecatedOverriding.scala @@ -18,4 +18,4 @@ package scala * @see [[scala.deprecatedInheritance]] */ private[scala] // for the same reasons as deprecatedInheritance -class deprecatedOverriding(message: String = "", since: String = "") extends annotation.StaticAnnotation +class deprecatedOverriding(message: String = "", since: String = "") extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/inline.scala b/src/library/scala/inline.scala index a182fdf9ca..42ae28a347 100644 --- a/src/library/scala/inline.scala +++ b/src/library/scala/inline.scala @@ -17,4 +17,4 @@ package scala * @author Lex Spoon * @version 1.0, 2007-5-21 */ -class inline extends annotation.StaticAnnotation +class inline extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala index 84cac88dcc..fa74be0f98 100644 --- a/src/library/scala/io/Codec.scala +++ b/src/library/scala/io/Codec.scala @@ -10,8 +10,8 @@ package scala.io import java.nio.charset.{ Charset, CharsetDecoder, CharsetEncoder, CharacterCodingException, CodingErrorAction => Action } -import annotation.migration -import language.implicitConversions +import scala.annotation.migration +import scala.language.implicitConversions // Some notes about encodings for use in refining this implementation. // diff --git a/src/library/scala/languageFeature.scala b/src/library/scala/languageFeature.scala index 39540b4f49..1f411c412a 100644 --- a/src/library/scala/languageFeature.scala +++ b/src/library/scala/languageFeature.scala @@ -1,6 +1,6 @@ package scala -import annotation.meta +import scala.annotation.meta object languageFeature { diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index a475d663f4..eb73d58d1c 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -12,7 +12,7 @@ package scala.math import java.{ lang => jl } import java.math.{ MathContext, BigDecimal => BigDec } import scala.collection.immutable.NumericRange -import language.implicitConversions +import scala.language.implicitConversions /** diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index e354117e14..3eb41053f7 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -9,7 +9,7 @@ package scala.math import java.math.BigInteger -import language.implicitConversions +import scala.language.implicitConversions /** * @author Martin Odersky diff --git a/src/library/scala/math/Fractional.scala b/src/library/scala/math/Fractional.scala index 0686569c16..98fd325980 100644 --- a/src/library/scala/math/Fractional.scala +++ b/src/library/scala/math/Fractional.scala @@ -8,7 +8,7 @@ package scala.math -import language.implicitConversions +import scala.language.implicitConversions /** * @since 2.8 @@ -28,4 +28,4 @@ object Fractional { implicit def infixFractionalOps[T](x: T)(implicit num: Fractional[T]): Fractional[T]#FractionalOps = new num.FractionalOps(x) } object Implicits extends ExtraImplicits -} \ No newline at end of file +} diff --git a/src/library/scala/math/Integral.scala b/src/library/scala/math/Integral.scala index 4b4de28228..e5bfc8f687 100644 --- a/src/library/scala/math/Integral.scala +++ b/src/library/scala/math/Integral.scala @@ -10,7 +10,7 @@ package scala.math -import language.implicitConversions +import scala.language.implicitConversions /** * @since 2.8 @@ -36,4 +36,4 @@ object Integral { implicit def infixIntegralOps[T](x: T)(implicit num: Integral[T]): Integral[T]#IntegralOps = new num.IntegralOps(x) } object Implicits extends ExtraImplicits -} \ No newline at end of file +} diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala index ee62706e49..4428d9c249 100644 --- a/src/library/scala/math/Numeric.scala +++ b/src/library/scala/math/Numeric.scala @@ -8,7 +8,7 @@ package scala.math -import language.implicitConversions +import scala.language.implicitConversions /** * @since 2.8 diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala index a5efa41b80..53b3ae81cb 100644 --- a/src/library/scala/math/Ordered.scala +++ b/src/library/scala/math/Ordered.scala @@ -8,7 +8,7 @@ package scala.math -import language.implicitConversions +import scala.language.implicitConversions /** A trait for data that have a single, natural ordering. See * [[scala.math.Ordering]] before using this trait for diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index 9020bb9edd..3ac255b57f 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -9,7 +9,7 @@ package scala.math import java.util.Comparator -import language.{implicitConversions, higherKinds} +import scala.language.{implicitConversions, higherKinds} /** Ordering is a trait whose instances each represent a strategy for sorting * instances of a type. @@ -165,7 +165,7 @@ object Ordering extends LowPriorityOrderingImplicits { /** Not in the standard scope due to the potential for divergence: * For instance `implicitly[Ordering[Any]]` diverges in its presence. */ - implicit def seqDerivedOrdering[CC[X] <: collection.Seq[X], T](implicit ord: Ordering[T]): Ordering[CC[T]] = + implicit def seqDerivedOrdering[CC[X] <: scala.collection.Seq[X], T](implicit ord: Ordering[T]): Ordering[CC[T]] = new Ordering[CC[T]] { def compare(x: CC[T], y: CC[T]): Int = { val xe = x.iterator diff --git a/src/library/scala/native.scala b/src/library/scala/native.scala index 28bb9f70fd..798af3a5da 100644 --- a/src/library/scala/native.scala +++ b/src/library/scala/native.scala @@ -20,4 +20,4 @@ package scala * but it is type checked when present. * * @since 2.6 */ -class native extends annotation.StaticAnnotation {} +class native extends scala.annotation.StaticAnnotation {} diff --git a/src/library/scala/noinline.scala b/src/library/scala/noinline.scala index de650ed209..7cb9b3d53c 100644 --- a/src/library/scala/noinline.scala +++ b/src/library/scala/noinline.scala @@ -18,4 +18,4 @@ package scala * @version 1.0, 2007-5-21 * @since 2.5 */ -class noinline extends annotation.StaticAnnotation +class noinline extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index e42c89d21f..6757a72053 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -1,7 +1,7 @@ package scala.reflect import java.lang.{ Class => jClass } -import language.{implicitConversions, existentials} +import scala.language.{implicitConversions, existentials} import scala.runtime.ScalaRunTime.{ arrayClass, arrayElementClass } /** A `ClassTag[T]` wraps a runtime class, which can be accessed via the `runtimeClass` method. @@ -126,4 +126,4 @@ object ClassTag { } def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.runtimeClass) -} \ No newline at end of file +} diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala index 6f90d598f9..33582675bd 100644 --- a/src/library/scala/reflect/base/Base.scala +++ b/src/library/scala/reflect/base/Base.scala @@ -4,7 +4,7 @@ package base import java.io.PrintWriter import scala.annotation.switch import scala.ref.WeakReference -import collection.mutable +import scala.collection.mutable class Base extends Universe { self => diff --git a/src/library/scala/reflect/base/Names.scala b/src/library/scala/reflect/base/Names.scala index 532b780e7e..ad99f54fb3 100644 --- a/src/library/scala/reflect/base/Names.scala +++ b/src/library/scala/reflect/base/Names.scala @@ -1,7 +1,7 @@ package scala.reflect package base -import language.implicitConversions +import scala.language.implicitConversions /** A trait that manages names. * A name is a string in one of two name universes: terms and types. diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index 37e0c4f02f..ec86bbc9be 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -7,7 +7,7 @@ package scala.reflect package base import java.lang.{ Class => jClass } -import language.implicitConversions +import scala.language.implicitConversions /** * Type tags encapsulate a representation of type T. @@ -274,4 +274,4 @@ private[scala] class SerializedTypeTag(var tpec: TypeCreator, var concrete: Bool if (concrete) TypeTag(rootMirror, tpec) else WeakTypeTag(rootMirror, tpec) } -} \ No newline at end of file +} diff --git a/src/library/scala/reflect/macros/internal/macroImpl.scala b/src/library/scala/reflect/macros/internal/macroImpl.scala index a7b2bf482c..b281fb7d12 100644 --- a/src/library/scala/reflect/macros/internal/macroImpl.scala +++ b/src/library/scala/reflect/macros/internal/macroImpl.scala @@ -15,4 +15,4 @@ package internal * To lessen the weirdness we define this annotation as `private[scala]`. * It will not prevent pickling, but it will prevent application developers (and scaladocs) from seeing the annotation. */ -private[scala] class macroImpl(val referenceToMacroImpl: Any) extends annotation.StaticAnnotation +private[scala] class macroImpl(val referenceToMacroImpl: Any) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/remote.scala b/src/library/scala/remote.scala index bf6b440031..36893da298 100644 --- a/src/library/scala/remote.scala +++ b/src/library/scala/remote.scala @@ -24,4 +24,4 @@ package scala * } * }}} */ -class remote extends annotation.StaticAnnotation {} +class remote extends scala.annotation.StaticAnnotation {} diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala index bb20ec61bb..b9289562f8 100644 --- a/src/library/scala/runtime/RichException.scala +++ b/src/library/scala/runtime/RichException.scala @@ -8,7 +8,7 @@ package scala.runtime -import compat.Platform.EOL +import scala.compat.Platform.EOL final class RichException(exc: Throwable) { def getStackTraceString = exc.getStackTrace().mkString("", EOL, EOL) diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index 64df4611e3..df2d209e3e 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -9,7 +9,7 @@ package scala.runtime import scala.collection.{ mutable, immutable } -import math.ScalaNumericConversions +import scala.math.ScalaNumericConversions import immutable.NumericRange import Proxy.Typed diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index a8635151ff..045fb5b252 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -144,7 +144,7 @@ object ScalaRunTime { dest } - def toArray[T](xs: collection.Seq[T]) = { + def toArray[T](xs: scala.collection.Seq[T]) = { val arr = new Array[AnyRef](xs.length) var i = 0 for (x <- xs) { @@ -250,7 +250,7 @@ object ScalaRunTime { * it's performing a series of Any/Any equals comparisons anyway. * See ticket #2867 for specifics. */ - def sameElements(xs1: collection.Seq[Any], xs2: collection.Seq[Any]) = xs1 sameElements xs2 + def sameElements(xs1: scala.collection.Seq[Any], xs2: scala.collection.Seq[Any]) = xs1 sameElements xs2 /** Given any Scala value, convert it to a String. * @@ -317,7 +317,7 @@ object ScalaRunTime { case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x case x if useOwnToString(x) => x.toString case x: AnyRef if isArray(x) => arrayToString(x) - case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")") + case x: scala.collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")") case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)" // that special trailing comma diff --git a/src/library/scala/runtime/SeqCharSequence.scala b/src/library/scala/runtime/SeqCharSequence.scala index 8ef1a9a33e..dc9594d960 100644 --- a/src/library/scala/runtime/SeqCharSequence.scala +++ b/src/library/scala/runtime/SeqCharSequence.scala @@ -10,7 +10,7 @@ package scala.runtime import java.util.Arrays.copyOfRange -final class SeqCharSequence(val xs: collection.IndexedSeq[Char]) extends CharSequence { +final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends CharSequence { def length: Int = xs.length def charAt(index: Int): Char = xs(index) def subSequence(start: Int, end: Int): CharSequence = new SeqCharSequence(xs.slice(start, end)) diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala index 182fd77133..bd52c678af 100644 --- a/src/library/scala/runtime/Tuple2Zipped.scala +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -10,7 +10,7 @@ package scala.runtime import scala.collection.{ TraversableLike, IterableLike } import scala.collection.generic.{ CanBuildFrom => CBF } -import language.{ higherKinds, implicitConversions } +import scala.language.{ higherKinds, implicitConversions } /** This interface is intended as a minimal interface, not complicated * by the requirement to resolve type constructors, for implicit search (which only @@ -111,7 +111,7 @@ object Tuple2Zipped { def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], That] (implicit w1: T1 <:< CC1[El1], w2: T2 <:< CC2[El2], - bf: collection.generic.CanBuildFrom[CC1[_], (El1, El2), That] + bf: scala.collection.generic.CanBuildFrom[CC1[_], (El1, El2), That] ): That = { val buf = bf(x._1) val it1 = x._1.toIterator diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala index f6aafe41fb..3b78b6261a 100644 --- a/src/library/scala/runtime/Tuple3Zipped.scala +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -10,7 +10,7 @@ package scala.runtime import scala.collection.{ TraversableLike, IterableLike } import scala.collection.generic.{ CanBuildFrom => CBF } -import language.{ higherKinds, implicitConversions } +import scala.language.{ higherKinds, implicitConversions } /** See comment on ZippedTraversable2. */ trait ZippedTraversable3[+El1, +El2, +El3] extends Any { @@ -119,7 +119,7 @@ object Tuple3Zipped { (implicit w1: T1 <:< CC1[El1], w2: T2 <:< CC2[El2], w3: T3 <:< CC3[El3], - bf: collection.generic.CanBuildFrom[CC1[_], (El1, El2, El3), That] + bf: scala.collection.generic.CanBuildFrom[CC1[_], (El1, El2, El3), That] ): That = { val buf = bf(x._1) val it1 = x._1.toIterator diff --git a/src/library/scala/specialized.scala b/src/library/scala/specialized.scala index 761c7cb25e..d349b7e0c2 100644 --- a/src/library/scala/specialized.scala +++ b/src/library/scala/specialized.scala @@ -24,9 +24,9 @@ import Specializable._ * * @since 2.8 */ -// class tspecialized[T](group: Group[T]) extends annotation.StaticAnnotation { +// class tspecialized[T](group: Group[T]) extends scala.annotation.StaticAnnotation { -class specialized(group: SpecializedGroup) extends annotation.StaticAnnotation { +class specialized(group: SpecializedGroup) extends scala.annotation.StaticAnnotation { def this(types: Specializable*) = this(new Group(types.toList)) def this() = this(Primitives) } diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala index 45fc6f5897..7213fdeb65 100644 --- a/src/library/scala/sys/BooleanProp.scala +++ b/src/library/scala/sys/BooleanProp.scala @@ -8,7 +8,7 @@ package scala.sys -import language.implicitConversions +import scala.language.implicitConversions /** A few additional conveniences for Boolean properties. */ diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index d5777922b4..5777c255c3 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -11,7 +11,7 @@ package scala.sys import scala.collection.{ mutable, Iterator } import scala.collection.JavaConverters._ import java.security.AccessControlException -import language.implicitConversions +import scala.language.implicitConversions /** A bidirectional map wrapping the java System properties. diff --git a/src/library/scala/sys/package.scala b/src/library/scala/sys/package.scala index 119ab59c22..445b30e480 100644 --- a/src/library/scala/sys/package.scala +++ b/src/library/scala/sys/package.scala @@ -9,7 +9,7 @@ package scala import scala.collection.immutable -import collection.JavaConverters._ +import scala.collection.JavaConverters._ /** The package object `scala.sys` contains methods for reading * and altering core aspects of the virtual machine as well as the @@ -85,4 +85,4 @@ package object sys { tarray take got } -} \ No newline at end of file +} diff --git a/src/library/scala/sys/process/Process.scala b/src/library/scala/sys/process/Process.scala index d56c6f2c9d..4950758a1a 100644 --- a/src/library/scala/sys/process/Process.scala +++ b/src/library/scala/sys/process/Process.scala @@ -11,7 +11,7 @@ package process import processInternal._ import ProcessBuilder._ -import language.implicitConversions +import scala.language.implicitConversions /** Represents a process that is running or has finished running. * It may be a compound process with several underlying native processes (such as `a #&& b`). diff --git a/src/library/scala/sys/process/package.scala b/src/library/scala/sys/process/package.scala index c1bf470831..7c73fd587c 100644 --- a/src/library/scala/sys/process/package.scala +++ b/src/library/scala/sys/process/package.scala @@ -205,7 +205,7 @@ package scala.sys { package object process extends ProcessImplicits { /** The arguments passed to `java` when creating this process */ def javaVmArguments: List[String] = { - import collection.JavaConversions._ + import scala.collection.JavaConversions._ java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toList } diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index 9c07fcab4f..3794fb3f2b 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -8,7 +8,7 @@ package scala.testing -import compat.Platform +import scala.compat.Platform /** `Benchmark` can be used to quickly turn an existing class into a * benchmark. Here is a short example: diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala index 4621c789ab..0aa0d31c9f 100644 --- a/src/library/scala/throws.scala +++ b/src/library/scala/throws.scala @@ -23,4 +23,4 @@ package scala * @version 1.0, 19/05/2006 * @since 2.1 */ -class throws(clazz: Class[_]) extends annotation.StaticAnnotation +class throws(clazz: Class[_]) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/transient.scala b/src/library/scala/transient.scala index 3dcff0664c..36dcb996cf 100644 --- a/src/library/scala/transient.scala +++ b/src/library/scala/transient.scala @@ -10,7 +10,7 @@ package scala -import annotation.meta._ +import scala.annotation.meta._ @field -class transient extends annotation.StaticAnnotation +class transient extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/unchecked.scala b/src/library/scala/unchecked.scala index 5b05792d97..281f2ef4d7 100644 --- a/src/library/scala/unchecked.scala +++ b/src/library/scala/unchecked.scala @@ -33,4 +33,4 @@ package scala * * @since 2.4 */ -class unchecked extends annotation.Annotation {} +class unchecked extends scala.annotation.Annotation {} diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index dcfdc16d33..f0253eee07 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -10,7 +10,7 @@ package scala.util -import language.implicitConversions +import scala.language.implicitConversions /** Represents a value of one of two possible types (a disjoint union.) * Instances of Either are either an instance of [[scala.util.Left]] or [[scala.util.Right]]. diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala index 029fe095af..c087b0d8c8 100644 --- a/src/library/scala/util/MurmurHash.scala +++ b/src/library/scala/util/MurmurHash.scala @@ -178,7 +178,7 @@ object MurmurHash { * where the order of appearance of elements does not matter. * This is useful for hashing sets, for example. */ - def symmetricHash[T](xs: collection.TraversableOnce[T], seed: Int) = { + def symmetricHash[T](xs: scala.collection.TraversableOnce[T], seed: Int) = { var a,b,n = 0 var c = 1 xs.seq.foreach(i => { diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 65a1b8c685..85ac27e95c 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -8,10 +8,10 @@ package scala.util -import collection.mutable.ArrayBuffer -import collection.generic.CanBuildFrom +import scala.collection.mutable.ArrayBuffer +import scala.collection.generic.CanBuildFrom import scala.collection.immutable.{ List, Stream } -import language.{implicitConversions, higherKinds} +import scala.language.{implicitConversions, higherKinds} /** * @author Stephane Micheloud diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala index 7afbfcdd66..fe409c2d7a 100644 --- a/src/library/scala/util/Try.scala +++ b/src/library/scala/util/Try.scala @@ -8,9 +8,9 @@ package scala.util -import collection.Seq +import scala.collection.Seq import scala.util.control.NonFatal -import language.implicitConversions +import scala.language.implicitConversions /** * The `Try` type represents a computation that may either result in an exception, or return a diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 1567e06c22..28e4db2038 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -9,10 +9,10 @@ package scala.util package control -import collection.immutable.List -import reflect.{ ClassTag, classTag } +import scala.collection.immutable.List +import scala.reflect.{ ClassTag, classTag } import java.lang.reflect.InvocationTargetException -import language.implicitConversions +import scala.language.implicitConversions /** Classes representing the components of exception handling. @@ -27,7 +27,7 @@ import language.implicitConversions * }}} * * This class differs from `scala.util.Try` in that it focuses on composing exception handlers rather than - * composing behavior. All behavior should be composed first and fed to a `Catch` object using one of the + * composing behavior. All behavior should be composed first and fed to a `Catch` object using one of the * `opt` or `either` methods. * * @author Paul Phillips @@ -218,7 +218,7 @@ object Exception { } /** Private **/ - private def wouldMatch(x: Throwable, classes: collection.Seq[Class[_]]): Boolean = + private def wouldMatch(x: Throwable, classes: scala.collection.Seq[Class[_]]): Boolean = classes exists (_ isAssignableFrom x.getClass) private def pfFromExceptions(exceptions: Class[_]*): PartialFunction[Throwable, Nothing] = diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index 1cfb8276fe..8174f09bb2 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -158,7 +158,7 @@ private[hashing] class MurmurHash3 { finalizeHash(h, data.length) } - final def listHash(xs: collection.immutable.List[_], seed: Int): Int = { + final def listHash(xs: scala.collection.immutable.List[_], seed: Int): Int = { var n = 0 var h = seed var elems = xs @@ -213,45 +213,45 @@ object MurmurHash3 extends MurmurHash3 { /** To offer some potential for optimization. */ - def seqHash(xs: collection.Seq[_]): Int = xs match { + def seqHash(xs: scala.collection.Seq[_]): Int = xs match { case xs: List[_] => listHash(xs, seqSeed) case xs => orderedHash(xs, seqSeed) } - def mapHash(xs: collection.Map[_, _]): Int = unorderedHash(xs, mapSeed) - def setHash(xs: collection.Set[_]): Int = unorderedHash(xs, setSeed) + def mapHash(xs: scala.collection.Map[_, _]): Int = unorderedHash(xs, mapSeed) + def setHash(xs: scala.collection.Set[_]): Int = unorderedHash(xs, setSeed) class ArrayHashing[@specialized T] extends Hashing[Array[T]] { def hash(a: Array[T]) = arrayHash(a) } - + def arrayHashing[@specialized T] = new ArrayHashing[T] - + def bytesHashing = new Hashing[Array[Byte]] { def hash(data: Array[Byte]) = bytesHash(data) } - + def orderedHashing = new Hashing[TraversableOnce[Any]] { def hash(xs: TraversableOnce[Any]) = orderedHash(xs) } - + def productHashing = new Hashing[Product] { def hash(x: Product) = productHash(x) } - + def stringHashing = new Hashing[String] { def hash(x: String) = stringHash(x) } - + def unorderedHashing = new Hashing[TraversableOnce[Any]] { def hash(xs: TraversableOnce[Any]) = unorderedHash(xs) } - + /** All this trouble and foreach still appears faster. * Leaving in place in case someone would like to investigate further. */ /** - def linearSeqHash(xs: collection.LinearSeq[_], seed: Int): Int = { + def linearSeqHash(xs: scala.collection.LinearSeq[_], seed: Int): Int = { var n = 0 var h = seed var elems = xs @@ -263,7 +263,7 @@ object MurmurHash3 extends MurmurHash3 { finalizeHash(h, n) } - def indexedSeqHash(xs: collection.IndexedSeq[_], seed: Int): Int = { + def indexedSeqHash(xs: scala.collection.IndexedSeq[_], seed: Int): Int = { var n = 0 var h = seed val len = xs.length @@ -276,10 +276,10 @@ object MurmurHash3 extends MurmurHash3 { */ @deprecated("Use unorderedHash", "2.10.0") - final def symmetricHash[T](xs: collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int = + final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int = unorderedHash(xs.seq, seed) @deprecated("Use orderedHash", "2.10.0") - final def traversableHash[T](xs: collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = + final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = orderedHash(xs.seq, seed) } diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala index b93c24fde4..fc3b36a4e0 100644 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ b/src/library/scala/util/parsing/ast/Binders.scala @@ -10,7 +10,7 @@ package scala.util.parsing.ast import scala.collection.AbstractIterable import scala.collection.mutable -import language.implicitConversions +import scala.language.implicitConversions //DISCLAIMER: this code is highly experimental! diff --git a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala index 270ac680a9..5b616e9e13 100644 --- a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala +++ b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala @@ -9,7 +9,7 @@ package scala.util.parsing.combinator -import language.implicitConversions +import scala.language.implicitConversions /** This object contains implicit conversions that come in handy when using the `^^` combinator. * diff --git a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala index 06567ea348..520ac8cc2c 100644 --- a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala @@ -9,7 +9,7 @@ package scala.util.parsing.combinator -import annotation.migration +import scala.annotation.migration /** `JavaTokenParsers` differs from [[scala.util.parsing.combinator.RegexParsers]] * by adding the following definitions: diff --git a/src/library/scala/util/parsing/combinator/PackratParsers.scala b/src/library/scala/util/parsing/combinator/PackratParsers.scala index 9516df0093..91642da229 100644 --- a/src/library/scala/util/parsing/combinator/PackratParsers.scala +++ b/src/library/scala/util/parsing/combinator/PackratParsers.scala @@ -11,7 +11,7 @@ package scala.util.parsing.combinator import scala.util.parsing.combinator._ import scala.util.parsing.input.{ Reader, Position } import scala.collection.mutable -import language.implicitConversions +import scala.language.implicitConversions /** * `PackratParsers` is a component that extends the parser combinators diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index eaaea583ce..e6c9573756 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -11,8 +11,8 @@ package scala.util.parsing.combinator import scala.util.parsing.input._ import scala.collection.mutable.ListBuffer import scala.annotation.tailrec -import annotation.migration -import language.implicitConversions +import scala.annotation.migration +import scala.language.implicitConversions import scala.util.DynamicVariable // TODO: better error handling (labelling like parsec's ) diff --git a/src/library/scala/util/parsing/combinator/RegexParsers.scala b/src/library/scala/util/parsing/combinator/RegexParsers.scala index d685329ef1..9a2c497eab 100644 --- a/src/library/scala/util/parsing/combinator/RegexParsers.scala +++ b/src/library/scala/util/parsing/combinator/RegexParsers.scala @@ -13,7 +13,7 @@ import java.util.regex.Pattern import scala.util.matching.Regex import scala.util.parsing.input._ import scala.collection.immutable.PagedSeq -import language.implicitConversions +import scala.language.implicitConversions /** The ''most important'' differences between `RegexParsers` and * [[scala.util.parsing.combinator.Parsers]] are: diff --git a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala index 215b8b792f..03979d43b7 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala @@ -13,7 +13,7 @@ package syntactical import token._ import lexical.StdLexical -import language.implicitConversions +import scala.language.implicitConversions /** This component provides primitive parsers for the standard tokens defined in `StdTokens`. * diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala index 7aa6178df9..a3b94e2562 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala @@ -14,7 +14,7 @@ package syntactical import token._ import scala.collection.mutable -import language.implicitConversions +import scala.language.implicitConversions /** This component provides primitive parsers for the standard tokens defined in `StdTokens`. * diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala index ff3554a6af..80e9b0df39 100644 --- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala +++ b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala @@ -3,7 +3,7 @@ package scala.util.parsing.combinator.testing import scala.util.parsing.combinator._ import scala.util.parsing.input._ -import language.postfixOps +import scala.language.postfixOps @deprecated("This class will be removed", "2.10.0") case class Ident(s: String) diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala index 57a2c9c4c2..3366584ab2 100644 --- a/src/library/scala/util/parsing/input/OffsetPosition.scala +++ b/src/library/scala/util/parsing/input/OffsetPosition.scala @@ -8,7 +8,7 @@ package scala.util.parsing.input -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer /** `OffsetPosition` is a standard class for positions * represented as offsets into a source ``document''. diff --git a/src/library/scala/volatile.scala b/src/library/scala/volatile.scala index 88726d9336..1290e54f3a 100644 --- a/src/library/scala/volatile.scala +++ b/src/library/scala/volatile.scala @@ -10,7 +10,7 @@ package scala -import annotation.meta._ +import scala.annotation.meta._ @field -class volatile extends annotation.StaticAnnotation +class volatile extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index f140fd1e07..2ca1dbfcd0 100755 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -73,7 +73,7 @@ extends Node with Serializable throw new IllegalArgumentException("prefix of zero length, use null instead") if (scope == null) - throw new IllegalArgumentException("scope is null, use xml.TopScope for empty scope") + throw new IllegalArgumentException("scope is null, use scala.xml.TopScope for empty scope") //@todo: copy the children, // setting namespace scope if necessary diff --git a/src/library/scala/xml/Equality.scala b/src/library/scala/xml/Equality.scala index 07651adb90..0efbb4c511 100644 --- a/src/library/scala/xml/Equality.scala +++ b/src/library/scala/xml/Equality.scala @@ -13,7 +13,7 @@ package scala.xml * all the `xml` classes go through the `xml.Equality trait`. There are two * forms of `xml` comparison. * - * 1. `'''def''' strict_==(other: xml.Equality)` + * 1. `'''def''' strict_==(other: scala.xml.Equality)` * * This one tries to honor the little things like symmetry and hashCode * contracts. The `equals` method routes all comparisons through this. diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala index e98ec90aca..15b3cb6d4a 100644 --- a/src/library/scala/xml/MetaData.scala +++ b/src/library/scala/xml/MetaData.scala @@ -9,7 +9,7 @@ package scala.xml import Utility.sbToString -import annotation.tailrec +import scala.annotation.tailrec import scala.collection.{ AbstractIterable, Iterator } /** diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index 40ddc7d85c..e50e68d4fd 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -8,10 +8,10 @@ package scala.xml -import collection.{ mutable, immutable, generic, SeqLike, AbstractSeq } +import scala.collection.{ mutable, immutable, generic, SeqLike, AbstractSeq } import mutable.{ Builder, ListBuffer } import generic.{ CanBuildFrom } -import language.implicitConversions +import scala.language.implicitConversions /** This object ... * diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index bae529c85c..50a284d7cd 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -10,7 +10,7 @@ package scala.xml import scala.collection.mutable import parsing.XhtmlEntities -import language.implicitConversions +import scala.language.implicitConversions /** * The `Utility` object provides utility functions for processing instances diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala index a5d2a6bd7e..f98aff5709 100644 --- a/src/library/scala/xml/dtd/ContentModel.scala +++ b/src/library/scala/xml/dtd/ContentModel.scala @@ -11,9 +11,9 @@ package scala.xml package dtd -import util.regexp.WordExp -import util.automata._ -import Utility.sbToString +import scala.util.regexp.WordExp +import scala.util.automata._ +import scala.xml.Utility.sbToString import PartialFunction._ object ContentModel extends WordExp { diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index c764d042c8..07fab27957 100755 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -24,7 +24,7 @@ import scala.xml.parsing.{ ExternalSources, MarkupHandler, MarkupParser } * @author Paul Phillips */ class XMLEventReader(src: Source) -extends collection.AbstractIterator[XMLEvent] +extends scala.collection.AbstractIterator[XMLEvent] with ProducerConsumerIterator[XMLEvent] { // We implement a pull parser as an iterator, but since we may be operating on diff --git a/src/partest/scala/tools/partest/PartestDefaults.scala b/src/partest/scala/tools/partest/PartestDefaults.scala index 73a7b92778..b27ce6ff75 100644 --- a/src/partest/scala/tools/partest/PartestDefaults.scala +++ b/src/partest/scala/tools/partest/PartestDefaults.scala @@ -2,7 +2,7 @@ package scala.tools package partest import nsc.io.{ File, Path, Directory } -import util.{ PathResolver } +import scala.tools.util.PathResolver import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty } import java.lang.Runtime.getRuntime diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index 146e6fc69f..9bfd444180 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -1,6 +1,6 @@ package scala.tools.partest -import reflect.{ classTag, ClassTag } +import scala.reflect.{ classTag, ClassTag } trait TestUtil { /** Given function and block of code, evaluates code block, diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 064b82da85..512c718040 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -13,7 +13,7 @@ import java.io.{File, FilenameFilter, IOException, StringWriter, FileReader, PrintWriter, FileWriter} import java.net.URI import scala.tools.nsc.io.{ Path, Directory, File => SFile } -import sys.process._ +import scala.sys.process._ import scala.collection.mutable trait FileUtil { diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala index 6fa31492f3..206ee19c76 100644 --- a/src/partest/scala/tools/partest/nest/SBTRunner.scala +++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala @@ -4,7 +4,7 @@ package nest import java.io.File import scala.tools.nsc.io.{ Directory } import scala.util.Properties.setProp -import collection.JavaConverters._ +import scala.collection.JavaConverters._ object SBTRunner extends DirectRunner { diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 16a95c8966..ec1778940f 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -6,7 +6,7 @@ package scala.tools import java.io.{ FileNotFoundException, File => JFile } import nsc.io.{ Path, Directory, File => SFile } -import util.{ PathResolver } +import scala.tools.util.PathResolver import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty } import scala.sys.process.javaVmArguments import java.util.concurrent.Callable @@ -62,7 +62,7 @@ package object partest { ) def allPropertiesString = { - import collection.JavaConversions._ + import scala.collection.JavaConversions._ System.getProperties.toList.sorted map { case (k, v) => "%s -> %s\n".format(k, v) } mkString "" } diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 27d3b8ba7d..65ff2ed9fa 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -23,7 +23,7 @@ trait Printers { self: Universe => case class BooleanFlag(val value: Option[Boolean]) object BooleanFlag { - import language.implicitConversions + import scala.language.implicitConversions implicit def booleanToBooleanFlag(value: Boolean): BooleanFlag = BooleanFlag(Some(value)) implicit def optionToBooleanFlag(value: Option[Boolean]): BooleanFlag = BooleanFlag(value) } diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 554b3bfca6..539984c67f 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -7,7 +7,7 @@ package internal // todo implement in terms of BitSet import scala.collection.{ mutable, immutable } -import math.max +import scala.math.max import util.Statistics /** A base type sequence (BaseTypeSeq) is an ordered sequence spanning all the base types @@ -99,7 +99,7 @@ trait BaseTypeSeqs { def copy(head: Type, offset: Int): BaseTypeSeq = { val arr = new Array[Type](elems.length + offset) - compat.Platform.arraycopy(elems, 0, arr, offset, elems.length) + scala.compat.Platform.arraycopy(elems, 0, arr, offset, elems.length) arr(0) = head newBaseTypeSeq(parents, arr) } diff --git a/src/reflect/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala index 6ece733b06..e5e5325b93 100644 --- a/src/reflect/scala/reflect/internal/Chars.scala +++ b/src/reflect/scala/reflect/internal/Chars.scala @@ -5,9 +5,9 @@ package scala.reflect package internal -import annotation.{ tailrec, switch } +import scala.annotation.{ tailrec, switch } import java.lang.{ Character => JCharacter } -import language.postfixOps +import scala.language.postfixOps /** Contains constants and classifier methods for characters */ trait Chars { diff --git a/src/reflect/scala/reflect/internal/ClassfileConstants.scala b/src/reflect/scala/reflect/internal/ClassfileConstants.scala index 124f1f881d..62ed130232 100644 --- a/src/reflect/scala/reflect/internal/ClassfileConstants.scala +++ b/src/reflect/scala/reflect/internal/ClassfileConstants.scala @@ -6,7 +6,7 @@ package scala.reflect package internal -import annotation.switch +import scala.annotation.switch object ClassfileConstants { diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index b434be64a3..61fa553484 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -7,7 +7,7 @@ package scala.reflect package internal import java.lang.Integer.toOctalString -import annotation.switch +import scala.annotation.switch trait Constants extends api.Constants { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 6d9f68a8a5..6d7aa19738 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -6,7 +6,7 @@ package scala.reflect package internal -import annotation.{ switch, meta } +import scala.annotation.{ switch, meta } import scala.collection.{ mutable, immutable } import Flags._ import PartialFunction._ diff --git a/src/reflect/scala/reflect/internal/FlagSets.scala b/src/reflect/scala/reflect/internal/FlagSets.scala index b03d01c944..6270416d4f 100644 --- a/src/reflect/scala/reflect/internal/FlagSets.scala +++ b/src/reflect/scala/reflect/internal/FlagSets.scala @@ -1,7 +1,7 @@ package scala.reflect package internal -import language.implicitConversions +import scala.language.implicitConversions trait FlagSets extends api.FlagSets { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 3f85db0f54..0f42db95e3 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -8,7 +8,7 @@ package internal import scala.io.Codec import java.security.MessageDigest -import language.implicitConversions +import scala.language.implicitConversions trait LowPriorityNames { self: Names => @@ -67,7 +67,7 @@ trait Names extends api.Names with LowPriorityNames { while (i < len) { if (nc + i == chrs.length) { val newchrs = new Array[Char](chrs.length * 2) - compat.Platform.arraycopy(chrs, 0, newchrs, 0, chrs.length) + scala.compat.Platform.arraycopy(chrs, 0, newchrs, 0, chrs.length) chrs = newchrs } chrs(nc + i) = cs(offset + i) @@ -183,7 +183,7 @@ trait Names extends api.Names with LowPriorityNames { /** Copy bytes of this name to buffer cs, starting at position `offset`. */ final def copyChars(cs: Array[Char], offset: Int) = - compat.Platform.arraycopy(chrs, index, cs, offset, len) + scala.compat.Platform.arraycopy(chrs, index, cs, offset, len) /** @return the ascii representation of this name */ final def toChars: Array[Char] = { @@ -199,7 +199,7 @@ trait Names extends api.Names with LowPriorityNames { */ final def copyUTF8(bs: Array[Byte], offset: Int): Int = { val bytes = Codec.toUTF8(chrs, index, len) - compat.Platform.arraycopy(bytes, 0, bs, offset, bytes.length) + scala.compat.Platform.arraycopy(bytes, 0, bs, offset, bytes.length) offset + bytes.length } diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 9580ed1f72..c23d22efab 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -10,7 +10,7 @@ package internal import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } import Flags._ -import compat.Platform.EOL +import scala.compat.Platform.EOL trait Printers extends api.Printers { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 92adc85e25..e70531df6e 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -8,8 +8,8 @@ package internal import java.security.MessageDigest import Chars.isOperatorPart -import annotation.switch -import language.implicitConversions +import scala.annotation.switch +import scala.language.implicitConversions import scala.collection.immutable import scala.io.Codec diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 0180ed4c4f..a59f01155a 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -8,7 +8,7 @@ package internal import Flags._ import base.Attachments -import collection.mutable.{ListBuffer, LinkedHashSet} +import scala.collection.mutable.{ListBuffer, LinkedHashSet} import util.Statistics trait Trees extends api.Trees { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 2e00316d5b..1dae6e70b7 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -14,13 +14,13 @@ import java.lang.Double.longBitsToDouble import Flags._ import PickleFormat._ import scala.collection.{ mutable, immutable } -import collection.mutable.ListBuffer -import annotation.switch +import scala.collection.mutable.ListBuffer +import scala.annotation.switch /** @author Martin Odersky * @version 1.0 */ -abstract class UnPickler /*extends reflect.generic.UnPickler*/ { +abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { val global: SymbolTable import global._ diff --git a/src/reflect/scala/reflect/internal/transform/Transforms.scala b/src/reflect/scala/reflect/internal/transform/Transforms.scala index c4c5dc3a1c..71cc80895d 100644 --- a/src/reflect/scala/reflect/internal/transform/Transforms.scala +++ b/src/reflect/scala/reflect/internal/transform/Transforms.scala @@ -2,7 +2,7 @@ package scala.reflect package internal package transform -import language.existentials +import scala.language.existentials trait Transforms { self: SymbolTable => @@ -38,4 +38,4 @@ trait Transforms { self: SymbolTable => def transformedType(tpe: Type) = erasure.scalaErasure(uncurry.uncurry(tpe)) -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/util/HashSet.scala b/src/reflect/scala/reflect/internal/util/HashSet.scala index 51e540e235..0d0f16372c 100644 --- a/src/reflect/scala/reflect/internal/util/HashSet.scala +++ b/src/reflect/scala/reflect/internal/util/HashSet.scala @@ -13,7 +13,7 @@ object HashSet { new HashSet[T](label, initialCapacity) } -class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) extends Set[T] with collection.generic.Clearable { +class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) extends Set[T] with scala.collection.generic.Clearable { private var used = 0 private var table = new Array[AnyRef](initialCapacity) private def index(x: Int): Int = math.abs(x % table.length) diff --git a/src/reflect/scala/reflect/internal/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala index e4c6e4aca1..0268881be7 100644 --- a/src/reflect/scala/reflect/internal/util/Position.scala +++ b/src/reflect/scala/reflect/internal/util/Position.scala @@ -6,9 +6,9 @@ package scala.reflect.internal.util -import reflect.ClassTag -import reflect.base.Attachments -import reflect.api.PositionApi +import scala.reflect.ClassTag +import scala.reflect.base.Attachments +import scala.reflect.api.PositionApi object Position { val tabInc = 8 @@ -274,4 +274,4 @@ class TransparentPosition(source: SourceFile, start: Int, point: Int, end: Int) override def isTransparent = true override def makeTransparent = this override def show = "<"+start+":"+end+">" -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/util/SourceFile.scala b/src/reflect/scala/reflect/internal/util/SourceFile.scala index 747c1ad298..9a71e02e08 100644 --- a/src/reflect/scala/reflect/internal/util/SourceFile.scala +++ b/src/reflect/scala/reflect/internal/util/SourceFile.scala @@ -8,7 +8,7 @@ package scala.reflect.internal.util import scala.tools.nsc.io.{ AbstractFile, VirtualFile } import scala.collection.mutable.ArrayBuffer -import annotation.tailrec +import scala.annotation.tailrec import java.util.regex.Pattern import java.io.IOException import scala.reflect.internal.Chars._ @@ -107,15 +107,15 @@ class BatchSourceFile(val file : AbstractFile, val content0: Array[Char]) extend def this(sourceName: String, cs: Seq[Char]) = this(new VirtualFile(sourceName), cs.toArray) def this(file: AbstractFile, cs: Seq[Char]) = this(file, cs.toArray) - // If non-whitespace tokens run all the way up to EOF, - // positions go wrong because the correct end of the last - // token cannot be used as an index into the char array. - // The least painful way to address this was to add a - // newline to the array. - val content = ( - if (content0.length == 0 || !content0.last.isWhitespace) - content0 :+ '\n' - else content0 + // If non-whitespace tokens run all the way up to EOF, + // positions go wrong because the correct end of the last + // token cannot be used as an index into the char array. + // The least painful way to address this was to add a + // newline to the array. + val content = ( + if (content0.length == 0 || !content0.last.isWhitespace) + content0 :+ '\n' + else content0 ) val length = content.length def start = 0 diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index f7b81ca252..2c90d2d525 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -1,6 +1,6 @@ package scala.reflect.internal.util -import collection.mutable +import scala.collection.mutable object Statistics { diff --git a/src/reflect/scala/reflect/internal/util/TableDef.scala b/src/reflect/scala/reflect/internal/util/TableDef.scala index 2e60ce3bcc..8e2bcc2ff7 100644 --- a/src/reflect/scala/reflect/internal/util/TableDef.scala +++ b/src/reflect/scala/reflect/internal/util/TableDef.scala @@ -1,7 +1,7 @@ package scala.reflect.internal.util import TableDef._ -import language.postfixOps +import scala.language.postfixOps /** A class for representing tabular data in a way that preserves * its inner beauty. See Exceptional for an example usage. diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala index cecf8e4658..fa83f70f3a 100644 --- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -2,7 +2,7 @@ package scala.reflect.internal package util import scala.collection.{ mutable, immutable } -import language.postfixOps +import scala.language.postfixOps trait TraceSymbolActivity { val global: SymbolTable @@ -108,12 +108,12 @@ trait TraceSymbolActivity { sym.name.decode + "#" + sym.id } - private def freq[T, U](xs: collection.Traversable[T])(fn: T => U): List[(U, Int)] = { + private def freq[T, U](xs: scala.collection.Traversable[T])(fn: T => U): List[(U, Int)] = { val ys = xs groupBy fn mapValues (_.size) ys.toList sortBy (-_._2) } - private def showMapFreq[T](xs: collection.Map[T, Traversable[_]])(showFn: T => String) { + private def showMapFreq[T](xs: scala.collection.Map[T, Traversable[_]])(showFn: T => String) { xs.mapValues(_.size).toList.sortBy(-_._2) take 100 foreach { case (k, size) => show(size, showFn(k)) } diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index a8a8b814b1..f01725cd1d 100644 --- a/src/reflect/scala/reflect/macros/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -86,7 +86,7 @@ trait Infrastructure { * Needs to be used with extreme care, since memory leaks here will swiftly crash the presentation compiler. * For example, Scala IDE typically launches a compiler run on every edit action so there might be hundreds of runs per minute. */ - val globalCache: collection.mutable.Map[Any, Any] + val globalCache: scala.collection.mutable.Map[Any, Any] /** A cache shared by all invocations of the same macro within a single compilation run. * @@ -95,5 +95,5 @@ trait Infrastructure { * * To share data between different macros and/or different compilation runs, use ``globalCache''. */ - val cache: collection.mutable.Map[Any, Any] + val cache: scala.collection.mutable.Map[Any, Any] } diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala index 1bee17d548..bdc6687edc 100644 --- a/src/reflect/scala/reflect/macros/Reifiers.scala +++ b/src/reflect/scala/reflect/macros/Reifiers.scala @@ -1,6 +1,8 @@ package scala.reflect package macros +import scala.reflect.api.PositionApi + trait Reifiers { self: Context => @@ -86,6 +88,6 @@ trait Reifiers { // made these guys non path-dependent, otherwise exception handling quickly becomes a mess -case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg) +case class ReificationError(val pos: PositionApi, val msg: String) extends Throwable(msg) -case class UnexpectedReificationError(val pos: reflect.api.PositionApi, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause) +case class UnexpectedReificationError(val pos: PositionApi, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause) diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index f4b68640ae..be2661149a 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -14,12 +14,12 @@ import internal.MissingRequirementError import internal.pickling.ByteCodecs import internal.ClassfileConstants._ import internal.pickling.UnPickler -import collection.mutable.{ HashMap, ListBuffer } +import scala.collection.mutable.{ HashMap, ListBuffer } import internal.Flags._ //import scala.tools.nsc.util.ScalaClassLoader //import scala.tools.nsc.util.ScalaClassLoader._ import ReflectionUtils.{staticSingletonInstance, innerSingletonInstance} -import language.existentials +import scala.language.existentials import scala.runtime.{ScalaRunTime, BoxesRunTime} import scala.reflect.internal.util.Collections._ diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index 0125fa2c53..eaf7d8326f 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -38,7 +38,7 @@ object ReflectionUtils { ) def show(cl: ClassLoader): String = { - import language.reflectiveCalls + import scala.language.reflectiveCalls def isAbstractFileClassLoader(clazz: Class[_]): Boolean = { if (clazz == null) return false diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 583b9d93f3..f3473d46a7 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -3,7 +3,7 @@ package runtime import internal.Flags import java.lang.{Class => jClass, Package => jPackage} -import collection.mutable +import scala.collection.mutable trait SymbolLoaders { self: SymbolTable => diff --git a/src/reflect/scala/reflect/runtime/TwoWayCache.scala b/src/reflect/scala/reflect/runtime/TwoWayCache.scala index e2bf5773d2..05debcba65 100644 --- a/src/reflect/scala/reflect/runtime/TwoWayCache.scala +++ b/src/reflect/scala/reflect/runtime/TwoWayCache.scala @@ -1,7 +1,7 @@ package scala.reflect package runtime -import collection.mutable.WeakHashMap +import scala.collection.mutable.WeakHashMap import java.lang.ref.WeakReference /** A cache that maintains a bijection between Java reflection type `J` diff --git a/src/reflect/scala/tools/nsc/io/File.scala b/src/reflect/scala/tools/nsc/io/File.scala index 1f3cac7ee1..fce0e339e0 100644 --- a/src/reflect/scala/tools/nsc/io/File.scala +++ b/src/reflect/scala/tools/nsc/io/File.scala @@ -16,7 +16,7 @@ import java.io.{ import java.io.{ File => JFile } import java.nio.channels.{ Channel, FileChannel } import scala.io.Codec -import language.{reflectiveCalls, implicitConversions} +import scala.language.{reflectiveCalls, implicitConversions} object File { def pathSeparator = java.io.File.pathSeparator diff --git a/src/reflect/scala/tools/nsc/io/Path.scala b/src/reflect/scala/tools/nsc/io/Path.scala index e965c70111..0a27e49686 100644 --- a/src/reflect/scala/tools/nsc/io/Path.scala +++ b/src/reflect/scala/tools/nsc/io/Path.scala @@ -12,7 +12,7 @@ import java.io.{ import java.io.{ File => JFile } import java.net.{ URI, URL } import scala.util.Random.alphanumeric -import language.implicitConversions +import scala.language.implicitConversions /** An abstraction for filesystem paths. The differences between * Path, File, and Directory are primarily to communicate intent. diff --git a/src/reflect/scala/tools/nsc/io/Streamable.scala b/src/reflect/scala/tools/nsc/io/Streamable.scala index ff770bd396..625429bdb3 100644 --- a/src/reflect/scala/tools/nsc/io/Streamable.scala +++ b/src/reflect/scala/tools/nsc/io/Streamable.scala @@ -10,7 +10,7 @@ import java.net.{ URI, URL } import java.io.{ BufferedInputStream, InputStream, PrintStream } import java.io.{ BufferedReader, InputStreamReader, Closeable => JCloseable } import scala.io.{ Codec, BufferedSource, Source } -import collection.mutable.ArrayBuffer +import scala.collection.mutable.ArrayBuffer import Path.fail /** Traits for objects which can be represented as Streams. diff --git a/src/reflect/scala/tools/nsc/io/ZipArchive.scala b/src/reflect/scala/tools/nsc/io/ZipArchive.scala index d1a91294a5..d7ec209525 100644 --- a/src/reflect/scala/tools/nsc/io/ZipArchive.scala +++ b/src/reflect/scala/tools/nsc/io/ZipArchive.scala @@ -11,7 +11,7 @@ import java.io.{ IOException, InputStream, ByteArrayInputStream } import java.io.{ File => JFile } import java.util.zip.{ ZipEntry, ZipFile, ZipInputStream } import scala.collection.{ immutable, mutable } -import annotation.tailrec +import scala.annotation.tailrec /** An abstraction for zip files and streams. Everything is written the way * it is for performance: we come through here a lot on every run. Be careful @@ -107,14 +107,14 @@ abstract class ZipArchive(override val file: JFile) extends AbstractFile with Eq // }) dirs get path match { case Some(v) => v - case None => + case None => val parent = ensureDir(dirs, dirName(path), null) val dir = new DirEntry(path) parent.entries(baseName(path)) = dir dirs(path) = dir dir } - + protected def getDir(dirs: mutable.Map[String, DirEntry], entry: ZipEntry): DirEntry = { if (entry.isDirectory) ensureDir(dirs, entry.getName, entry) else ensureDir(dirs, dirName(entry.getName), null) diff --git a/src/scalap/scala/tools/scalap/CodeWriter.scala b/src/scalap/scala/tools/scalap/CodeWriter.scala index f5db183abb..35de796727 100644 --- a/src/scalap/scala/tools/scalap/CodeWriter.scala +++ b/src/scalap/scala/tools/scalap/CodeWriter.scala @@ -13,7 +13,7 @@ import java.io._ class CodeWriter(writer: Writer) { - private val nl = compat.Platform.EOL + private val nl = scala.compat.Platform.EOL private var step = " " private var level = 0 private var align = false diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check index fd2667dbb8..ae6c6c695a 100644 --- a/test/files/neg/macro-without-xmacros-a.check +++ b/test/files/neg/macro-without-xmacros-a.check @@ -1,17 +1,17 @@ -Macros_2.scala:5: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. -This can be achieved by adding the import clause 'import language.experimental.macros' -or by setting the compiler option -language:experimental.macros. -See the Scala docs for value scala.language.experimental.macros for a discussion -why the feature needs to be explicitly enabled. - def foo(x: Int): Int = macro foo_impl - ^ -Macros_2.scala:7: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. - def bar(x: Int): Int = macro bar_impl - ^ -Macros_2.scala:11: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. - def quux(x: Int): Int = macro quux_impl - ^ -three errors found +Macros_2.scala:5: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. +This can be achieved by adding the import clause 'import scala.language.experimental.macros' +or by setting the compiler option -language:experimental.macros. +See the Scala docs for value scala.language.experimental.macros for a discussion +why the feature needs to be explicitly enabled. + def foo(x: Int): Int = macro foo_impl + ^ +Macros_2.scala:7: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def bar(x: Int): Int = macro bar_impl + ^ +Macros_2.scala:11: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def quux(x: Int): Int = macro quux_impl + ^ +three errors found diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check index 2d675b8319..c3cadcf36a 100644 --- a/test/files/neg/macro-without-xmacros-b.check +++ b/test/files/neg/macro-without-xmacros-b.check @@ -1,17 +1,17 @@ -Macros_2.scala:3: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. -This can be achieved by adding the import clause 'import language.experimental.macros' -or by setting the compiler option -language:experimental.macros. -See the Scala docs for value scala.language.experimental.macros for a discussion -why the feature needs to be explicitly enabled. - def foo(x: Int): Int = macro Impls.foo_impl - ^ -Macros_2.scala:5: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. - def bar(x: Int): Int = macro Impls.bar_impl - ^ -Macros_2.scala:9: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. - def quux(x: Int): Int = macro Impls.quux_impl - ^ -three errors found +Macros_2.scala:3: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. +This can be achieved by adding the import clause 'import scala.language.experimental.macros' +or by setting the compiler option -language:experimental.macros. +See the Scala docs for value scala.language.experimental.macros for a discussion +why the feature needs to be explicitly enabled. + def foo(x: Int): Int = macro Impls.foo_impl + ^ +Macros_2.scala:5: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def bar(x: Int): Int = macro Impls.bar_impl + ^ +Macros_2.scala:9: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def quux(x: Int): Int = macro Impls.quux_impl + ^ +three errors found diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check index f44a81c471..f6757f97e3 100644 --- a/test/files/neg/t6040.check +++ b/test/files/neg/t6040.check @@ -1,6 +1,6 @@ error: extension of type scala.Dynamic needs to be enabled by making the implicit value language.dynamics visible. -This can be achieved by adding the import clause 'import language.dynamics' +This can be achieved by adding the import clause 'import scala.language.dynamics' or by setting the compiler option -language:dynamics. See the Scala docs for value scala.language.dynamics for a discussion why the feature needs to be explicitly enabled. -- cgit v1.2.3