From 2d4f0f1859b957b744f9b9f222dec8e8c478a4a8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 18 Nov 2013 09:39:55 -0800 Subject: Removing deprecated code. Code which has been deprecated since 2.10.0 and which allowed for straightforward removal. --- .../scala/reflect/macros/compiler/Resolvers.scala | 2 +- .../scala/tools/nsc/backend/jvm/GenASM.scala | 2 +- .../scala/tools/nsc/reporters/Reporter.scala | 6 - .../scala/tools/nsc/scratchpad/Mixer.scala | 99 ---------- .../tools/nsc/scratchpad/SourceInserter.scala | 21 --- src/compiler/scala/tools/nsc/util/package.scala | 35 +--- .../tools/nsc/interactive/CompilerControl.scala | 37 ---- .../scala/tools/nsc/interactive/Global.scala | 13 -- .../scala/tools/nsc/interactive/REPL.scala | 55 ------ .../tools/nsc/interactive/ScratchPadMaker.scala | 201 --------------------- src/library/scala/collection/immutable/Range.scala | 16 -- src/library/scala/math/BigDecimal.scala | 3 +- src/library/scala/math/BigInt.scala | 3 +- .../reflect/ClassManifestDeprecatedApis.scala | 23 +-- src/library/scala/reflect/Manifest.scala | 12 +- src/library/scala/runtime/WorksheetSupport.scala | 93 ---------- src/library/scala/util/hashing/MurmurHash3.scala | 8 - src/reflect/scala/reflect/api/JavaUniverse.scala | 2 +- .../scala/reflect/internal/Definitions.scala | 16 +- src/reflect/scala/reflect/internal/Mirrors.scala | 12 +- src/reflect/scala/reflect/internal/Symbols.scala | 24 --- src/repl/scala/tools/nsc/interpreter/IMain.scala | 3 +- 22 files changed, 32 insertions(+), 654 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/scratchpad/Mixer.scala delete mode 100644 src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala delete mode 100644 src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala delete mode 100644 src/library/scala/runtime/WorksheetSupport.scala (limited to 'src') diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala index 03d306f593..e4851632a5 100644 --- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala +++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala @@ -9,7 +9,7 @@ trait Resolvers { import global._ import analyzer._ - import definitions.{EmptyPackageClass => _, _} + import definitions._ import treeInfo._ import gen._ private val runDefinitions = currentRun.runDefinitions diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 5e885fdd04..cf20348942 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -293,7 +293,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def inameToSymbol(iname: String): Symbol = { val name = global.newTypeName(iname) val res0 = - if (nme.isModuleName(name)) rootMirror.getModule(name.dropModule) + if (nme.isModuleName(name)) rootMirror.getModuleByName(name.dropModule) else rootMirror.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested). assert(res0 != NoSymbol) val res = jsymbol(res0) diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 0544da5d3c..68362c066d 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -80,10 +80,4 @@ abstract class Reporter { WARNING.count = 0 cancelled = false } - - // sbt compat - @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0") - def countElementsAsString(n: Int, elements: String): String = StringOps.countElementsAsString(n, elements) - @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0") - def countAsString(n: Int): String = StringOps.countAsString(n) } diff --git a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala deleted file mode 100644 index 3aecc06b1e..0000000000 --- a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala +++ /dev/null @@ -1,99 +0,0 @@ -package scala.tools.nsc.scratchpad - -import java.io.{FileInputStream, InputStreamReader, IOException} - -import scala.collection.mutable.ArrayBuffer - -@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") -class Mixer { - - protected val stdSeparator = "//> " - protected val ctdSeparator = "//| " - protected val sepColumn = 50 - protected val tabInc = 8 - - type Comments = Seq[(Int, Array[Char])] - - def parseComments(comments: Array[Char]): Iterator[(Int, Array[Char])] = new Iterator[(Int, Array[Char])] { - var idx = 0 - def hasNext = idx < comments.length - def next() = { - val nextSpace = comments indexOf (' ', idx) - var nextNL = comments indexOf ('\n', nextSpace + 1) - if (nextNL < 0) nextNL = comments.length - val result = - (new String(comments.slice(idx, nextSpace)).toInt, comments.slice(nextSpace + 1, nextNL)) - idx = nextNL + 1 - result - } - } - - def mix(source: Array[Char], comments: Array[Char]): Array[Char] = { - val mixed = new ArrayBuffer[Char] - var written = 0 - def align() = { - var idx = mixed.lastIndexOf('\n') + 1 - var col = 0 - while (idx < mixed.length) { - col = - if (mixed(idx) == '\t') (col / tabInc) * tabInc + tabInc - else col + 1 - idx += 1 - } - if (col > sepColumn) { - mixed += '\n' - col = 0 - } - while (col < sepColumn) { - mixed += ' ' - col += 1 - } - } - for ((offset, cs) <- parseComments(comments)) { - val sep = - if (written < offset) { - for (i <- written until offset) mixed += source(i) - written = offset - stdSeparator - } else { - mixed += '\n' - ctdSeparator - } - align() - mixed ++= sep ++= cs - } - mixed ++= source.view(written, source.length) - mixed.toArray - } - -} - -object Mixer extends Mixer { - - def contents(name: String): Array[Char] = { - val page = new Array[Char](2 << 14) - val buf = new ArrayBuffer[Char] - val in = new FileInputStream(name) - val rdr = new InputStreamReader(in) - var nread = 0 - do { - nread = rdr.read(page, 0, page.length) - buf ++= (if (nread == page.length) page else page.take(nread)) - } while (nread >= 0) - buf.toArray - } - - def main(args: Array[String]) { - val mixer = new Mixer - try { - require(args.length == 2, "required arguments: file1 file2") - val source = contents(args(0)) - val comments = contents(args(1)) - val mixed = mixer.mix(source, comments) - println(mixed.mkString) - } catch { - case ex: IOException => - println("error: "+ ex.getMessage) - } - } -} diff --git a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala deleted file mode 100644 index 61c1717fea..0000000000 --- a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala +++ /dev/null @@ -1,21 +0,0 @@ -package scala.tools.nsc -package scratchpad - -import scala.reflect.internal.Chars._ - -@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") -object SourceInserter { - def stripRight(cs: Array[Char]): Array[Char] = { - val lines = - new String(cs) split "\n" - def leftPart(str: String) = - (str split """//>|//\|""").head - def isContinuation(str: String) = - ((str contains "//>") || (str contains "//|")) && (leftPart(str) forall isWhitespace) - def stripTrailingWS(str: String) = - str take (str lastIndexWhere (!isWhitespace(_))) + 1 - val prefixes = - lines filterNot isContinuation map leftPart map stripTrailingWS - (prefixes mkString "\n").toArray - } -} diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index cb46004174..4237f36ade 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -90,51 +90,22 @@ package object util { lazy val trace = new SimpleTracer(System.out) - @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0") - val StringOps = scala.reflect.internal.util.StringOps - - @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0") - type StringOps = scala.reflect.internal.util.StringOps - - @deprecated("scala.reflect.internal.util.WeakHashSet", "2.10.0") - type WeakHashSet[T <: AnyRef] = scala.reflect.internal.util.WeakHashSet[T] - - @deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0") - val Position = scala.reflect.internal.util.Position - + // These four deprecated since 2.10.0 are still used in (at least) + // the sbt 0.12.4 compiler interface. @deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0") type Position = scala.reflect.internal.util.Position - @deprecated("Moved to scala.reflect.internal.util.NoPosition", "2.10.0") val NoPosition = scala.reflect.internal.util.NoPosition - @deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0") val FakePos = scala.reflect.internal.util.FakePos - @deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0") type FakePos = scala.reflect.internal.util.FakePos - @deprecated("Moved to scala.reflect.internal.util.OffsetPosition", "2.10.0") - type OffsetPosition = scala.reflect.internal.util.OffsetPosition - + // These three were still used in scala-refactoring. @deprecated("Moved to scala.reflect.internal.util.RangePosition", "2.10.0") type RangePosition = scala.reflect.internal.util.RangePosition - @deprecated("Moved to scala.reflect.internal.util.SourceFile", "2.10.0") type SourceFile = scala.reflect.internal.util.SourceFile - - @deprecated("Moved to scala.reflect.internal.util.NoSourceFile", "2.10.0") - val NoSourceFile = scala.reflect.internal.util.NoSourceFile - - @deprecated("Moved to scala.reflect.internal.util.NoFile", "2.10.0") - val NoFile = scala.reflect.internal.util.NoFile - - @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0") - val ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile - - @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0") - type ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile - @deprecated("Moved to scala.reflect.internal.util.BatchSourceFile", "2.10.0") type BatchSourceFile = scala.reflect.internal.util.BatchSourceFile diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala index d036a6e853..69cae24808 100644 --- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala @@ -62,17 +62,6 @@ trait CompilerControl { self: Global => def onUnitOf[T](source: SourceFile)(op: RichCompilationUnit => T): T = op(unitOfFile.getOrElse(source.file, new RichCompilationUnit(source))) - /** The compilation unit corresponding to a source file - * if it does not yet exist create a new one atomically - * Note: We want to get roid of this operation as it messes compiler invariants. - */ - @deprecated("use getUnitOf(s) or onUnitOf(s) instead", "2.10.0") - def unitOf(s: SourceFile): RichCompilationUnit = getOrCreateUnitOf(s) - - /** The compilation unit corresponding to a position */ - @deprecated("use getUnitOf(pos.source) or onUnitOf(pos.source) instead", "2.10.0") - def unitOf(pos: Position): RichCompilationUnit = getOrCreateUnitOf(pos.source) - /** Removes the CompilationUnit corresponding to the given SourceFile * from consideration for recompilation. */ @@ -229,18 +218,6 @@ trait CompilerControl { self: Global => def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) = postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response)) - /** Set sync var `response` to a pair consisting of - * - the fully qualified name of the first top-level object definition in the file. - * or "" if there are no object definitions. - * - the text of the instrumented program which, when run, - * prints its output and all defined values in a comment column. - * - * @param source The source file to be analyzed - * @param response The response. - */ - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - def askInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) = - postWorkItem(new AskInstrumentedItem(source, line, response)) /** Cancels current compiler run and start a fresh one where everything will be re-typechecked * (but not re-loaded). @@ -250,11 +227,6 @@ trait CompilerControl { self: Global => /** Tells the compile server to shutdown, and not to restart again */ def askShutdown() = scheduler raise ShutdownReq - @deprecated("use parseTree(source) instead", "2.10.0") // deleted 2nd parameter, as this has to run on 2.8 also. - def askParse(source: SourceFile, response: Response[Tree]) = respond(response) { - parseTree(source) - } - /** Returns parse tree for source `source`. No symbols are entered. Syntax errors are reported. * * This method is thread-safe and as such can safely run outside of the presentation @@ -419,15 +391,6 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - case class AskInstrumentedItem(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem { - def apply() = self.getInstrumented(source, line, response) - override def toString = "getInstrumented "+source - - def raiseMissing() = - response raise new MissingResponse - } - /** A do-nothing work scheduler that responds immediately with MissingResponse. * * Used during compiler shutdown. diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index da838e0f83..a1878c77e0 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -100,7 +100,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") with CompilerControl with ContextTrees with RichCompilationUnits - with ScratchPadMaker with Picklers { import definitions._ @@ -1171,18 +1170,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } } - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - def getInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) { - try { - interruptsEnabled = false - respond(response) { - instrument(source, line) - } - } finally { - interruptsEnabled = true - } - } - // ---------------- Helper classes --------------------------- /** The typer run */ diff --git a/src/interactive/scala/tools/nsc/interactive/REPL.scala b/src/interactive/scala/tools/nsc/interactive/REPL.scala index 33981771ec..8e9b0ceee0 100644 --- a/src/interactive/scala/tools/nsc/interactive/REPL.scala +++ b/src/interactive/scala/tools/nsc/interactive/REPL.scala @@ -9,7 +9,6 @@ package interactive import scala.reflect.internal.util._ import scala.tools.nsc.reporters._ import scala.tools.nsc.io._ -import scala.tools.nsc.scratchpad.SourceInserter import java.io.FileWriter /** Interface of interactive compiler to a client such as an IDE @@ -89,8 +88,6 @@ object REPL { val completeResult = new Response[List[comp.Member]] val typedResult = new Response[comp.Tree] val structureResult = new Response[comp.Tree] - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - val instrumentedResult = new Response[(String, Array[Char])] def makePos(file: String, off1: String, off2: String) = { val source = toSourceFile(file) @@ -112,52 +109,6 @@ object REPL { show(structureResult) } - /** Write instrumented source file to disk. - * @param iFullName The full name of the first top-level object in source - * @param iContents An Array[Char] containing the instrumented source - * @return The name of the instrumented source file - */ - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - def writeInstrumented(iFullName: String, suffix: String, iContents: Array[Char]): String = { - val iSimpleName = iFullName drop ((iFullName lastIndexOf '.') + 1) - val iSourceName = iSimpleName + suffix - val ifile = new FileWriter(iSourceName) - ifile.write(iContents) - ifile.close() - iSourceName - } - - /** The method for implementing worksheet functionality. - * @param arguments a file name, followed by optional command line arguments that are passed - * to the compiler that processes the instrumented source. - * @param line A line number that controls uop to which line results should be produced - * If line = -1, results are produced for all expressions in the worksheet. - * @return The generated file content containing original source in the left column - * and outputs in the right column, or None if the presentation compiler - * does not respond to askInstrumented. - */ - @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") - def instrument(arguments: List[String], line: Int): Option[(String, String)] = { - val source = toSourceFile(arguments.head) - // strip right hand side comment column and any trailing spaces from all lines - val strippedContents = SourceInserter.stripRight(source.content) - val strippedSource = new BatchSourceFile(source.file, strippedContents) - println("stripped source = "+strippedSource+":"+strippedContents.mkString) - comp.askReload(List(strippedSource), reloadResult) - comp.askInstrumented(strippedSource, line, instrumentedResult) - using(instrumentedResult) { - case (iFullName, iContents) => - println(s"instrumented source $iFullName = ${iContents.mkString}") - val iSourceName = writeInstrumented(iFullName, "$instrumented.scala", iContents) - val sSourceName = writeInstrumented(iFullName, "$stripped.scala", strippedContents) - (iSourceName, sSourceName) -/* - * val vdirOpt = compileInstrumented(iSourceName, arguments.tail) - runInstrumented(vdirOpt, iFullName, strippedSource.content) - */ - } - } - loop { line => (line split " ").toList match { case "reload" :: args => @@ -177,10 +128,6 @@ object REPL { doComplete(makePos(file, off1, off2)) case List("complete", file, off1) => doComplete(makePos(file, off1, off1)) - case "instrument" :: arguments => - println(instrument(arguments, -1)) - case "instrumentTo" :: line :: arguments => - println(instrument(arguments, line.toInt)) case List("quit") => comp.askShutdown() sys.exit(1) @@ -195,8 +142,6 @@ object REPL { | typeat | complete | compile - | instrument * - | instrumentTo * | structure | quit |""".stripMargin) diff --git a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala deleted file mode 100644 index 2400b97d97..0000000000 --- a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ /dev/null @@ -1,201 +0,0 @@ -package scala -package tools.nsc -package interactive - -import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition} -import scala.collection.mutable.ArrayBuffer -import scala.reflect.internal.Chars.{isLineBreakChar, isWhitespace} -import ast.parser.Tokens._ - -@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") -trait ScratchPadMaker { self: Global => - - import definitions._ - - private case class Patch(offset: Int, text: String) - - private class Patcher(contents: Array[Char], lex: LexicalStructure, endOffset: Int) extends Traverser { - var objectName: String = "" - - private val patches = new ArrayBuffer[Patch] - private val toPrint = new ArrayBuffer[String] - private var skipped = 0 - private var resNum: Int = -1 - - private def nextRes(): String = { - resNum += 1 - "res$"+resNum - } - - private def nameType(name: String, tpe: Type): String = { - // if name ends in symbol character, add a space to separate it from the following ':' - val pad = if (Character.isLetter(name.last) || Character.isDigit(name.last)) "" else " " - name+pad+": "+tpe - } - - private def nameType(sym: Symbol): String = nameType(sym.name.decoded, sym.tpe) - - private def literal(str: String) = "\"\"\""+str+"\"\"\"" - - private val prologue = ";import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{" - - private val epilogue = "}" - - private def applyPendingPatches(offset: Int) = { - if (skipped == 0) patches += Patch(offset, prologue) - for (msg <- toPrint) patches += Patch(offset, ";System.out.println("+msg+")") - toPrint.clear() - } - - /** The position where to insert an instrumentation statement in front of given statement. - * This is at the latest `stat.pos.start`. But in order not to mess with column numbers - * in position we try to insert it at the end of the previous token instead. - * Furthermore, `(' tokens have to be skipped because they do not show up - * in statement range positions. - */ - private def instrumentPos(start: Int): Int = { - val (prevToken, prevStart, prevEnd) = lex.locate(start - 1) - if (prevStart >= start) start - else if (prevToken == LPAREN) instrumentPos(prevStart) - else prevEnd - } - - private def addSkip(stat: Tree): Unit = { - val ipos = instrumentPos(stat.pos.start) - if (stat.pos.start > skipped) applyPendingPatches(ipos) - if (stat.pos.start >= endOffset) - patches += Patch(ipos, ";$stop()") - var end = stat.pos.end - if (end > skipped) { - while (end < contents.length && !isLineBreakChar(contents(end))) end += 1 - patches += Patch(ipos, ";$skip("+(end-skipped)+"); ") - skipped = end - } - } - - private def addSandbox(expr: Tree) = {} -// patches += (Patch(expr.pos.start, "sandbox("), Patch(expr.pos.end, ")")) - - private def resultString(prefix: String, expr: String) = - literal(prefix + " = ") + " + $show(" + expr + ")" - - private def traverseStat(stat: Tree) = - if (stat.pos.isInstanceOf[RangePosition]) { - stat match { - case ValDef(_, _, _, rhs) => - addSkip(stat) - if (stat.symbol.isLazy) - toPrint += literal(nameType(stat.symbol) + " = ") - else if (!stat.symbol.isSynthetic) { - addSandbox(rhs) - toPrint += resultString(nameType(stat.symbol), stat.symbol.name.toString) - } - case DefDef(_, _, _, _, _, _) => - addSkip(stat) - toPrint += literal(nameType(stat.symbol)) - case Annotated(_, arg) => - traverse(arg) - case DocDef(_, defn) => - traverse(defn) - case _ => - if (stat.isTerm) { - addSkip(stat) - if (stat.tpe.typeSymbol == UnitClass) { - addSandbox(stat) - } else { - val resName = nextRes() - val dispResName = resName filter ('$' != _) - val offset = instrumentPos(stat.pos.start) - patches += Patch(offset, "val " + resName + " = ") - addSandbox(stat) - toPrint += resultString(nameType(dispResName, stat.tpe), resName) - } - } - } - } - - override def traverse(tree: Tree): Unit = tree match { - case PackageDef(_, _) => - super.traverse(tree) - case ModuleDef(_, name, Template(_, _, body)) => - val topLevel = objectName.isEmpty - if (topLevel) { - objectName = tree.symbol.fullName - body foreach traverseStat - if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements - applyPendingPatches(skipped) - patches += Patch(skipped, epilogue) - } - } - case _ => - } - - /** The patched text. - * @require traverse is run first - */ - def result: Array[Char] = { - val reslen = contents.length + (patches map (_.text.length)).sum - val res = Array.ofDim[Char](reslen) - var lastOffset = 0 - var from = 0 - var to = 0 - for (Patch(offset, text) <- patches) { - val delta = offset - lastOffset - assert(delta >= 0) - Array.copy(contents, from, res, to, delta) - from += delta - to += delta - lastOffset = offset - text.copyToArray(res, to) - to += text.length - } - assert(contents.length - from == reslen - to) - Array.copy(contents, from, res, to, contents.length - from) - res - } - } - - class LexicalStructure(source: SourceFile) { - val token = new ArrayBuffer[Int] - val startOffset = new ArrayBuffer[Int] - val endOffset = new ArrayBuffer[Int] - private val scanner = new syntaxAnalyzer.UnitScanner(new CompilationUnit(source)) - scanner.init() - while (scanner.token != EOF) { - startOffset += scanner.offset - token += scanner.token - scanner.nextToken() - endOffset += scanner.lastOffset - } - - /** @return token that starts before or at offset, its startOffset, its endOffset - */ - def locate(offset: Int): (Int, Int, Int) = { - var lo = 0 - var hi = token.length - 1 - while (lo < hi) { - val mid = (lo + hi + 1) / 2 - if (startOffset(mid) <= offset) lo = mid - else hi = mid - 1 - } - (token(lo), startOffset(lo), endOffset(lo)) - } - } - - /** Compute an instrumented version of a sourcefile. - * @param source The given sourcefile. - * @param line The line up to which results should be printed, -1 = whole document. - * @return A pair consisting of - * - the fully qualified name of the first top-level object definition in the file. - * or "" if there are no object definitions. - * - the text of the instrumented program which, when run, - * prints its output and all defined values in a comment column. - */ - protected def instrument(source: SourceFile, line: Int): (String, Array[Char]) = { - val tree = typedTree(source, forceReload = true) - val endOffset = if (line < 0) source.length else source.lineToOffset(line + 1) - val patcher = new Patcher(source.content, new LexicalStructure(source), endOffset) - patcher.traverse(tree) - (patcher.objectName, patcher.result) - } -} diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 34b2346851..00f398a4b0 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -117,22 +117,6 @@ extends scala.collection.AbstractSeq[Int] fail() } - @deprecated("Range.foreach() is now self-contained, making this auxiliary method redundant.", "2.10.1") - def validateRangeBoundaries(f: Int => Any): Boolean = { - validateMaxLength() - - start != Int.MinValue || end != Int.MinValue || { - var count = 0 - var num = start - while (count < numRangeElements) { - f(num) - count += 1 - num += step - } - false - } - } - final def apply(idx: Int): Int = { validateMaxLength() if (idx < 0 || idx >= numRangeElements) throw new IndexOutOfBoundsException(idx.toString) diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index 0a2da16523..d783dd29f5 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -158,8 +158,7 @@ object BigDecimal { * @author Stephane Micheloud * @version 1.0 */ -@deprecatedInheritance("This class will be made final.", "2.10.0") -class BigDecimal( +final class BigDecimal( val bigDecimal: BigDec, val mc: MathContext) extends ScalaNumber with ScalaNumericConversions with Serializable { diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index b25dbefebd..5e70bdc2f6 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -109,8 +109,7 @@ object BigInt { * @author Martin Odersky * @version 1.0, 15/07/2003 */ -@deprecatedInheritance("This class will be made final.", "2.10.0") -class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable { +final class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable { /** Returns the hash code for this BigInt. */ override def hashCode(): Int = if (isValidLong) unifiedPrimitiveHashcode() diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala index 798746851a..ca7a3cddb8 100644 --- a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala +++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala @@ -16,6 +16,7 @@ import java.lang.{ Class => jClass } trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { self: ClassManifest[T] => + // Still in use in target test.junit.comp. @deprecated("Use runtimeClass instead", "2.10.0") def erasure: jClass[_] = runtimeClass @@ -64,12 +65,12 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { // when the erasure is the same, even before considering variance. !cannotMatch && { // this part is wrong for not considering variance - if (this.erasure == that.erasure) + if (this.runtimeClass == that.runtimeClass) subargs(this.typeArguments, that.typeArguments) // this part is wrong for punting unless the rhs has no type // arguments, but it's better than a blindfolded pinata swing. else - that.typeArguments.isEmpty && subtype(this.erasure, that.erasure) + that.typeArguments.isEmpty && subtype(this.runtimeClass, that.runtimeClass) } } @@ -91,29 +92,29 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { @deprecated("Use wrap instead", "2.10.0") def arrayManifest: ClassManifest[Array[T]] = - ClassManifest.classType[Array[T]](arrayClass[T](erasure), this) + ClassManifest.classType[Array[T]](arrayClass[T](runtimeClass), this) override def newArray(len: Int): Array[T] = - java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]] + java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]] @deprecated("Use wrap.newArray instead", "2.10.0") def newArray2(len: Int): Array[Array[T]] = - java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len) + java.lang.reflect.Array.newInstance(arrayClass[T](runtimeClass), len) .asInstanceOf[Array[Array[T]]] @deprecated("Use wrap.wrap.newArray instead", "2.10.0") def newArray3(len: Int): Array[Array[Array[T]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len) + java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](runtimeClass)), len) .asInstanceOf[Array[Array[Array[T]]]] @deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0") def newArray4(len: Int): Array[Array[Array[Array[T]]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len) + java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass))), len) .asInstanceOf[Array[Array[Array[Array[T]]]]] @deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0") def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] = - java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len) + java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass)))), len) .asInstanceOf[Array[Array[Array[Array[Array[T]]]]]] @deprecated("Create WrappedArray directly instead", "2.10.0") @@ -131,7 +132,7 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] { protected def argString = if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]") - else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]" + else if (runtimeClass.isArray) "["+ClassManifest.fromClass(runtimeClass.getComponentType)+"]" else "" } @@ -221,7 +222,7 @@ object ClassManifestFactory { */ def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] = new ClassManifest[T] { - override def runtimeClass = upperbound.erasure + override def runtimeClass = upperbound.runtimeClass override val typeArguments = args.toList override def toString = prefix.toString+"#"+name+argString } @@ -236,6 +237,6 @@ private class ClassTypeManifest[T]( { override def toString = (if (prefix.isEmpty) "" else prefix.get.toString+"#") + - (if (erasure.isArray) "Array" else erasure.getName) + + (if (runtimeClass.isArray) "Array" else runtimeClass.getName) + argString } \ No newline at end of file diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 3bc76da295..803c980058 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -46,7 +46,7 @@ trait Manifest[T] extends ClassManifest[T] with Equals { override def typeArguments: List[Manifest[_]] = Nil override def arrayManifest: Manifest[Array[T]] = - Manifest.classType[Array[T]](arrayClass[T](erasure), this) + Manifest.classType[Array[T]](arrayClass[T](runtimeClass), this) override def canEqual(that: Any): Boolean = that match { case _: Manifest[_] => true @@ -56,10 +56,10 @@ trait Manifest[T] extends ClassManifest[T] with Equals { * faster than <:< and rules out most comparisons. */ override def equals(that: Any): Boolean = that match { - case m: Manifest[_] => (m canEqual this) && (this.erasure == m.erasure) && (this <:< m) && (m <:< this) + case m: Manifest[_] => (m canEqual this) && (this.runtimeClass == m.runtimeClass) && (this <:< m) && (m <:< this) case _ => false } - override def hashCode = this.erasure.## + override def hashCode = this.runtimeClass.## } // TODO undeprecated until Scala reflection becomes non-experimental @@ -238,7 +238,7 @@ object ManifestFactory { override val typeArguments: List[Manifest[_]]) extends Manifest[T] { override def toString = (if (prefix.isEmpty) "" else prefix.get.toString+"#") + - (if (erasure.isArray) "Array" else erasure.getName) + + (if (runtimeClass.isArray) "Array" else runtimeClass.getName) + argString } @@ -259,7 +259,7 @@ object ManifestFactory { */ def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] = new Manifest[T] { - def runtimeClass = upperBound.erasure + def runtimeClass = upperBound.runtimeClass override def toString = "_" + (if (lowerBound eq Nothing) "" else " >: "+lowerBound) + @@ -269,7 +269,7 @@ object ManifestFactory { /** Manifest for the intersection type `parents_0 with ... with parents_n'. */ def intersectionType[T](parents: Manifest[_]*): Manifest[T] = new Manifest[T] { - def runtimeClass = parents.head.erasure + def runtimeClass = parents.head.runtimeClass override def toString = parents.mkString(" with ") } } diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala deleted file mode 100644 index d86f8873aa..0000000000 --- a/src/library/scala/runtime/WorksheetSupport.scala +++ /dev/null @@ -1,93 +0,0 @@ -package scala.runtime -import java.io.{OutputStream, PrintStream} -import scala.runtime.ScalaRunTime.stringOf - -/** A utility object that's needed by the code that executes a worksheet. - */ -@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0") -object WorksheetSupport { - - /** The offset in the source which should be printed */ - private var currentOffset = 0 - - /** A stream that flushes in regular intervals so that output can be captured - * in real time. The flush interval is determined by the field "flushInterval". - * By default it is 30ms. - */ - private class FlushedOutputStream(out: OutputStream) extends OutputStream { - protected def flushInterval = 30000000L // interval between flushes, by default 30ms - protected def width = 80 // output width, by default 80 characters - protected def tabInc = 8 // tab increment, by default 8 characters - private var lastFlush: Long = 0L - private var col = -1 - override def write(b: Array[Byte], off: Int, len: Int) = { - for (idx <- off until (off + len min b.length)) writeOne(b(idx).toInt) - flush() - } - override def write(c: Int) { - writeOne(c) - flush() - } - override def flush() { - val current = System.nanoTime - if (current - lastFlush >= flushInterval) { - out.flush() - lastFlush = current - } - } - def writeOne(c: Int) { - if (col < 0) { - col = 0 - write((currentOffset+" ").getBytes) - } - out.write(c) - col = - if (c == '\n') -1 - else if (c == '\t') (col / tabInc) * tabInc + tabInc - else col + 1 - if (col >= width) writeOne('\n') - } - def ensureNewLine() = if (col > 0) writeOne('\n') - } - - private val flushedOut = new FlushedOutputStream(System.out) - private val printOut = new PrintStream(flushedOut) - - private def redirected(op: => Unit) = { - val oldSysOut = System.out - val oldSysErr = System.err - val oldConsOut = Console.out - val oldConsErr = Console.err - System.setOut(printOut) - System.setErr(printOut) - Console.setOut(printOut) - Console.setErr(printOut) - try op - finally { - printOut.close() - System.setOut(oldSysOut) - System.setErr(oldSysErr) - Console.setOut(oldConsOut) - Console.setErr(oldConsErr) - } - } - - def $execute(op: => Unit) = redirected { - try op - catch { - case ex: StopException => ; - case ex: Throwable => ex.printStackTrace() - } - } - - def $skip(n: Int) = { - flushedOut.ensureNewLine() - currentOffset += n - } - - def $stop() = throw new StopException - - def $show(x: Any): String = stringOf(x) -} - -class StopException extends Exception diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala index c85664349e..1bfaeb255b 100644 --- a/src/library/scala/util/hashing/MurmurHash3.scala +++ b/src/library/scala/util/hashing/MurmurHash3.scala @@ -275,12 +275,4 @@ object MurmurHash3 extends MurmurHash3 { finalizeHash(h, n) } */ - - @deprecated("Use unorderedHash", "2.10.0") - 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: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int = - orderedHash(xs.seq, seed) } diff --git a/src/reflect/scala/reflect/api/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala index 6fc76c9693..df5e0699a5 100644 --- a/src/reflect/scala/reflect/api/JavaUniverse.scala +++ b/src/reflect/scala/reflect/api/JavaUniverse.scala @@ -34,7 +34,7 @@ trait JavaUniverse extends Universe with JavaMirrors { self => mirror.universe match { case ju: JavaUniverse => val jm = mirror.asInstanceOf[ju.Mirror] - val sym = jm.classSymbol(manifest.erasure) + val sym = jm.classSymbol(manifest.runtimeClass) val tpe = if (manifest.typeArguments.isEmpty) sym.toType else ju.appliedType(sym.toTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe)) diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 563f23cb3b..19f06894c8 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -16,7 +16,7 @@ import scala.reflect.api.{Universe => ApiUniverse} trait Definitions extends api.StandardDefinitions { self: SymbolTable => - import rootMirror.{getModule, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule} + import rootMirror.{getModuleByName, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule} object definitions extends DefinitionsClass @@ -87,7 +87,7 @@ trait Definitions extends api.StandardDefinitions { lazy val abbrvTag = symbolsMap(ScalaValueClasses, nameToTag) withDefaultValue OBJECT_TAG lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight) - lazy val boxedModule = classesMap(x => getModule(boxedName(x))) + lazy val boxedModule = classesMap(x => getModuleByName(boxedName(x))) lazy val boxedClass = classesMap(x => getClassByName(boxedName(x))) lazy val refClass = classesMap(x => getRequiredClass("scala.runtime." + x + "Ref")) lazy val volatileRefClass = classesMap(x => getRequiredClass("scala.runtime.Volatile" + x + "Ref")) @@ -153,18 +153,6 @@ trait Definitions extends api.StandardDefinitions { private var isInitialized = false def isDefinitionsInitialized = isInitialized - @deprecated("Moved to rootMirror.RootPackage", "2.10.0") - val RootPackage: ModuleSymbol = rootMirror.RootPackage - - @deprecated("Moved to rootMirror.RootClass", "2.10.0") - val RootClass: ClassSymbol = rootMirror.RootClass - - @deprecated("Moved to rootMirror.EmptyPackage", "2.10.0") - val EmptyPackage: ModuleSymbol = rootMirror.EmptyPackage - - @deprecated("Moved to rootMirror.EmptyPackageClass", "2.10.0") - val EmptyPackageClass: ClassSymbol = rootMirror.EmptyPackageClass - // It becomes tricky to create dedicated objects for other symbols because // of initialization order issues. lazy val JavaLangPackage = getPackage("java.lang") diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index e122fa498b..3a630b6a16 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -96,10 +96,6 @@ trait Mirrors extends api.Mirrors { } } - @deprecated("Use getClassByName", "2.10.0") - def getClass(fullname: Name): ClassSymbol = - getClassByName(fullname) - def getClassByName(fullname: Name): ClassSymbol = ensureClassSymbol(fullname.toString, getModuleOrClass(fullname.toTypeName)) @@ -131,15 +127,11 @@ trait Mirrors extends api.Mirrors { case _ => MissingRequirementError.notFound("object " + fullname) } - @deprecated("Use getModuleByName", "2.10.0") - def getModule(fullname: Name): ModuleSymbol = - getModuleByName(fullname) - def getModuleByName(fullname: Name): ModuleSymbol = ensureModuleSymbol(fullname.toString, getModuleOrClass(fullname.toTermName), allowPackages = true) def getRequiredModule(fullname: String): ModuleSymbol = - getModule(newTermNameCached(fullname)) + getModuleByName(newTermNameCached(fullname)) // TODO: What syntax do we think should work here? Say you have an object // like scala.Predef. You can't say requiredModule[scala.Predef] since there's @@ -155,7 +147,7 @@ trait Mirrors extends api.Mirrors { getModuleIfDefined(newTermNameCached(fullname)) def getModuleIfDefined(fullname: Name): Symbol = - wrapMissing(getModule(fullname.toTermName)) + wrapMissing(getModuleByName(fullname.toTermName)) /** @inheritdoc * diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index bd17c18119..85bc3158f6 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -452,23 +452,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => case _ => new StubTermSymbol(this, name.toTermName, missingMessage) } - @deprecated("Use the other signature", "2.10.0") - def newClass(pos: Position, name: TypeName): Symbol = newClass(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newModuleClass(pos: Position, name: TypeName): Symbol = newModuleClass(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newLabel(pos: Position, name: TermName): MethodSymbol = newLabel(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newValue(pos: Position, name: TermName): TermSymbol = newTermSymbol(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newAliasType(pos: Position, name: TypeName): Symbol = newAliasType(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newAbstractType(pos: Position, name: TypeName): Symbol = newAbstractType(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newExistential(pos: Position, name: TypeName): Symbol = newExistential(name, pos) - @deprecated("Use the other signature", "2.10.0") - def newMethod(pos: Position, name: TermName): MethodSymbol = newMethod(name, pos) - // ----- locking and unlocking ------------------------------------------------------ // True if the symbol is unlocked. @@ -2047,10 +2030,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => else if (isMethod || isClass) this else owner.logicallyEnclosingMember - /** Kept for source compatibility with 2.9. Scala IDE for Eclipse relies on this. */ - @deprecated("Use enclosingTopLevelClass", "2.10.0") - def toplevelClass: Symbol = enclosingTopLevelClass - /** The top-level class containing this symbol. */ def enclosingTopLevelClass: Symbol = if (isTopLevel) { @@ -2365,9 +2344,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => def associatedFile: AbstractFile = enclosingTopLevelClass.associatedFile def associatedFile_=(f: AbstractFile) { abort("associatedFile_= inapplicable for " + this) } - @deprecated("Use associatedFile_= instead", "2.10.0") - def sourceFile_=(f: AbstractFile): Unit = associatedFile_=(f) - /** If this is a sealed class, its known direct subclasses. * Otherwise, the empty set. */ diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 0d55423247..8fba1e538e 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -9,10 +9,11 @@ package interpreter import PartialFunction.cond import scala.language.implicitConversions +import scala.beans.BeanProperty import scala.collection.mutable import scala.concurrent.{ Future, ExecutionContext } import scala.reflect.runtime.{ universe => ru } -import scala.reflect.{ BeanProperty, ClassTag, classTag } +import scala.reflect.{ ClassTag, classTag } import scala.reflect.internal.util.{ BatchSourceFile, SourceFile } import scala.tools.util.PathResolver import scala.tools.nsc.io.AbstractFile -- cgit v1.2.3