From aced32d05c97651534f468bc9a475ea5f6ae75b8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 27 Sep 2013 12:28:55 -0700 Subject: Removing unused code. Most of this was revealed via -Xlint with a flag which assumes closed world. I can't see how to check the assumes-closed-world code in without it being an ordeal. I'll leave it in a branch in case anyone wants to finish the long slog to the merge. --- .../scala/reflect/macros/compiler/Validators.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 11 +- src/compiler/scala/tools/nsc/PhaseAssembly.scala | 2 +- src/compiler/scala/tools/nsc/Properties.scala | 1 - src/compiler/scala/tools/nsc/ast/DocComments.scala | 14 -- src/compiler/scala/tools/nsc/ast/Printers.scala | 22 --- .../scala/tools/nsc/ast/TreeBrowsers.scala | 15 -- src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 19 +-- src/compiler/scala/tools/nsc/ast/Trees.scala | 3 - .../scala/tools/nsc/ast/parser/Parsers.scala | 11 -- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 2 - .../nsc/ast/parser/xml/MarkupParserCommon.scala | 44 ------ .../scala/tools/nsc/ast/parser/xml/Utility.scala | 13 -- .../scala/tools/nsc/backend/Platform.scala | 4 - .../tools/nsc/backend/icode/BasicBlocks.scala | 4 - .../scala/tools/nsc/backend/icode/ICodes.scala | 1 - .../scala/tools/nsc/backend/icode/Members.scala | 6 - .../scala/tools/nsc/backend/icode/Primitives.scala | 2 - .../tools/nsc/backend/jvm/BCodeBodyBuilder.scala | 15 +- .../scala/tools/nsc/backend/jvm/BCodeGlue.scala | 173 --------------------- .../scala/tools/nsc/backend/jvm/BCodeHelpers.scala | 4 +- .../tools/nsc/backend/jvm/BCodeIdiomatic.scala | 124 +-------------- .../tools/nsc/backend/jvm/BCodeSkelBuilder.scala | 3 - .../tools/nsc/backend/jvm/BCodeSyncAndTry.scala | 4 +- .../scala/tools/nsc/backend/jvm/BCodeTypes.scala | 143 +---------------- .../scala/tools/nsc/backend/opt/Inliners.scala | 12 +- src/compiler/scala/tools/nsc/io/Socket.scala | 7 - .../tools/nsc/reporters/ConsoleReporter.scala | 5 - .../scala/tools/nsc/settings/ScalaSettings.scala | 2 - .../tools/nsc/transform/ExtensionMethods.scala | 1 - .../tools/nsc/transform/patmat/MatchAnalysis.scala | 6 - .../nsc/transform/patmat/MatchOptimization.scala | 2 +- .../nsc/transform/patmat/MatchTranslation.scala | 12 -- .../nsc/transform/patmat/MatchTreeMaking.scala | 1 - .../nsc/transform/patmat/PatternMatching.scala | 5 - .../tools/nsc/typechecker/ContextErrors.scala | 3 - .../scala/tools/nsc/typechecker/Macros.scala | 3 - .../scala/tools/nsc/typechecker/Namers.scala | 7 - .../tools/nsc/typechecker/PatternTypers.scala | 11 -- .../tools/nsc/typechecker/StdAttachments.scala | 9 -- .../tools/nsc/typechecker/SyntheticMethods.scala | 2 +- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 19 +-- .../scala/tools/nsc/typechecker/TypeStrings.scala | 5 - .../tools/nsc/typechecker/TypersTracking.scala | 14 +- src/compiler/scala/tools/nsc/util/ClassPath.scala | 5 +- src/compiler/scala/tools/nsc/util/package.scala | 3 - .../scala/tools/reflect/ToolBoxFactory.scala | 4 +- .../scala/tools/reflect/quasiquotes/Holes.scala | 10 +- .../tools/reflect/quasiquotes/Placeholders.scala | 2 +- .../scala/tools/reflect/quasiquotes/Reifiers.scala | 1 - 50 files changed, 31 insertions(+), 762 deletions(-) (limited to 'src/compiler/scala') diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala index 8d396a56d8..b3e8131e34 100644 --- a/src/compiler/scala/reflect/macros/compiler/Validators.scala +++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala @@ -146,7 +146,7 @@ trait Validators { val ctxPrefix = if (isImplMethod) singleType(NoPrefix, makeParam(nme.macroContext, macroDdef.pos, ctxTpe, SYNTHETIC)) else singleType(ThisType(macroImpl.owner), macroImpl.owner.tpe.member(nme.c)) - var paramss = + val paramss = if (isImplMethod) List(ctxPrefix.termSymbol) :: mmap(macroDdef.vparamss)(param) else mmap(macroDdef.vparamss)(param) val macroDefRet = diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index f3a2d49697..ef9d8a310e 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -14,7 +14,7 @@ import scala.compat.Platform.currentTime import scala.collection.{ mutable, immutable } import io.{ SourceReader, AbstractFile, Path } import reporters.{ Reporter, ConsoleReporter } -import util.{ ClassPath, MergedClassPath, StatisticsInfo, returning, stackTraceString, stackTraceHeadString } +import util.{ ClassPath, MergedClassPath, StatisticsInfo, returning, stackTraceString } import scala.reflect.internal.util.{ OffsetPosition, SourceFile, NoSourceFile, BatchSourceFile, ScriptSourceFile } import scala.reflect.internal.pickling.{ PickleBuffer, PickleFormat } import scala.reflect.io.VirtualFile @@ -1026,14 +1026,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) * Then, fsc -Xexperimental clears the nsc project between successive runs of `fsc`. */ - /** Remove the current run when not needed anymore. Used by the build - * manager to save on the memory foot print. The current run holds on - * to all compilation units, which in turn hold on to trees. - */ - private [nsc] def dropRun() { - curRun = null - } - object typeDeconstruct extends { val global: Global.this.type = Global.this } with typechecker.StructuredTypeStrings @@ -1083,7 +1075,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) @inline final def enteringIcode[T](op: => T): T = enteringPhase(currentRun.icodePhase)(op) @inline final def enteringMixin[T](op: => T): T = enteringPhase(currentRun.mixinPhase)(op) @inline final def enteringPickler[T](op: => T): T = enteringPhase(currentRun.picklerPhase)(op) - @inline final def enteringRefchecks[T](op: => T): T = enteringPhase(currentRun.refchecksPhase)(op) @inline final def enteringSpecialize[T](op: => T): T = enteringPhase(currentRun.specializePhase)(op) @inline final def enteringTyper[T](op: => T): T = enteringPhase(currentRun.typerPhase)(op) @inline final def enteringUncurry[T](op: => T): T = enteringPhase(currentRun.uncurryPhase)(op) diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index 996f6efe55..cfb4cd23a1 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -144,7 +144,7 @@ trait PhaseAssembly { rerun = false hardlinks = edges.filter(_.hard) for (hl <- hardlinks) { - var sanity = Nil ++ hl.to.before.filter(_.hard) + val sanity = Nil ++ hl.to.before.filter(_.hard) if (sanity.length == 0) { throw new FatalError("There is no runs right after dependency, where there should be one! This is not supposed to happen!") } else if (sanity.length > 1) { diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala index feb4ded2f2..ed5fda9c3f 100644 --- a/src/compiler/scala/tools/nsc/Properties.scala +++ b/src/compiler/scala/tools/nsc/Properties.scala @@ -12,7 +12,6 @@ object Properties extends scala.util.PropertiesTrait { protected def pickJarBasedOn = classOf[Global] // settings based on jar properties - def fileEndingString = scalaPropOrElse("file.ending", ".scala|.java") def residentPromptString = scalaPropOrElse("resident.prompt", "\nnsc> ") def shellPromptString = scalaPropOrElse("shell.prompt", "\nscala> ") diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 7cf2f8559b..6d9b41ec45 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -33,11 +33,6 @@ trait DocComments { self: Global => defs.clear() } - /** Associate comment with symbol `sym` at position `pos`. */ - def docComment(sym: Symbol, docStr: String, pos: Position = NoPosition) = - if ((sym ne null) && (sym ne NoSymbol)) - docComments += (sym -> DocComment(docStr, pos)) - /** The raw doc comment of symbol `sym`, as it appears in the source text, "" if missing. */ def rawDocComment(sym: Symbol): String = @@ -99,11 +94,6 @@ trait DocComments { self: Global => expandVariables(cookedDocComment(sym, docStr), sym, site1) } - /** The cooked doc comment of symbol `sym` after variable expansion, or "" if missing. - * @param sym The symbol for which doc comment is returned (site is always the containing class) - */ - def expandedDocComment(sym: Symbol): String = expandedDocComment(sym, sym.enclClass) - /** The list of use cases of doc comment of symbol `sym` seen as a member of class * `site`. Each use case consists of a synthetic symbol (which is entered nowhere else), * of an expanded doc comment string, and of its position. @@ -132,10 +122,6 @@ trait DocComments { self: Global => getDocComment(sym) map getUseCases getOrElse List() } - /** Returns the javadoc format of doc comment string `s`, including wiki expansion - */ - def toJavaDoc(s: String): String = expandWiki(s) - private val wikiReplacements = List( ("""(\n\s*\*?)(\s*\n)""" .r, """$1

$2"""), ("""<([^\w/])""" .r, """<$1"""), diff --git a/src/compiler/scala/tools/nsc/ast/Printers.scala b/src/compiler/scala/tools/nsc/ast/Printers.scala index c31b5e2c0e..c64b18207a 100644 --- a/src/compiler/scala/tools/nsc/ast/Printers.scala +++ b/src/compiler/scala/tools/nsc/ast/Printers.scala @@ -178,28 +178,6 @@ trait Printers extends scala.reflect.internal.Printers { this: Global => } } - /** This must guarantee not to force any evaluation, so we can learn - * a little bit about trees in the midst of compilation without altering - * the natural course of events. - */ - class SafeTreePrinter(out: PrintWriter) extends TreePrinter(out) { - - private def default(t: Tree) = t.getClass.getName.reverse.takeWhile(_ != '.').reverse - private def params(trees: List[Tree]): String = trees map safe mkString ", " - - private def safe(name: Name): String = name.decode - private def safe(tree: Tree): String = tree match { - case Apply(fn, args) => "%s(%s)".format(safe(fn), params(args)) - case Select(qual, name) => safe(qual) + "." + safe(name) - case This(qual) => safe(qual) + ".this" - case Ident(name) => safe(name) - case Literal(value) => value.stringValue - case _ => "(?: %s)".format(default(tree)) - } - - override def printTree(tree: Tree) { print(safe(tree)) } - } - def asString(t: Tree): String = render(t, newStandardTreePrinter, settings.printtypes, settings.uniqid, settings.Yshowsymkinds) def asCompactString(t: Tree): String = render(t, newCompactTreePrinter, settings.printtypes, settings.uniqid, settings.Yshowsymkinds) def asCompactDebugString(t: Tree): String = render(t, newCompactTreePrinter, true, true, true) diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 1e70b7091b..c68b248240 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -49,21 +49,6 @@ abstract class TreeBrowsers { * Java Swing pretty printer for Scala abstract syntax trees. */ class SwingBrowser { - - def browse(t: Tree): Tree = { - val tm = new ASTTreeModel(t) - - val frame = new BrowserFrame() - frame.setTreeModel(tm) - - val lock = new Lock() - frame.createFrame(lock) - - // wait for the frame to be closed - lock.acquire() - t - } - def browse(pName: String, units: Iterator[CompilationUnit]): Unit = browse(pName, units.toList) diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 5922b4bbbf..0020528c5b 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package ast -import PartialFunction._ import symtab.Flags import scala.language.implicitConversions @@ -32,7 +31,6 @@ trait TreeDSL { object LIT extends (Any => Literal) { def typed(x: Any) = apply(x) setType ConstantType(Constant(x)) def apply(x: Any) = Literal(Constant(x)) - def unapply(x: Any) = condOpt(x) { case Literal(Constant(value)) => value } } // Boring, predictable trees. @@ -42,12 +40,6 @@ trait TreeDSL { def NULL = LIT(null) def UNIT = LIT(()) - object WILD { - def empty = Ident(nme.WILDCARD) - def apply(tpe: Type) = Ident(nme.WILDCARD) setType tpe - def unapply(other: Any) = cond(other) { case Ident(nme.WILDCARD) => true } - } - def fn(lhs: Tree, op: Name, args: Tree*) = Apply(Select(lhs, op), args.toList) def fn(lhs: Tree, op: Symbol, args: Tree*) = Apply(Select(lhs, op), args.toList) @@ -77,7 +69,6 @@ trait TreeDSL { def ANY_EQ (other: Tree) = OBJ_EQ(other AS ObjectTpe) def ANY_== (other: Tree) = fn(target, Any_==, other) def ANY_!= (other: Tree) = fn(target, Any_!=, other) - def OBJ_!= (other: Tree) = fn(target, Object_!=, other) def OBJ_EQ (other: Tree) = fn(target, Object_eq, other) def OBJ_NE (other: Tree) = fn(target, Object_ne, other) @@ -94,7 +85,6 @@ trait TreeDSL { /** Apply, Select, Match **/ def APPLY(params: Tree*) = Apply(target, params.toList) def APPLY(params: List[Tree]) = Apply(target, params) - def MATCH(cases: CaseDef*) = Match(target, cases.toList) def DOT(member: Name) = SelectStart(Select(target, member)) def DOT(sym: Symbol) = SelectStart(Select(target, sym)) @@ -106,21 +96,14 @@ trait TreeDSL { // clear how to proceed, so for now it retains the non-duplicating behavior. def ===(rhs: Tree) = Assign(target, rhs) - /** Methods for sequences **/ - def DROP(count: Int): Tree = - if (count == 0) target - else (target DOT nme.drop)(LIT(count)) - /** Casting & type tests -- working our way toward understanding exactly * what differs between the different forms of IS and AS. * * See ticket #2168 for one illustration of AS vs. AS_ANY. */ def AS(tpe: Type) = gen.mkAsInstanceOf(target, tpe, any = true, wrapInApply = false) - def IS(tpe: Type) = gen.mkIsInstanceOf(target, tpe, any = true) def IS_OBJ(tpe: Type) = gen.mkIsInstanceOf(target, tpe, any = false) - def TOSTRING() = fn(target, nme.toString_) def GETCLASS() = fn(target, Object_getClass) } @@ -144,7 +127,7 @@ trait TreeDSL { } def CASE(pat: Tree): CaseStart = new CaseStart(pat, EmptyTree) - def DEFAULT: CaseStart = new CaseStart(WILD.empty, EmptyTree) + def DEFAULT: CaseStart = new CaseStart(Ident(nme.WILDCARD), EmptyTree) def NEW(tpt: Tree, args: Tree*): Tree = New(tpt, List(args.toList)) diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index bdff5e1344..cccae0c3a0 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -80,8 +80,6 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => val global: Trees.this.type = self } with TreeInfo - lazy val treePrinter = newTreePrinter() - // --- additional cases in operations ---------------------------------- override protected def xtraverse(traverser: Traverser, tree: Tree): Unit = tree match { @@ -185,7 +183,6 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => def resetAllAttrs(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(false, leaveAlone).transform(x) def resetLocalAttrs(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(true, leaveAlone).transform(x) - def resetLocalAttrsKeepLabels(x: Tree, leaveAlone: Tree => Boolean = null): Tree = new ResetAttrs(true, leaveAlone, true).transform(x) /** A transformer which resets symbol and tpe fields of all nodes in a given tree, * with special treatment of: diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index d75e39ae00..34f3fcce9f 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -649,10 +649,6 @@ self => } def isDefIntro = isTemplateIntro || isDclIntro - def isTopLevelIntro = in.token match { - case PACKAGE | IMPORT | AT => true - case _ => isTemplateIntro || isModifier - } def isNumericLit: Boolean = in.token match { case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => true @@ -2995,13 +2991,6 @@ self => stats.toList } - /** Informal - for the repl and other direct parser accessors. - */ - def templateStatsCompat(): List[Tree] = templateStats() match { - case Nil => EmptyTree.asList - case stats => stats - } - /** {{{ * RefineStatSeq ::= RefineStat {semi RefineStat} * RefineStat ::= Dcl diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 2d38848f90..59abf99844 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -31,8 +31,6 @@ abstract class TreeBuilder { def scalaDot(name: Name) = gen.scalaDot(name) def scalaAnyRefConstr = scalaDot(tpnme.AnyRef) def scalaUnitConstr = scalaDot(tpnme.Unit) - def productConstr = scalaDot(tpnme.Product) - def serializableConstr = scalaDot(tpnme.Serializable) def convertToTypeName(t: Tree) = gen.convertToTypeName(t) diff --git a/src/compiler/scala/tools/nsc/ast/parser/xml/MarkupParserCommon.scala b/src/compiler/scala/tools/nsc/ast/parser/xml/MarkupParserCommon.scala index f6cfb64ed8..82dce9f1f8 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/xml/MarkupParserCommon.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/xml/MarkupParserCommon.scala @@ -18,8 +18,6 @@ private[scala] trait MarkupParserCommon { protected def unreachable = scala.sys.error("Cannot be reached.") - // type HandleType // MarkupHandler, SymbolicXMLBuilder - type InputType // Source, CharArrayReader type PositionType // Int, Position type ElementType // NodeSeq, Tree type NamespaceType // NamespaceBinding, Any @@ -65,21 +63,6 @@ private[scala] trait MarkupParserCommon { buf.toString } - def xAttributeValue(): String = { - val str = xAttributeValue(ch_returning_nextch) - // well-formedness constraint - normalizeAttributeValue(str) - } - - private def takeUntilChar(it: Iterator[Char], end: Char): String = { - val buf = new StringBuilder - while (it.hasNext) it.next() match { - case `end` => return buf.toString - case ch => buf append ch - } - scala.sys.error("Expected '%s'".format(end)) - } - /** [42] '<' xmlEndTag ::= '<' '/' Name S? '>' */ def xEndTag(startName: String) { @@ -117,33 +100,6 @@ private[scala] trait MarkupParserCommon { else buf.toString } - private def attr_unescape(s: String) = s match { - case "lt" => "<" - case "gt" => ">" - case "amp" => "&" - case "apos" => "'" - case "quot" => "\"" - case "quote" => "\"" - case _ => "&" + s + ";" - } - - /** Replaces only character references right now. - * see spec 3.3.3 - */ - private def normalizeAttributeValue(attval: String): String = { - val buf = new StringBuilder - val it = attval.iterator.buffered - - while (it.hasNext) buf append (it.next() match { - case ' ' | '\t' | '\n' | '\r' => " " - case '&' if it.head == '#' => it.next() ; xCharRef(it) - case '&' => attr_unescape(takeUntilChar(it, ';')) - case c => c - }) - - buf.toString - } - /** CharRef ::= "&#" '0'..'9' {'0'..'9'} ";" * | "&#x" '0'..'9'|'A'..'F'|'a'..'f' { hexdigit } ";" * diff --git a/src/compiler/scala/tools/nsc/ast/parser/xml/Utility.scala b/src/compiler/scala/tools/nsc/ast/parser/xml/Utility.scala index 39e4831af2..6dcfa173df 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/xml/Utility.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/xml/Utility.scala @@ -122,10 +122,6 @@ object Utility { case '\u0009' | '\u000A' | '\u000D' | '\u0020' => true case _ => false } - /** {{{ - * (#x20 | #x9 | #xD | #xA)+ - * }}} */ - final def isSpace(cs: Seq[Char]): Boolean = cs.nonEmpty && (cs forall isSpace) /** {{{ * NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' @@ -164,13 +160,4 @@ object Utility { case _ => ch == '_' } } - - /** {{{ - * Name ::= ( Letter | '_' ) (NameChar)* - * }}} - * See [5] of XML 1.0 specification. - */ - def isName(s: String) = - s.nonEmpty && isNameStart(s.head) && (s.tail forall isNameChar) - } diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala index 3bca16635b..499f8a9290 100644 --- a/src/compiler/scala/tools/nsc/backend/Platform.scala +++ b/src/compiler/scala/tools/nsc/backend/Platform.scala @@ -15,10 +15,6 @@ trait Platform { val symbolTable: symtab.SymbolTable import symbolTable._ - /** The binary classfile representation type */ - @deprecated("BinaryRepr is not an abstract type anymore. It's an alias that points at AbstractFile. It'll be removed before Scala 2.11 is released.", "2.11.0-M5") - type BinaryRepr = AbstractFile - /** The compiler classpath. */ def classPath: ClassPath[AbstractFile] diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 26d10d2514..f9551697d2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -452,10 +452,6 @@ trait BasicBlocks { if (closed) instrs(instrs.length - 1) else instructionList.head - def firstInstruction = - if (closed) instrs(0) - else instructionList.last - def exceptionSuccessors: List[BasicBlock] = exceptionSuccessorsForBlock(this) diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala index b9eb8f8aac..bc35a9e7de 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala @@ -105,7 +105,6 @@ abstract class ICodes extends AnyRef lazy val NullReference: TypeKind = REFERENCE(definitions.NullClass) lazy val ObjectReference: TypeKind = REFERENCE(definitions.ObjectClass) lazy val StringReference: TypeKind = REFERENCE(definitions.StringClass) - lazy val ThrowableReference: TypeKind = REFERENCE(definitions.ThrowableClass) object icodeReader extends ICodeReader { lazy val global: ICodes.this.global.type = ICodes.this.global diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 91bd39232e..4d1d59cd12 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -282,12 +282,6 @@ trait Members { class Local(val sym: Symbol, val kind: TypeKind, val arg: Boolean) { var index: Int = -1 - /** Starting PC for this local's visibility range. */ - var start: Int = _ - - /** PC-based ranges for this local variable's visibility */ - var ranges: List[(Int, Int)] = Nil - override def equals(other: Any): Boolean = other match { case x: Local => sym == x.sym case _ => false diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index 4fa717309e..f81c42d836 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -80,8 +80,6 @@ trait Primitives { self: ICodes => out.print(s) this } - - def print(o: AnyRef): PrimitivePrinter = print(o.toString()) } /** This class represents a comparison operation. */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala index 817546b0f1..3bacc26a3a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala @@ -43,8 +43,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { /* ---------------- helper utils for generating methods and code ---------------- */ def emit(opc: Int) { mnode.visitInsn(opc) } - def emit(i: asm.tree.AbstractInsnNode) { mnode.instructions.add(i) } - def emit(is: List[asm.tree.AbstractInsnNode]) { for(i <- is) { mnode.instructions.add(i) } } def emitZeroOf(tk: BType) { (tk.sort: @switch) match { @@ -411,7 +409,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { /* * must-single-thread */ - private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol = null) { + private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol) { // LOAD_FIELD.hostClass , CALL_METHOD.hostClass , and #4283 val owner = if (hostClass == null) internalName(field.owner) @@ -950,13 +948,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { || sym.isJavaDefined && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass) ) - def isAccessibleFrom(target: Symbol, site: Symbol): Boolean = { - target.isPublic || target.isProtected && { - (site.enclClass isSubClass target.enclClass) || - (site.enclosingPackage == target.privateWithin) - } - } - // whether to reference the type of the receiver or // the type of the method owner val useMethodOwner = ( @@ -1233,10 +1224,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } } - /* can-multi-thread */ - def getMaxType(ts: List[Type]): BType = { - ts map toTypeKind reduceLeft maxType - } def genSynchronized(tree: Apply, expectedType: BType): BType def genLoadTry(tree: Try): BType diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala index f95ceef678..9dcf263f4f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala @@ -118,16 +118,6 @@ abstract class BCodeGlue extends SubComponent { new BType(sort, index, length) } - /* - * @param typeDescriptor a field or method type descriptor. - * - * must-single-thread - */ - def getType(typeDescriptor: String): BType = { - val n = global.newTypeName(typeDescriptor) - getType(n.start) - } - /* * @param methodDescriptor a method descriptor. * @@ -176,20 +166,6 @@ abstract class BCodeGlue extends SubComponent { args } - /* - * Returns the Java types corresponding to the argument types of the given - * method descriptor. - * - * @param methodDescriptor a method descriptor. - * @return the Java types corresponding to the argument types of the given method descriptor. - * - * must-single-thread - */ - def getArgumentTypes(methodDescriptor: String): Array[BType] = { - val n = global.newTypeName(methodDescriptor) - getArgumentTypes(n.start + 1) - } - /* * Returns the number of argument types of this method type, whose first argument starts at idx0. * @@ -348,19 +324,6 @@ abstract class BCodeGlue extends SubComponent { new String(chrs, off, len) } - /* - * @return the prefix of the internal name until the last '/' (if '/' present), empty string otherwise. - * - * can-multi-thread - */ - def getRuntimePackage: String = { - assert(hasObjectSort, s"not of object sort: $toString") - val iname = getInternalName - val idx = iname.lastIndexOf('/') - if (idx == -1) "" - else iname.substring(0, idx) - } - /* * @return the suffix of the internal name until the last '/' (if '/' present), internal name otherwise. * @@ -386,18 +349,6 @@ abstract class BCodeGlue extends SubComponent { BType.getArgumentTypes(off + 1) } - /* - * Returns the number of arguments of methods of this type. - * This method should only be used for method types. - * - * @return the number of arguments of methods of this type. - * - * can-multi-thread - */ - def getArgumentCount: Int = { - BType.getArgumentCount(off + 1) - } - /* * Returns the return type of methods of this type. * This method should only be used for method types. @@ -413,38 +364,6 @@ abstract class BCodeGlue extends SubComponent { BType.getType(resPos + 1) } - /* - * Given a zero-based formal-param-position, return its corresponding local-var-index, - * taking into account the JVM-type-sizes of preceding formal params. - */ - def convertFormalParamPosToLocalVarIdx(paramPos: Int, isInstanceMethod: Boolean): Int = { - assert(sort == asm.Type.METHOD) - val paramTypes = getArgumentTypes - var local = 0 - (0 until paramPos) foreach { argPos => local += paramTypes(argPos).getSize } - - local + (if (isInstanceMethod) 1 else 0) - } - - /* - * Given a local-var-index, return its corresponding zero-based formal-param-position, - * taking into account the JVM-type-sizes of preceding formal params. - */ - def convertLocalVarIdxToFormalParamPos(localIdx: Int, isInstanceMethod: Boolean): Int = { - assert(sort == asm.Type.METHOD) - val paramTypes = getArgumentTypes - var remaining = (if (isInstanceMethod) (localIdx - 1) else localIdx) - assert(remaining >= 0) - var result = 0 - while (remaining > 0) { - remaining -= paramTypes(result).getSize - result += 1 - } - assert(remaining == 0) - - result - } - // ------------------------------------------------------------------------ // Inspector methods // ------------------------------------------------------------------------ @@ -521,14 +440,6 @@ abstract class BCodeGlue extends SubComponent { */ def isWideType = (getSize == 2) - def isCapturedCellRef: Boolean = { - this == srBooleanRef || this == srByteRef || - this == srCharRef || - this == srIntRef || - this == srLongRef || - this == srFloatRef || this == srDoubleRef - } - /* * Element vs. Component type of an array: * Quoting from the JVMS, Sec. 2.4 "Reference Types and Values" @@ -750,14 +661,6 @@ abstract class BCodeGlue extends SubComponent { val CT_NOTHING = brefType("scala/Nothing") // TODO needed? val CT_NULL = brefType("scala/Null") // TODO needed? - val srBooleanRef = brefType("scala/runtime/BooleanRef") - val srByteRef = brefType("scala/runtime/ByteRef") - val srCharRef = brefType("scala/runtime/CharRef") - val srIntRef = brefType("scala/runtime/IntRef") - val srLongRef = brefType("scala/runtime/LongRef") - val srFloatRef = brefType("scala/runtime/FloatRef") - val srDoubleRef = brefType("scala/runtime/DoubleRef") - /* Map from type kinds to the Java reference types. * Useful when pushing class literals onto the operand stack (ldc instruction taking a class literal). * @see Predef.classOf @@ -802,80 +705,4 @@ abstract class BCodeGlue extends SubComponent { DOUBLE -> MethodNameAndType("unboxToDouble", "(Ljava/lang/Object;)D") ) } - - /* - * can-multi-thread - */ - def toBType(t: asm.Type): BType = { - (t.getSort: @switch) match { - case asm.Type.VOID => BType.VOID_TYPE - case asm.Type.BOOLEAN => BType.BOOLEAN_TYPE - case asm.Type.CHAR => BType.CHAR_TYPE - case asm.Type.BYTE => BType.BYTE_TYPE - case asm.Type.SHORT => BType.SHORT_TYPE - case asm.Type.INT => BType.INT_TYPE - case asm.Type.FLOAT => BType.FLOAT_TYPE - case asm.Type.LONG => BType.LONG_TYPE - case asm.Type.DOUBLE => BType.DOUBLE_TYPE - case asm.Type.ARRAY | - asm.Type.OBJECT | - asm.Type.METHOD => - // TODO confirm whether this also takes care of the phantom types. - val key = - if (t.getSort == asm.Type.METHOD) t.getDescriptor - else t.getInternalName - - val n = global.lookupTypeName(key.toCharArray) - new BType(t.getSort, n.start, n.length) - } - } - - /* - * ASM trees represent types as strings (internal names, descriptors). - * Given that we operate instead on BTypes, conversion is needed when visiting MethodNodes outside GenBCode. - * - * can-multi-thread - */ - def descrToBType(typeDescriptor: String): BType = { - val c: Char = typeDescriptor(0) - c match { - case 'V' => BType.VOID_TYPE - case 'Z' => BType.BOOLEAN_TYPE - case 'C' => BType.CHAR_TYPE - case 'B' => BType.BYTE_TYPE - case 'S' => BType.SHORT_TYPE - case 'I' => BType.INT_TYPE - case 'F' => BType.FLOAT_TYPE - case 'J' => BType.LONG_TYPE - case 'D' => BType.DOUBLE_TYPE - case 'L' => - val iname = typeDescriptor.substring(1, typeDescriptor.length() - 1) - val n = global.lookupTypeName(iname.toCharArray) - new BType(asm.Type.OBJECT, n.start, n.length) - case _ => - val n = global.lookupTypeName(typeDescriptor.toCharArray) - BType.getType(n.start) - } - } - - /* - * Use only to lookup reference types, otherwise use `descrToBType()` - * - * can-multi-thread - */ - def lookupRefBType(iname: String): BType = { - import global.chrs - val n = global.lookupTypeName(iname.toCharArray) - val sort = if (chrs(n.start) == '[') BType.ARRAY else BType.OBJECT; - new BType(sort, n.start, n.length) - } - - def lookupRefBTypeIfExisting(iname: String): BType = { - import global.chrs - val n = global.lookupTypeNameIfExisting(iname.toCharArray, false) - if (n == null) { return null } - val sort = if (chrs(n.start) == '[') BType.ARRAY else BType.OBJECT; - new BType(sort, n.start, n.length) - } - } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index eff7d3211e..c22ced26a5 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -561,9 +561,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { memberCTK } - - exemplar(csym).directMemberClasses = (result ::: lateClosuresBTs) - + exemplar(csym) // side effect city result } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala index eda17c6e32..529295389c 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala @@ -46,7 +46,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { val ObjectReference = brefType("java/lang/Object") val AnyRefReference = ObjectReference - val objArrayReference = arrayOf(ObjectReference) val JAVA_LANG_OBJECT = ObjectReference val JAVA_LANG_STRING = brefType("java/lang/String") @@ -73,11 +72,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { if (xs.isEmpty) { return EMPTY_LABEL_ARRAY } val a = new Array[asm.Label](xs.size); xs.copyToArray(a); a } - /* can-multi-thread */ - final def mkArray(xs: List[Int]): Array[Int] = { - if (xs.isEmpty) { return EMPTY_INT_ARRAY } - val a = new Array[Int](xs.size); xs.copyToArray(a); a - } /* * can-multi-thread @@ -113,23 +107,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { a } - /* - * can-multi-thread - */ - final def mkArrayReverse(xs: List[asm.Label]): Array[asm.Label] = { - val len = xs.size - if (len == 0) { return EMPTY_LABEL_ARRAY } - val a = new Array[asm.Label](len) - var i = len - 1 - var rest = xs - while (!rest.isEmpty) { - a(i) = rest.head - rest = rest.tail - i -= 1 - } - a - } - /* * The type of 1-dimensional arrays of `elem` type. * The invoker is responsible for tracking (if needed) the inner class given by the elem BType. @@ -141,20 +118,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { brefType("[" + elem.getDescriptor) } - /* - * The type of N-dimensional arrays of `elem` type. - * The invoker is responsible for tracking (if needed) the inner class given by the elem BType. - * - * must-single-thread - */ - final def arrayN(elem: BType, dims: Int): BType = { - assert(dims > 0) - assert(!(elem.isUnitType) && !(elem.isPhantomType), - "The element type of an array type is necessarily either a primitive type, or a class type, or an interface type.") - val desc = ("[" * dims) + elem.getDescriptor - brefType(desc) - } - /* Just a namespace for utilities that encapsulate MethodVisitor idioms. * In the ASM world, org.objectweb.asm.commons.InstructionAdapter plays a similar role, * but the methods here allow choosing when to transition from ICode to ASM types @@ -165,7 +128,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { def jmethod: asm.MethodVisitor import asm.Opcodes; - import icodes.opcodes.{ InvokeStyle, Static, Dynamic, SuperCall } + import icodes.opcodes.{ Static, Dynamic, SuperCall } final def emit(opc: Int) { jmethod.visitInsn(opc) } @@ -259,23 +222,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // end of method genPrimitiveShift() - /* - * can-multi-thread - */ - final def genPrimitiveComparison(op: icodes.ComparisonOp, kind: BType) { - - import icodes.{ CMPL, CMP, CMPG } - - ((op, kind): @unchecked) match { - case (CMP, LONG) => emit(Opcodes.LCMP) - case (CMPL, FLOAT) => emit(Opcodes.FCMPL) - case (CMPG, FLOAT) => emit(Opcodes.FCMPG) - case (CMPL, DOUBLE) => emit(Opcodes.DCMPL) - case (CMPG, DOUBLE) => emit(Opcodes.DCMPL) // http://docs.oracle.com/javase/specs/jvms/se5.0/html/Instructions2.doc3.html - } - - } // end of method genPrimitiveComparison() - /* * can-multi-thread */ @@ -378,12 +324,6 @@ abstract class BCodeIdiomatic extends BCodeGlue { } } // end of emitT2T() - // can-multi-thread - final def aconst(cst: AnyRef) { - if (cst == null) { emit(Opcodes.ACONST_NULL) } - else { jmethod.visitLdcInsn(cst) } - } - // can-multi-thread final def boolconst(b: Boolean) { iconst(if (b) 1 else 0) } @@ -768,22 +708,8 @@ abstract class BCodeIdiomatic extends BCodeGlue { } } - implicit class MethodIterClassNode(cnode: asm.tree.ClassNode) { - - @inline final def foreachMethod(f: (asm.tree.MethodNode) => Unit) { toMethodList.foreach(f) } - - @inline final def toMethodList: List[asm.tree.MethodNode] = { JListWrapper(cnode.methods).toList } - - @inline final def toFieldList: List[asm.tree.FieldNode] = { JListWrapper(cnode.fields).toList } - - } - implicit class InsnIterMethodNode(mnode: asm.tree.MethodNode) { - @inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit) { mnode.instructions.foreachInsn(f) } - - @inline final def toList: List[asm.tree.AbstractInsnNode] = { mnode.instructions.toList } - } implicit class InsnIterInsnList(lst: asm.tree.InsnList) { @@ -794,51 +720,5 @@ abstract class BCodeIdiomatic extends BCodeGlue { f(insnIter.next()) } } - - @inline final def toList: List[asm.tree.AbstractInsnNode] = { - var result: List[asm.tree.AbstractInsnNode] = Nil - lst foreachInsn { insn => if (insn != null) { result ::= insn } } - result.reverse - } - - } - - /* - * Upon finding a name already seen among previous List elements, adds a numeric postfix to make it unique. - */ - def uniquify(names: List[String]): List[String] = { - val seen = mutable.Set.empty[String] - - @scala.annotation.tailrec def uniquified(current: String, attempt: Int): String = { - if (seen contains current) { - val currentBis = (current + "$" + attempt.toString) - if (seen contains currentBis) { - uniquified(current, attempt + 1) - } else currentBis - } else current - } - - var rest = names - var result: List[String] = Nil - while (rest.nonEmpty) { - val u = uniquified(rest.head.trim, 1) - seen += u - result ::= u - rest = rest.tail - } - - result.reverse } - - def allDifferent[ElemType](xs: Iterable[ElemType]): Boolean = { - val seen = mutable.Set.empty[ElemType] - val iter = xs.iterator - while (iter.hasNext) { - val nxt = iter.next() - if (seen contains nxt) { return false } - seen += nxt - } - true - } - -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala index 8b6b4ab9ce..5fe03624cf 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala @@ -23,7 +23,6 @@ import scala.tools.asm */ abstract class BCodeSkelBuilder extends BCodeHelpers { import global._ - import definitions._ /* * There's a dedicated PlainClassBuilder for each CompilationUnit, @@ -270,7 +269,6 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { var mnode: asm.tree.MethodNode = null var jMethodName: String = null var isMethSymStaticCtor = false - var isMethSymBridge = false var returnType: BType = null var methSymbol: Symbol = null // in GenASM this is local to genCode(), ie should get false whenever a new method is emitted (including fabricated ones eg addStaticInit()) @@ -553,7 +551,6 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { jMethodName = methSymbol.javaSimpleName.toString returnType = asmMethodType(dd.symbol).getReturnType isMethSymStaticCtor = methSymbol.isStaticConstructor - isMethSymBridge = methSymbol.isBridge resetMethodBookkeeping(dd) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala index 439be77b31..27bcbb82d4 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala @@ -386,9 +386,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder { /* Does this tree have a try-catch block? */ def mayCleanStack(tree: Tree): Boolean = tree exists { t => t.isInstanceOf[Try] } - abstract class Cleanup(val value: AnyRef) { - def contains(x: AnyRef) = value == x - } + abstract class Cleanup(val value: AnyRef) { } case class MonitorRelease(v: Symbol) extends Cleanup(v) { } case class Finalizer(f: Tree) extends Cleanup (f) { } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala index 542a90fa85..39fea9a486 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala @@ -24,19 +24,13 @@ abstract class BCodeTypes extends BCodeIdiomatic { // when compiling the Scala library, some assertions don't hold (e.g., scala.Boolean has null superClass although it's not an interface) val isCompilingStdLib = !(settings.sourcepath.isDefault) - val srBoxedUnit = brefType("scala/runtime/BoxedUnit") - // special names var StringReference : BType = null var ThrowableReference : BType = null var jlCloneableReference : BType = null // java/lang/Cloneable - var jlNPEReference : BType = null // java/lang/NullPointerException var jioSerializableReference : BType = null // java/io/Serializable - var scalaSerializableReference : BType = null // scala/Serializable var classCastExceptionReference : BType = null // java/lang/ClassCastException - var lateClosureInterfaces: Array[Tracked] = null // the only interface a Late-Closure-Class implements is scala.Serializable - /* A map from scala primitive type-symbols to BTypes */ var primitiveTypeMap: Map[Symbol, BType] = null /* A map from scala type-symbols for Nothing and Null to (runtime version) BTypes */ @@ -52,15 +46,12 @@ abstract class BCodeTypes extends BCodeIdiomatic { var AndroidParcelableInterface: Symbol = null var AndroidCreatorClass : Symbol = null // this is an inner class, use asmType() to get hold of its BType while tracking in innerClassBufferASM - var androidCreatorType : BType = null var BeanInfoAttr: Symbol = null /* The Object => String overload. */ var String_valueOf: Symbol = null - var ArrayInterfaces: Set[Tracked] = null - // scala.FunctionX and scala.runtim.AbstractFunctionX val FunctionReference = new Array[Tracked](definitions.MaxFunctionArity + 1) val AbstractFunctionReference = new Array[Tracked](definitions.MaxFunctionArity + 1) @@ -75,7 +66,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { * must-single-thread */ def initBCodeTypes() { - import definitions._ primitiveTypeMap = @@ -138,19 +128,17 @@ abstract class BCodeTypes extends BCodeIdiomatic { ) } - ArrayInterfaces = Set(JavaCloneableClass, JavaSerializableClass) map exemplar + exemplar(JavaCloneableClass).c + exemplar(JavaSerializableClass).c + exemplar(SerializableClass).c StringReference = exemplar(StringClass).c StringBuilderReference = exemplar(StringBuilderClass).c ThrowableReference = exemplar(ThrowableClass).c jlCloneableReference = exemplar(JavaCloneableClass).c - jlNPEReference = exemplar(NullPointerExceptionClass).c jioSerializableReference = exemplar(JavaSerializableClass).c - scalaSerializableReference = exemplar(SerializableClass).c classCastExceptionReference = exemplar(ClassCastExceptionClass).c - lateClosureInterfaces = Array(exemplar(SerializableClass)) - /* * The bytecode emitter special-cases String concatenation, in that three methods of `JCodeMethodN` * ( `genStartConcat()` , `genStringConcat()` , and `genEndConcat()` ) @@ -215,23 +203,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { * All methods of this class can-multi-thread */ case class Tracked(c: BType, flags: Int, sc: Tracked, ifaces: Array[Tracked], innersChain: Array[InnerClassEntry]) { - - // not a case-field because we initialize it only for JVM classes we emit. - private var _directMemberClasses: List[BType] = null - - def directMemberClasses: List[BType] = { - assert(_directMemberClasses != null, s"getter directMemberClasses() invoked too early for $c") - _directMemberClasses - } - - def directMemberClasses_=(bs: List[BType]) { - if (_directMemberClasses != null) { - // TODO we enter here when both mirror class and plain class are emitted for the same ModuleClassSymbol. - assert(_directMemberClasses == bs.sortBy(_.off)) - } - _directMemberClasses = bs.sortBy(_.off) - } - /* `isCompilingStdLib` saves the day when compiling: * (1) scala.Nothing (the test `c.isNonSpecial` fails for it) * (2) scala.Boolean (it has null superClass and is not an interface) @@ -246,23 +217,13 @@ abstract class BCodeTypes extends BCodeIdiomatic { import asm.Opcodes._ def hasFlags(mask: Int) = (flags & mask) != 0 - def isPrivate = hasFlags(ACC_PRIVATE) - def isPublic = hasFlags(ACC_PUBLIC) - def isAbstract = hasFlags(ACC_ABSTRACT) def isInterface = hasFlags(ACC_INTERFACE) def isFinal = hasFlags(ACC_FINAL) - def isSynthetic = hasFlags(ACC_SYNTHETIC) - def isSuper = hasFlags(ACC_SUPER) - def isDeprecated = hasFlags(ACC_DEPRECATED) def isInnerClass = { innersChain != null } - def isTraditionalClosureClass = { - isInnerClass && isFinal && (c.getSimpleName.contains(tpnme.ANON_FUN_NAME.toString)) && isFunctionType(c) - } def isLambda = { // ie isLCC || isTraditionalClosureClass isFinal && (c.getSimpleName.contains(tpnme.ANON_FUN_NAME.toString)) && isFunctionType(c) } - def isSerializable = { isSubtypeOf(jioSerializableReference) } /* can-multi-thread */ def superClasses: List[Tracked] = { @@ -370,16 +331,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { minimizeInterfaces(superInterfaces) } - final def exemplarIfExisting(iname: String): Tracked = { - val bt = lookupRefBTypeIfExisting(iname) - if (bt != null) exemplars.get(bt) - else null - } - - final def lookupExemplar(iname: String) = { - exemplars.get(lookupRefBType(iname)) - } - /* * Records the superClass and supportedInterfaces relations, * so that afterwards queries can be answered without resorting to typer. @@ -419,10 +370,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { tr } - val EMPTY_TRACKED_SET = Set.empty[Tracked] - val EMPTY_TRACKED_ARRAY = Array.empty[Tracked] - val EMPTY_InnerClassEntry_ARRAY = Array.empty[InnerClassEntry] /* * must-single-thread @@ -461,12 +409,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { Tracked(key, flags, tsc, ifacesArr, innersChain) } - /* can-multi-thread */ - final def mkArray(xs: List[Tracked]): Array[Tracked] = { - if (xs.isEmpty) { return EMPTY_TRACKED_ARRAY } - val a = new Array[Tracked](xs.size); xs.copyToArray(a); a - } - // ---------------- utilities around interfaces represented by Tracked instances. ---------------- /* Drop redundant interfaces (those which are implemented by some other). @@ -496,21 +438,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { assert(allInterfaces(ifaces), s"Non-interfaces: ${nonInterfaces(ifaces).mkString}") } - /* - * Returns the intersection of two sets of interfaces. - */ - def intersection(ifacesA: Set[Tracked], ifacesB: Set[Tracked]): Set[Tracked] = { - var acc: Set[Tracked] = Set() - for(ia <- ifacesA; ib <- ifacesB) { - val ab = ia.supportedBranches(ib) - val ba = ib.supportedBranches(ia) - acc = minimizeInterfaces(acc ++ ab ++ ba) - } - checkAllInterfaces(acc) - - acc - } - /* * Subtype check `a <:< b` on BTypes that takes into account the JVM built-in numeric promotions (e.g. BYTE to INT). * Its operation can be visualized more easily in terms of the Java bytecode type hierarchy. @@ -649,27 +576,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { } } - /* - * Whether the argument (the signature of a method) takes as argument - * one ore more Function or PartialFunction (in particular an anonymous closure). - * - * can-multi-thread - */ - final def isHigherOrderMethod(mtype: BType): Boolean = { - assert(mtype.sort == BType.METHOD) - - val ats = mtype.getArgumentTypes - var idx = 0 - while (idx < ats.length) { - val t = ats(idx) - if (isFunctionType(t) || isPartialFunctionType(t)) { - return true - } - idx += 1 - } - false - } - /* * Whether the argument is a subtype of * scala.PartialFunction[-A, +B] extends (A => B) @@ -681,16 +587,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { (t.hasObjectSort) && exemplars.get(t).isSubtypeOf(PartialFunctionReference) } - /* - * Whether the argument is a subtype of - * scala.runtime.AbstractPartialFunction[-T1, +R] extends Function1[T1, R] with PartialFunction[T1, R] - * - * can-multi-thread - */ - def isAbstractPartialFunctionType(t: BType): Boolean = { - (t.hasObjectSort) && exemplars.get(t).isSubtypeOf(AbstractPartialFunctionReference) - } - /* * Whether the argument is a subtype of scala.FunctionX where 0 <= X <= definitions.MaxFunctionArity * @@ -709,39 +605,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { false } - def isClosureClass(bt: BType): Boolean = { - val tr = exemplars.get(bt); (tr != null && tr.isLambda) - } - - /* - * Whether the argument is a subtype of scala.runtime.AbstractFunctionX where 0 <= X <= definitions.MaxFunctionArity - * - * can-multi-thread - */ - def isAbstractFunctionType(t: BType): Boolean = { - if (!t.hasObjectSort) return false - var idx = 0 - val et: Tracked = exemplars.get(t) - while (idx <= definitions.MaxFunctionArity) { - if (et.isSubtypeOf(AbstractFunctionReference(idx).c)) { - return true - } - idx += 1 - } - false - } - - /* - * For an argument of exactly one of the types - * scala.runtime.AbstractFunctionX where 0 <= X <= definitions.MaxFunctionArity - * returns the function arity, -1 otherwise. - * - * can-multi-thread - */ - def abstractFunctionArity(t: BType): Int = { - abstractFunctionArityMap.getOrElse(t, -1) - } - /* * must-single-thread */ diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 181f4bde4e..fa424584b2 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -443,7 +443,6 @@ abstract class Inliners extends SubComponent { 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") @@ -738,16 +737,11 @@ abstract class Inliners extends SubComponent { * - either log the reason for failure --- case (b) ---, * - or perform inlining --- case (a) ---. */ - sealed abstract class InlineSafetyInfo { - def isSafe = false - } + sealed abstract class InlineSafetyInfo case object NeverSafeToInline extends InlineSafetyInfo - case object InlineableAtThisCaller extends InlineSafetyInfo { override def isSafe = true } + case object InlineableAtThisCaller extends InlineSafetyInfo case class DontInlineHere(msg: String) extends InlineSafetyInfo - case class FeasibleInline(accessNeeded: NonPublicRefs.Value, - toBecomePublic: List[Symbol]) extends InlineSafetyInfo { - override def isSafe = true - } + case class FeasibleInline(accessNeeded: NonPublicRefs.Value, toBecomePublic: List[Symbol]) extends InlineSafetyInfo case class AccessReq( accessNeeded: NonPublicRefs.Value, diff --git a/src/compiler/scala/tools/nsc/io/Socket.scala b/src/compiler/scala/tools/nsc/io/Socket.scala index 4925c50d85..a803e4121a 100644 --- a/src/compiler/scala/tools/nsc/io/Socket.scala +++ b/src/compiler/scala/tools/nsc/io/Socket.scala @@ -9,18 +9,11 @@ package io import java.io.{ IOException, InputStreamReader, BufferedReader, PrintWriter, Closeable } import java.io.{ BufferedOutputStream, BufferedReader } import java.net.{ ServerSocket, SocketException, SocketTimeoutException, InetAddress, Socket => JSocket } -import scala.sys.SystemProperties._ import scala.io.Codec /** A skeletal only-as-much-as-I-need Socket wrapper. */ object Socket { - def preferringIPv4[T](body: => T): T = exclusively { - val saved = preferIPv4Stack.value - try { preferIPv4Stack.enable() ; body } - finally preferIPv4Stack setValue saved - } - class Box[+T](f: () => T) { private def handlerFn[U](f: Throwable => U): PartialFunction[Throwable, U] = { case x @ (_: IOException | _: SecurityException) => f(x) diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index 52c6ddc6ee..3f210a543c 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -54,11 +54,6 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr printMessage(pos, clabel(severity) + msg) } - def printSourceLine(pos: Position) { - printMessage(pos.lineContent.stripLineEnd) - printColumnMarker(pos) - } - /** Prints the column marker of the given position. */ def printColumnMarker(pos: Position) = diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 96c93a838b..61b3d35f6a 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -165,7 +165,6 @@ trait ScalaSettings extends AbsScalaSettings val Ygenjavap = StringSetting ("-Ygen-javap", "dir", "Generate a parallel output directory of .javap files.", "") val Ygenasmp = StringSetting ("-Ygen-asmp", "dir", "Generate a parallel output directory of .asmp files (ie ASM Textifier output).", "") val Ydumpclasses = StringSetting ("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") - val Ynosqueeze = BooleanSetting ("-Yno-squeeze", "Disable creation of compact code in matching.") val Ystatistics = BooleanSetting ("-Ystatistics", "Print compiler statistics.") andThen (scala.reflect.internal.util.Statistics.enabled = _) val stopAfter = PhasesSetting ("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat val stopBefore = PhasesSetting ("-Ystop-before", "Stop before") @@ -191,7 +190,6 @@ trait ScalaSettings extends AbsScalaSettings val Yissuedebug = BooleanSetting("-Yissue-debug", "Print stack traces when a context issues an error.") val YmacrodebugLite = BooleanSetting("-Ymacro-debug-lite", "Trace essential macro-related activities.") val YmacrodebugVerbose = BooleanSetting("-Ymacro-debug-verbose", "Trace all macro-related activities: compilation, generation of synthetics, classloading, expansion, exceptions.") - val Ypmatdebug = BooleanSetting("-Ypmat-debug", "Trace all pattern matcher activity.") val Yposdebug = BooleanSetting("-Ypos-debug", "Trace position validation.") val Yreifydebug = BooleanSetting("-Yreify-debug", "Trace reification.") val Ytyperdebug = BooleanSetting("-Ytyper-debug", "Trace all type assignments.") diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 6a405295cf..f001964fb4 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -288,7 +288,6 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { // object C { def meth$extension[M, C](this$: C[C], a: A) // = { meth$extension[M', C']({ : C[C'] })(a1) } } case treeInfo.Applied(sel @ Select(qual, _), targs, argss) if sel.symbol == origMeth => - import gen.CODE._ localTyper.typedPos(tree.pos) { val allArgss = List(qual) :: argss val origThis = extensionMeth.owner.companionClass diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index 7eb899d9d7..2a3c631a66 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -327,13 +327,7 @@ trait MatchApproximation extends TreeAndTypeAnalysis with ScalaLogic with MatchT debug.patmat("treeMakers:") debug.patmat(alignAcrossRows(cases, ">>")) } - - def showTests(testss: List[List[Test]]) = { - debug.patmat("tests: ") - debug.patmat(alignAcrossRows(testss, "&")) - } } - } trait MatchAnalysis extends MatchApproximation { diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala index 8a04c67582..45698c0c76 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala @@ -141,7 +141,7 @@ trait MatchOptimization extends MatchTreeMaking with MatchAnalysis { object ReusedCondTreeMaker { def apply(orig: CondTreeMaker) = new ReusedCondTreeMaker(orig.prevBinder, orig.nextBinder, orig.cond, orig.res, orig.pos) } - class ReusedCondTreeMaker(prevBinder: Symbol, val nextBinder: Symbol, cond: Tree, res: Tree, val pos: Position) extends TreeMaker { import CODE._ + class ReusedCondTreeMaker(prevBinder: Symbol, val nextBinder: Symbol, cond: Tree, res: Tree, val pos: Position) extends TreeMaker { lazy val localSubstitution = Substitution(List(prevBinder), List(CODE.REF(nextBinder))) lazy val storedCond = freshSym(pos, BooleanTpe, "rc") setFlag MUTABLE lazy val treesToHoist: List[Tree] = { diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index ab19660da5..bb20c96809 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -53,10 +53,6 @@ trait MatchTranslation { case TypeBound(tpe) => tpe case tree => tree.tpe } - def repeatedType = unbound match { - case Star(tpt) => tpt.tpe - case _ => NoType - } def glbWith(other: Type) = glb(tpe :: other :: Nil).normalize object SymbolAndTypeBound { @@ -420,7 +416,6 @@ trait MatchTranslation { ) private def rawGet = typeOfMemberNamedGetOrSelf(resultType) - private def emptySub = rawSubPatTypes.isEmpty private def rawInit = rawSubPatTypes dropRight 1 protected def sequenceType = typeOfLastSelectorOrSelf(rawGet) protected def elementType = elementTypeOfLastSelectorOrSelf(rawGet) @@ -651,12 +646,5 @@ trait MatchTranslation { case _ => false } } - - object Bound { - def unapply(t: Tree): Option[(Symbol, Tree)] = t match { - case t@Bind(n, p) if t.hasExistingSymbol => Some((t.symbol, p)) // pos/t2429 does not satisfy these conditions - case _ => None - } - } } } diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala index 317685682d..7df03044aa 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala @@ -159,7 +159,6 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging { override def subPatternsAsSubstitution = Substitution(subPatBinders, subPatRefs) >> super.subPatternsAsSubstitution - import CODE._ def bindSubPats(in: Tree): Tree = if (!emitVars) in else { diff --git a/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala b/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala index a4944caa2b..394ba98f17 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala @@ -106,7 +106,6 @@ trait Debugging { trait Interface extends ast.TreeDSL { import global._ - import definitions._ import analyzer.Typer // 2.10/2.11 compatibility @@ -117,7 +116,6 @@ trait Interface extends ast.TreeDSL { object vpmName { val one = newTermName("one") - val drop = newTermName("drop") val flatMap = newTermName("flatMap") val get = newTermName("get") val guard = newTermName("guard") @@ -175,9 +173,6 @@ trait Interface extends ast.TreeDSL { val matchOwner = typer.context.owner def pureType(tp: Type): Type = tp - // Extracting from the monad: tp == { def get: T }, result == T - def matchMonadResult(tp: Type) = typeOfMemberNamedGet(tp) - def reportUnreachable(pos: Position) = typer.context.unit.warning(pos, "unreachable code") def reportMissingCases(pos: Position, counterExamples: List[String]) = { val ceString = diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index dc8c26c926..92f95e282b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -442,9 +442,6 @@ trait ContextErrors { def ArrayConstantsTypeMismatchError(tree: Tree, pt: Type) = NormalTypeError(tree, "found array constant, expected argument of type " + pt) - def UnexpectedTreeAnnotation(tree: Tree) = - NormalTypeError(tree, "unexpected tree in annotation: "+ tree) - def AnnotationTypeMismatchError(tree: Tree, expected: Type, found: Type) = NormalTypeError(tree, "expected annotation of type " + expected + ", found " + found) diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index b3675d6a82..4765c301dd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -854,9 +854,6 @@ object MacrosStats { class Fingerprint private[Fingerprint](val value: Int) extends AnyVal { def paramPos = { assert(isTag, this); value } def isTag = value >= 0 - def isOther = this == Other - def isExpr = this == LiftedTyped - def isTree = this == LiftedUntyped override def toString = this match { case Other => "Other" case LiftedTyped => "Expr" diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 12e8b0a3f9..599969598e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1675,13 +1675,6 @@ trait Namers extends MethodSynthesis { } } - @deprecated("Use underlyingSymbol instead", "2.10.0") - def underlying(member: Symbol): Symbol = underlyingSymbol(member) - @deprecated("Use `companionSymbolOf` instead", "2.10.0") - def companionClassOf(module: Symbol, ctx: Context): Symbol = companionSymbolOf(module, ctx) - @deprecated("Use `companionSymbolOf` instead", "2.10.0") - def companionModuleOf(clazz: Symbol, ctx: Context): Symbol = companionSymbolOf(clazz, ctx) - /** The companion class or companion module of `original`. * Calling .companionModule does not work for classes defined inside methods. * diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala index 38a3f18bf8..ee2a207efd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala @@ -159,19 +159,12 @@ trait PatternTypers { } } - def newExtractorShape(tree: Tree): ExtractorShape = tree match { - case Apply(fun, args) => ExtractorShape(fun, args) - case UnApply(fun, args) => ExtractorShape(fun, args) - } def newExtractorShape(fun: Tree, args: List[Tree]): ExtractorShape = ExtractorShape(fun, args) case class CaseClassInfo(clazz: Symbol, classType: Type) { def constructor = clazz.primaryConstructor def constructorType = classType.prefix memberType clazz memberType constructor - def paramTypes = constructorType.paramTypes def accessors = clazz.caseFieldAccessors - def accessorTypes = accessors map (m => (classType memberType m).finalResultType) - // def inverted = MethodType(clazz :: Nil, tupleType(accessorTypes)) } object NoCaseClassInfo extends CaseClassInfo(NoSymbol, NoType) { override def toString = "NoCaseClassInfo" @@ -186,10 +179,7 @@ trait PatternTypers { def paramType = firstParamType(unapplyType) def rawGet = if (isBool) UnitTpe else typeOfMemberNamedGetOrSelf(resultType) def rawTypes = if (isBool) Nil else typesOfSelectorsOrSelf(rawGet) - def rawArity = rawTypes.size def isBool = resultType =:= BooleanTpe // aka "Tuple0" or "Option[Unit]" - def isNothing = rawGet =:= NothingTpe - def isCase = method.isCase } object NoUnapplyMethodInfo extends UnapplyMethodInfo(NoSymbol, NoType) { @@ -213,7 +203,6 @@ trait PatternTypers { def unapplyMethod = exInfo.method def unapplyType = exInfo.unapplyType def unapplyParamType = exInfo.paramType - def caseClass = ccInfo.clazz def enclClass = symbol.enclClass // TODO - merge these. The difference between these two methods is that expectedPatternTypes diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala index bbd51b5564..54c665fe56 100644 --- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala +++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala @@ -62,15 +62,6 @@ trait StdAttachments { } } - /** Checks whether there is any tree resulting from a macro expansion and associated with the current tree. - */ - object ExpandedIntoTree { - def unapply(tree: Tree): Option[Tree] = tree.attachments.get[MacroExpansionAttachment] match { - case Some(MacroExpansionAttachment(_, tree: Tree)) => Some(tree) - case _ => None - } - } - /** When present, suppresses macro expansion for the host. * This is occasionally necessary, e.g. to prohibit eta-expansion of macros. * diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 61295b5abd..f0252251f7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -157,7 +157,7 @@ trait SyntheticMethods extends ast.TreeDSL { Ident(eqmeth.firstParam), List( CaseDef(Typed(Ident(nme.WILDCARD), TypeTree(clazz.tpe)), EmptyTree, TRUE), - CaseDef(WILD.empty, EmptyTree, FALSE) + CaseDef(Ident(nme.WILDCARD), EmptyTree, FALSE) ) ) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index e44c83aa56..1b726c37b9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -162,7 +162,6 @@ abstract class TreeCheckers extends Analyzer { lazy val tpeOfTree = mutable.HashMap[Tree, Type]() private lazy val reportedAlready = mutable.HashSet[(Tree, Symbol)]() - def posstr(t: Tree): String = if (t eq null) "" else posstr(t.pos) def posstr(p: Position): String = ( if (p eq null) "" else { try p.source.path + ":" + p.line @@ -264,9 +263,7 @@ abstract class TreeCheckers extends Analyzer { checkedTyped(tree, mode, pt) ) private def checkedTyped(tree: Tree, mode: Mode, pt: Type): Tree = { - def tpe = try tree.tpe finally tree.clearType() - val recorded = tpeOfTree.getOrElseUpdate(tree, tpe) - val typed = wrap(tree)(super.typed(tree, mode, pt)) + val typed = wrap(tree)(super.typed(tree, mode, pt)) if (tree ne typed) treesDiffer(tree, typed) @@ -365,8 +362,6 @@ abstract class TreeCheckers extends Analyzer { def typeOf(t: Tree): Type = if (t.tpe eq null) NoType else t.tpe def infoOf(t: Tree): Type = symbolOf(t).info def referencesInType(tp: Type) = tp collect { case TypeRef(_, sym, _) => sym } - def referencesInTree(t: Tree) = referencesInType(typeOf(t)) ++ referencesInType(infoOf(t)) - def symbolRefsInTree(t: Tree) = t collect { case t: RefTree => symbolOf(t) } // Accessors are known to steal the type of the underlying field without cloning existential symbols at the new owner. // This happens in Namer#accessorTypeCompleter. We just look the other way here. if (symbolOf(tree).isAccessor) @@ -381,10 +376,6 @@ abstract class TreeCheckers extends Analyzer { sym.isTypeParameter || sym.isLocal ) - val direct = tree match { - case _: RefTree => treeSym - case _ => NoSymbol - } val referencedSymbols = (treeSym :: referencesInType(treeInfo)).distinct filter (sym => isEligible(sym) && !isOk(sym)) def mk[T](what: String, x: T, str: T => String = (x: T) => "" + x): ((Any, String)) = x -> s"%10s %-20s %s".format(what, classString(x), truncate(str(x), 80).trim) @@ -415,13 +406,7 @@ abstract class TreeCheckers extends Analyzer { } referencedSymbols foreach (sym => - if (reportedAlready((tree, sym))) { - def what = tree match { - case tt: TypeTree => s"TypeTree(${tt.tpe})" - case _ => tree.shortClass + "(" + tree.symbol.nameString + ")" - } - } - else { + if (!reportedAlready((tree, sym))) { errorFn("\n" + mkErrorMsg(sym)) reportedAlready += ((tree, sym)) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala index afe6875218..cb1f1f4568 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala @@ -112,11 +112,6 @@ trait StructuredTypeStrings extends DestructureTypes { override def emptyTypeName = "Nil" override def typeName = "List" } - class TypeScope(nodes: List[TypeNode]) extends TypeProduct(nodes) { - override def grouping = BlockGrouping - override def typeName = "Scope" - override def emptyTypeName = "EmptyScope" - } object TypeEmpty extends TypeNode { override def grouping = NoGrouping diff --git a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala index f44fd412fd..550fd4e68d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala @@ -9,14 +9,12 @@ package typechecker import scala.collection.mutable import scala.reflect.internal.util.{ BatchSourceFile, Statistics } import mutable.ListBuffer -import symtab.Flags._ import Mode._ trait TypersTracking { self: Analyzer => import global._ - import definitions._ import typeDebug._ // To enable decent error messages when the typer crashes. @@ -53,7 +51,6 @@ trait TypersTracking { object typingStack { val out = new java.io.PrintWriter(System.err, true) - def println(msg: Any) = out println "" + msg // TODO - account for colors so the color of a multiline string // doesn't infect the connector lines @@ -72,12 +69,7 @@ trait TypersTracking { if (s1.length < 60 || settings.debug.value) s1 else s1.take(57) + "..." } - private val nextId = { var x = 1 ; () => try x finally x += 1 } - private class Frame(val tree: Tree) { - val stamp = System.nanoTime - val id = nextId() - } - private object NoFrame extends Frame(EmptyTree) { } + private class Frame(val tree: Tree) { } private def greenType(tp: Type): String = tpe_s(tp, inGreen) private def greenType(tree: Tree): String = tree match { case null => "[exception]" @@ -108,7 +100,6 @@ trait TypersTracking { showPush(tree, NOmode, WildcardType, context) } def showPush(tree: Tree, mode: Mode, pt: Type, context: Context) { - val alreadyTyped = tree.tpe ne null def tree_s = truncAndOneLine(ptTree(tree)) def pt_s = if (pt.isWildcard || context.inTypeConstructorAllowed) "" else s": pt=$pt" def all_s = List(tree_s, pt_s, mode, fullSiteString(context)) filterNot (_ == "") mkString " " @@ -143,9 +134,6 @@ trait TypersTracking { def nextTyped(tree: Tree, mode: Mode, pt: Type, context: Context)(body: => Tree): Tree = nextTypedInternal(tree, showPush(tree, mode, pt, context))(body) - def nextTyped(tree: Tree, context: Context)(body: => Tree): Tree = - nextTypedInternal(tree, showPush(tree, context))(body) - def nextTypedInternal(tree: Tree, pushFn: => Unit)(body: => Tree): Tree = ( if (noPrintTyping(tree)) body diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index c63d7f6820..8beca86a25 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -26,6 +26,8 @@ import scala.reflect.runtime.ReflectionUtils * @author Stepan Koltsov */ object ClassPath { + import scala.language.postfixOps + /** Expand single path entry */ private def expandS(pattern: String): List[String] = { val wildSuffix = File.separator + "*" @@ -80,9 +82,6 @@ object ClassPath { ) } - /** A useful name filter. */ - def isTraitImplementation(name: String) = ReflectionUtils.isTraitImplementation(name) - def specToURL(spec: String): Option[URL] = try Some(new URL(spec)) catch { case _: MalformedURLException => None } diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index 72a4bbf5c0..0db351f918 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -10,9 +10,6 @@ package nsc import java.io.{ OutputStream, PrintStream, ByteArrayOutputStream, PrintWriter, StringWriter } package object util { - - implicit def postfixOps = scala.language.postfixOps // make all postfix ops in this package compile without warning - // forwarder for old code that builds against 2.9 and 2.10 val Chars = scala.reflect.internal.Chars diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 6a495cfcee..fdc2613810 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -126,7 +126,9 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => verify(expr0) // need to wrap the expr, because otherwise you won't be able to typecheck macros against something that contains free vars - var (expr, freeTerms) = extractFreeTerms(expr0, wrapFreeTermRefs = false) + val exprAndFreeTerms = extractFreeTerms(expr0, wrapFreeTermRefs = false) + var expr = exprAndFreeTerms._1 + val freeTerms = exprAndFreeTerms._2 val dummies = freeTerms.map{ case (freeTerm, name) => ValDef(NoMods, name, TypeTree(freeTerm.info), Select(Ident(PredefModule), newTermName("$qmark$qmark$qmark"))) }.toList expr = Block(dummies, wrapIntoTerm(expr)) diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala b/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala index 9d171d52d2..dd849f2bca 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala @@ -60,11 +60,11 @@ trait Holes { self: Quasiquotes => } object HoleType { def unapply(tpe: Type): Option[HoleType] = tpe match { - case NativeType(holeTpe) => Some(holeTpe) - case LiftableType(holeTpe) => Some(holeTpe) - case IterableTreeType(holeTpe) => Some(holeTpe) + case NativeType(holeTpe) => Some(holeTpe) + case LiftableType(holeTpe) => Some(holeTpe) + case IterableTreeType(holeTpe) => Some(holeTpe) case IterableLiftableType(holeTpe) => Some(holeTpe) - case _ => None + case _ => None } trait HoleTypeExtractor { @@ -102,7 +102,7 @@ trait Holes { self: Quasiquotes => if (tree.tpe != null && (tree.tpe <:< listTreeType || tree.tpe <:< listListTreeType)) tree else atPos(tree.pos)(loop(tree, n)) } - val (card, elementTpe) = parseCardinality(tpe) + val card = parseCardinality(tpe)._1 if (card != NoDot) Some(reifyIterable(_, card)) else None } } diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala index e20d98c0f1..c2b219ee31 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala @@ -26,7 +26,7 @@ trait Placeholders { self: Quasiquotes => val start = sb.length sb.append(value) val end = sb.length - posMap += pos -> (start, end) + posMap += pos -> ((start, end)) } def appendHole(tree: Tree, cardinality: Cardinality) = { diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala index 0d1fb6be07..18999e8267 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala @@ -11,7 +11,6 @@ trait Reifiers { self: Quasiquotes => SyntacticDefDef, SyntacticValDef, SyntacticVarDef, SyntacticBlock, SyntacticApplied, SyntacticTypeApplied, SyntacticFunction, SyntacticNew, SyntacticAssign} - import global.treeInfo._ import global.definitions._ import Cardinality._ import universeTypes._ -- cgit v1.2.3