diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-21 19:10:41 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-21 19:10:41 +0000 |
commit | 914932babf9343fdfcec20f25bfb1576dc8c433b (patch) | |
tree | 088e404a21862209be434b0236c34e4576042c51 /src | |
parent | cb7f66a22c9167a7e8ffce042a4bf1c5c9849a89 (diff) | |
download | scala-914932babf9343fdfcec20f25bfb1576dc8c433b.tar.gz scala-914932babf9343fdfcec20f25bfb1576dc8c433b.tar.bz2 scala-914932babf9343fdfcec20f25bfb1576dc8c433b.zip |
Removed Pair(...), Triple(...).
Diffstat (limited to 'src')
107 files changed, 885 insertions, 859 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala index bb24ad2d30..7c3a664641 100644 --- a/src/compiler/scala/tools/nsc/CompileClient.scala +++ b/src/compiler/scala/tools/nsc/CompileClient.scala @@ -35,7 +35,7 @@ object CompileClient { pathsList.map(absFileName).mkString("", sep, "") } - private def normalize(args: Array[String]): Pair[String, String] = { + private def normalize(args: Array[String]): (String, String) = { var i = 0 val vmArgs = new StringBuilder var serverAdr = "" @@ -70,7 +70,7 @@ object CompileClient { } } } - Pair(vmArgs.toString, serverAdr) + (vmArgs.toString, serverAdr) } // used by class ant.FastScalac to skip exit statement in Ant. @@ -81,7 +81,7 @@ object CompileClient { else ("-d" :: "." :: args0.toList).toArray - val Pair(vmArgs, serverAdr) = normalize(args) + val (vmArgs, serverAdr) = normalize(args) if (version) { Console.println(versionMsg) return 0 diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 0fa020d4d3..0f9147de8a 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -55,13 +55,13 @@ object CompileSocket { /** The temporary directory in which the port identification file is stored */ private val tmpDir = { val totry = List( - Pair("scala.home", List("var", "scala-devel")), - Pair("user.home", List("tmp")), - Pair("java.io.tmpdir", Nil)) + ("scala.home", List("var", "scala-devel")), + ("user.home", List("tmp")), + ("java.io.tmpdir", Nil)) /** Expand a property-extensions pair into a complete File object */ - def expand(trial: Pair[String, List[String]]): Option[File] = { - val Pair(topdirProp, extensions) = trial + def expand(trial: (String, List[String])): Option[File] = { + val (topdirProp, extensions) = trial val topdir = System.getProperty(topdirProp) if (topdir eq null) return None diff --git a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala index 4503abf241..cf6e6672db 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala @@ -36,7 +36,7 @@ extends Settings(error) { class DefinesSetting extends Setting("-D<prop>", "set a Java property") { - private val props = new Queue[Pair[String, String]] + private val props = new Queue[(String, String)] def value = props.toList @@ -49,9 +49,9 @@ extends Settings(error) { val eqidx = stripD.indexOf('=') val addition = if(eqidx < 0) - Pair(stripD, "") + (stripD, "") else - Pair(stripD.substring(0, eqidx), stripD.substring(eqidx+1)) + (stripD.substring(0, eqidx), stripD.substring(eqidx+1)) props += addition rest } @@ -63,7 +63,7 @@ extends Settings(error) { /** Apply the specified properties to the current JVM */ def applyToCurrentJVM = { val systemProps = getProperties - for(val Pair(key, value) <- props.toList) + for(val (key, value) <- props.toList) systemProps.setProperty(key, value) } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 016d84f6b1..8d8297afd1 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -507,7 +507,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable showDef(newTermName(settings.Xshowobj.value), true) if (reporter.hasErrors) { - for (val Pair(sym, file) <- symSource.elements) { + for (val (sym, file) <- symSource.elements) { sym.reset(new loaders.SourcefileLoader(file)) if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader) } @@ -520,7 +520,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable warning("there were unchecked warnings; re-run with -unchecked for details") } } - for (val Pair(sym, file) <- symSource.elements) resetPackageClass(sym.owner) + for (val (sym, file) <- symSource.elements) resetPackageClass(sym.owner) //units foreach (.clear()) informTime("total", startTime) } diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index c8115cf7b4..c66590c359 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -282,7 +282,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) if (!req.compile) return IR.Error // an error happened during compilation, e.g. a type error - val Pair(interpreterResultString, succeeded) = req.loadAndRun + val (interpreterResultString, succeeded) = req.loadAndRun if (printResults || !succeeded) { // print the result @@ -553,20 +553,20 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter) } /** load and run the code using reflection */ - def loadAndRun: Pair[String, Boolean] = { + def loadAndRun: (String, Boolean) = { val interpreterResultObject: Class = Class.forName(resultObjectName, true, classLoader) val resultValMethod: java.lang.reflect.Method = interpreterResultObject.getMethod("result", null) try { - Pair(resultValMethod.invoke(interpreterResultObject, null).toString(), + (resultValMethod.invoke(interpreterResultObject, null).toString(), true) } catch { case e => { def caus(e: Throwable): Throwable = if (e.getCause eq null) e else caus(e.getCause) val orig = caus(e) - Pair(stringFrom(str => orig.printStackTrace(str)), + (stringFrom(str => orig.printStackTrace(str)), false) } } diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 6696f210df..a353c2b3e8 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -108,7 +108,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { if (line eq null) return () // assumes null means EOF - val Pair(keepGoing, finalLineMaybe) = command(line) + val (keepGoing, finalLineMaybe) = command(line) if (!keepGoing) return @@ -158,7 +158,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { /** Run one command submitted by the user. Three values are returned: * (1) whether to keep running, (2) the line to record for replay, * if any. */ - def command(line: String): Pair[Boolean, Option[String]] = { + def command(line: String): (Boolean, Option[String]) = { def withFile(command: String)(action: String => Unit): Unit = { val spaceIdx = command.indexOf(' ') if (spaceIdx <= 0) { @@ -183,7 +183,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { if (line.matches(helpRegexp)) printHelp else if (line.matches(quitRegexp)) - return Pair(false, None) + return (false, None) else if (line.matches(loadRegexp)) { withFile(line)(f => { interpretAllFrom(f) @@ -197,7 +197,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { else shouldReplay = interpretStartingWith(line) - Pair(true, shouldReplay) + (true, shouldReplay) } /** Interpret expressions starting with the first line. diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index e541cfc906..6ee8348600 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -227,7 +227,7 @@ object ScriptRunner { * the directory with the compiled class files, * and a flag for whether the compilation succeeded. */ - def compile: Pair[File, Boolean] = { + def compile: (File, Boolean) = { val compiledPath = File.createTempFile("scalascript", "") compiledPath.delete // the file is created as a file; make it a directory compiledPath.mkdirs @@ -239,10 +239,10 @@ object ScriptRunner { val compiler = new Global(settings, reporter) val cr = new compiler.Run cr.compileSources(List(wrappedScript(scriptFile, &compiler.getSourceFile))) - Pair(compiledPath, !reporter.hasErrors) + (compiledPath, !reporter.hasErrors) } else { val compok = compileWithDaemon(settings, scriptFile) - Pair(compiledPath, compok) + (compiledPath, compok) } } @@ -258,7 +258,7 @@ object ScriptRunner { } else { // The pre-compiled jar is old. Recompile the script. jarFile.delete - val Pair(compiledPath, compok) = compile + val (compiledPath, compok) = compile try { if (compok) { tryMakeJar(jarFile, compiledPath) @@ -277,7 +277,7 @@ object ScriptRunner { } } else { // don't use the cache; just run from the interpreter's temporary directory - val Pair(compiledPath, compok) = compile + val (compiledPath, compok) = compile try { if (compok) handler(compiledPath.getPath) diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 038daeb815..057071f97f 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -173,7 +173,7 @@ abstract class TreeBrowsers { override def convertValueToText(value: Any, sel: Boolean, exp: Boolean, leaf: Boolean, row: Int, hasFocus: Boolean) = { - val Pair(cls, name) = TreeInfo.treeName(value.asInstanceOf[Tree]) + val (cls, name) = TreeInfo.treeName(value.asInstanceOf[Tree]) if (name != EMPTY) cls + "[" + name.toString() + "]" else @@ -250,138 +250,138 @@ abstract class TreeBrowsers { object TreeInfo { /** Return the case class name and the Name, if the node defines one */ - def treeName(t: Tree): Pair[String, Name] = t match { + def treeName(t: Tree): (String, Name) = t match { case ProgramTree(units) => - Pair("Program", EMPTY) + ("Program", EMPTY) case UnitTree(unit) => - Pair("CompilationUnit", unit.toString()) + ("CompilationUnit", unit.toString()) case DocDef(comment, definition) => - Pair("DocDef", EMPTY) + ("DocDef", EMPTY) case ClassDef(mods, name, tparams, self, impl) => - Pair("ClassDef", name) + ("ClassDef", name) case PackageDef(packaged, impl) => - Pair("PackageDef", EMPTY) + ("PackageDef", EMPTY) case ModuleDef(mods, name, impl) => - Pair("ModuleDef", name) + ("ModuleDef", name) case ValDef(mods, name, tpe, rhs) => - Pair("ValDef", name) + ("ValDef", name) case DefDef(mods, name, tparams, vparams, tpe, rhs) => - Pair("DefDef", name) + ("DefDef", name) case AbsTypeDef(mods, name, rhs, lobound) => - Pair("AbsTypeDef", name) + ("AbsTypeDef", name) case AliasTypeDef(mods, name, tparams, rhs) => - Pair("AliasTypeDef", name) + ("AliasTypeDef", name) case Import(expr, selectors) => - Pair("Import", EMPTY) + ("Import", EMPTY) case CaseDef(pat, guard, body) => - Pair("CaseDef", EMPTY) + ("CaseDef", EMPTY) case Template(parents, body) => - Pair("Template", EMPTY) + ("Template", EMPTY) case LabelDef(name, params, rhs) => - Pair("LabelDef", name) + ("LabelDef", name) case Block(stats, expr) => - Pair("Block", EMPTY) + ("Block", EMPTY) case Sequence(trees) => - Pair("Sequence", EMPTY) + ("Sequence", EMPTY) case Alternative(trees) => - Pair("Alternative", EMPTY) + ("Alternative", EMPTY) case Bind(name, rhs) => - Pair("Bind", name) + ("Bind", name) case Match(selector, cases) => - Pair("Visitor", EMPTY) + ("Visitor", EMPTY) case Function(vparams, body) => - Pair("Function", EMPTY) + ("Function", EMPTY) case Assign(lhs, rhs) => - Pair("Assign", EMPTY) + ("Assign", EMPTY) case If(cond, thenp, elsep) => - Pair("If", EMPTY) + ("If", EMPTY) case Return(expr) => - Pair("Return", EMPTY) + ("Return", EMPTY) case Throw(expr) => - Pair("Throw", EMPTY) + ("Throw", EMPTY) case New(init) => - Pair("New", EMPTY) + ("New", EMPTY) case Typed(expr, tpe) => - Pair("Typed", EMPTY) + ("Typed", EMPTY) case TypeApply(fun, args) => - Pair("TypeApply", EMPTY) + ("TypeApply", EMPTY) case Apply(fun, args) => - Pair("Apply", EMPTY) + ("Apply", EMPTY) case Super(qualif, mix) => - Pair("Super", qualif.toString() + ", mix: " + mix.toString()) + ("Super", qualif.toString() + ", mix: " + mix.toString()) case This(qualifier) => - Pair("This", qualifier) + ("This", qualifier) case Select(qualifier, selector) => - Pair("Select", selector) + ("Select", selector) case Ident(name) => - Pair("Ident", name) + ("Ident", name) case Literal(value) => - Pair("Literal", EMPTY) + ("Literal", EMPTY) case TypeTree() => - Pair("TypeTree", EMPTY) + ("TypeTree", EMPTY) case Annotated(constr, elements, arg) => - Pair("Annotated", EMPTY) + ("Annotated", EMPTY) case AttributedTypeTree(attribs, tpt) => - Pair("AttributedTypeTree", EMPTY) + ("AttributedTypeTree", EMPTY) case SingletonTypeTree(ref) => - Pair("SingletonType", EMPTY) + ("SingletonType", EMPTY) case SelectFromTypeTree(qualifier, selector) => - Pair("SelectFromType", selector) + ("SelectFromType", selector) case CompoundTypeTree(template) => - Pair("CompoundType", EMPTY) + ("CompoundType", EMPTY) case AppliedTypeTree(tpe, args) => - Pair("AppliedType", EMPTY) + ("AppliedType", EMPTY) case Try(block, catcher, finalizer) => - Pair("Try", EMPTY) + ("Try", EMPTY) case EmptyTree => - Pair("Empty", EMPTY) + ("Empty", EMPTY) case ArrayValue(elemtpt, trees) => - Pair("ArrayValue", EMPTY) + ("ArrayValue", EMPTY) case Star(t) => - Pair("Star", EMPTY) + ("Star", EMPTY) } /** Return a list of children for the given tree node */ diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 28a7fd10b0..2ff4b41266 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -8,6 +8,7 @@ package scala.tools.nsc.ast import scala.tools.nsc.util.Position import symtab.Flags._ +import scala.collection.mutable.ListBuffer abstract class TreeGen { @@ -205,4 +206,34 @@ abstract class TreeGen { def mkRuntimeCall(meth: Name, args: List[Tree]): Tree = Apply(Select(mkAttributedRef(ScalaRunTimeModule), meth), args) + + def evalOnce(expr: Tree, owner: Symbol, unit: CompilationUnit)(within: (() => Tree) => Tree): Tree = + if (treeInfo.isPureExpr(expr)) { + within(() => expr); + } else { + val temp = owner.newValue(expr.pos, unit.fresh.newName()) + .setFlag(SYNTHETIC).setInfo(expr.tpe); + atPos(expr.pos) { + Block(List(ValDef(temp, expr)), within(() => Ident(temp) setType expr.tpe)) + } + } + + def evalOnceAll(exprs: List[Tree], owner: Symbol, unit: CompilationUnit)(within: (List[() => Tree]) => Tree): Tree = { + val vdefs = new ListBuffer[ValDef] + val exprs1 = new ListBuffer[() => Tree] + for (val expr <- exprs) { + if (treeInfo.isPureExpr(expr)) { + exprs1 += (() => expr) + } else { + val temp = owner.newValue(expr.pos, unit.fresh.newName()) + .setFlag(SYNTHETIC).setInfo(expr.tpe) + vdefs += ValDef(temp, expr) + exprs1 += (() => Ident(temp) setType expr.tpe) + } + } + val prefix = vdefs.toList + val result = within(exprs1.toList) + if (prefix.isEmpty) result + else Block(prefix, result) setPos prefix.head.pos + } } diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index 13980856ec..d4ff2d1737 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -96,6 +96,25 @@ abstract class TreeInfo { false } + def mayBeVarGetter(sym: Symbol) = sym.info match { + case PolyType(List(), _) => sym.owner.isClass && !sym.isStable + case _: ImplicitMethodType => sym.owner.isClass && !sym.isStable + case _ => false + } + + def isVariableOrGetter(tree: Tree) = tree match { + case Ident(_) => + tree.symbol.isVariable + case Select(qual, _) => + tree.symbol.isVariable || + (mayBeVarGetter(tree.symbol) && + tree.symbol.owner.info.decl(nme.getterToSetter(tree.symbol.name)) != NoSymbol) + case Apply(Select(qual, nme.apply), _) => + qual.tpe.decl(nme.update) != NoSymbol + case _ => + false + } + /** Is tree a self constructor call? */ def isSelfConstrCall(tree: Tree): boolean = tree match { diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 5294cb5fc6..c592c01af0 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -177,7 +177,7 @@ abstract class TreePrinters { print(symName(tree, name)); printRow(params, "(", ",", ")"); printBlock(rhs) case Import(expr, selectors) => - def selectorToString(s: Pair[Name, Name]): String = + def selectorToString(s: (Name, Name)): String = if (s._1 == nme.WILDCARD || s._1 == s._2) s._1.toString() else s._1.toString() + "=>" + s._2.toString() print("import "); print(expr) diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index a2085bb50b..d4f400169d 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -409,7 +409,7 @@ trait Trees requires Global { * @param expr * @param selectors */ - case class Import(expr: Tree, selectors: List[Pair[Name, Name]]) + case class Import(expr: Tree, selectors: List[(Name, Name)]) extends SymTree /** Annotation application (constructor arguments + name-value pairs) */ @@ -751,7 +751,7 @@ trait Trees requires Global { def AbsTypeDef(tree: Tree, mods: Modifiers, name: Name, lo: Tree, hi: Tree): AbsTypeDef def AliasTypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[AbsTypeDef], rhs: Tree): AliasTypeDef def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]): Import + def Import(tree: Tree, expr: Tree, selectors: List[(Name, Name)]): Import def Annotation(tree: Tree, constr: Tree, elements: List[Tree]): Annotation def DocDef(tree: Tree, comment: String, definition: Tree): DocDef def Template(tree: Tree, parents: List[Tree], body: List[Tree]): Template @@ -806,7 +806,7 @@ trait Trees requires Global { new AliasTypeDef(mods, name, tparams, rhs).copyAttrs(tree) def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree) = new LabelDef(name, params, rhs).copyAttrs(tree) - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) = + def Import(tree: Tree, expr: Tree, selectors: List[(Name, Name)]) = new Import(expr, selectors).copyAttrs(tree) def Annotation(tree: Tree, constr: Tree, elements: List[Tree]) = new Annotation(constr, elements) @@ -923,7 +923,7 @@ trait Trees requires Global { if (name0 == name) && (params0 == params) && (rhs0 == rhs) => t case _ => copy.LabelDef(tree, name, params, rhs) } - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) = tree match { + def Import(tree: Tree, expr: Tree, selectors: List[(Name, Name)]) = tree match { case t @ Import(expr0, selectors0) if (expr0 == expr) && (selectors0 == selectors) => t case _ => copy.Import(tree, expr, selectors) diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 4e1d73b53f..1da2a5e779 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -62,7 +62,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean else reportSyntaxError("'" + that + "' expected instead of '" + ch + "'") - var debugLastStartElement = new mutable.Stack[Pair[Int, String]] + var debugLastStartElement = new mutable.Stack[(Int, String)] /** checks whether next character starts a Scala block, if yes, skip it. * @return true if next character starts a scala block @@ -143,7 +143,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean * [40] STag ::= '<' Name { S Attribute } [S] * [44] EmptyElemTag ::= '<' Name { S Attribute } [S] */ - /*[Duplicate]*/ def xTag: Pair[String, mutable.Map[String, Tree]] = { + /*[Duplicate]*/ def xTag: (String, mutable.Map[String, Tree]) = { val elemName = xName xSpaceOpt val aMap = @@ -378,7 +378,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean if(qname == "xml:unparsed") return xUnparsed - debugLastStartElement.push(Pair(pos1, qname)) + debugLastStartElement.push((pos1, qname)) val ts = content xEndTag(qname) debugLastStartElement.pop @@ -613,7 +613,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean //Console.println("xPattern") val pos1 = pos val qname = xName - debugLastStartElement.push(Pair(pos1, qname)) + debugLastStartElement.push((pos1, qname)) xSpaceOpt if (ch == '/') { // empty tag nextch diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index e21460633c..6f4247b49e 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1059,8 +1059,8 @@ trait Parsers requires SyntaxAnalyzer { parents += annotType(false) } newLineOptWhenFollowedBy(LBRACE) - val Pair(self, stats) = if (in.token == LBRACE) templateBody() - else Pair(emptyValDef, List()) + val (self, stats) = if (in.token == LBRACE) templateBody() + else (emptyValDef, List()) makeNew(parents.toList, self, stats, argss.toList) } canApply = false @@ -1704,7 +1704,7 @@ trait Parsers requires SyntaxAnalyzer { def loop: Tree = if (in.token == USCORE) { in.nextToken() - Import(t, List(Pair(nme.WILDCARD, null))) + Import(t, List((nme.WILDCARD, null))) } else if (in.token == LBRACE) { Import(t, importSelectors()) } else { @@ -1714,7 +1714,7 @@ trait Parsers requires SyntaxAnalyzer { pos = accept(DOT) loop } else { - Import(t, List(Pair(name, name))) + Import(t, List((name, name))) } } loop @@ -1722,8 +1722,8 @@ trait Parsers requires SyntaxAnalyzer { /** ImportSelectors ::= `{' {ImportSelector `,'} (ImportSelector | `_') `}' */ - def importSelectors(): List[Pair[Name, Name]] = { - val names = new ListBuffer[Pair[Name, Name]] + def importSelectors(): List[(Name, Name)] = { + val names = new ListBuffer[(Name, Name)] accept(LBRACE) var isLast = importSelector(names) while (!isLast && in.token == COMMA) { @@ -1736,12 +1736,12 @@ trait Parsers requires SyntaxAnalyzer { /** ImportSelector ::= Id [`=>' Id | `=>' `_'] */ - def importSelector(names: ListBuffer[Pair[Name, Name]]): boolean = + def importSelector(names: ListBuffer[(Name, Name)]): boolean = if (in.token == USCORE) { - in.nextToken(); names += Pair(nme.WILDCARD, null); true + in.nextToken(); names += (nme.WILDCARD, null); true } else { val name = ident() - names += Pair( + names += ( name, if (in.token == ARROW) { in.nextToken() @@ -1821,9 +1821,9 @@ trait Parsers requires SyntaxAnalyzer { */ def varDefOrDcl(mods: Modifiers): List[Tree] = { var newmods = mods | Flags.MUTABLE - val lhs = new ListBuffer[Pair[Int, Name]] + val lhs = new ListBuffer[(Int, Name)] do { - lhs += Pair(in.skipToken(), ident()) + lhs += (in.skipToken(), ident()) } while (in.token == COMMA) val tp = typedOpt() val rhs = if (tp.isEmpty || in.token == EQUALS) { @@ -1838,7 +1838,7 @@ trait Parsers requires SyntaxAnalyzer { newmods = newmods | Flags.DEFERRED EmptyTree } - for (val Pair(pos, name) <- lhs.toList) yield + for (val (pos, name) <- lhs.toList) yield atPos(pos) { ValDef(newmods, name, tp.duplicate, rhs.duplicate) } } @@ -1965,12 +1965,12 @@ trait Parsers requires SyntaxAnalyzer { implicitClassViews = implicitViewBuf.toList //if (mods.hasFlag(Flags.CASE) && in.token != LPAREN) accept(LPAREN) val constrAnnots = annotations() - val Pair(constrMods, vparamss) = - if (mods.hasFlag(Flags.TRAIT)) Pair(NoMods, List()) - else Pair(accessModifierOpt(), + val (constrMods, vparamss) = + if (mods.hasFlag(Flags.TRAIT)) (NoMods, List()) + else (accessModifierOpt(), paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE))) val thistpe = requiresTypeOpt() - val Pair(self0, template) = + val (self0, template) = classTemplate(mods, name, constrMods withAnnotations constrAnnots, vparamss) val mods1 = if (mods.hasFlag(Flags.TRAIT) && (template.body forall treeInfo.isInterfaceMember)) @@ -1987,7 +1987,7 @@ trait Parsers requires SyntaxAnalyzer { def objectDef(mods: Modifiers): ModuleDef = atPos(in.skipToken()) { val name = ident() - val Pair(self, template0) = classTemplate(mods, name, NoMods, List()) + val (self, template0) = classTemplate(mods, name, NoMods, List()) val template = self match { case ValDef(mods, name, tpt, EmptyTree) if (name != nme.WILDCARD) => val vd = ValDef(mods, name, tpt, This(nme.EMPTY.toTypeName)) setPos self.pos @@ -2003,7 +2003,7 @@ trait Parsers requires SyntaxAnalyzer { * TraitTemplate ::= [extends MixinParents] [TemplateBody] * MixinParents ::= AnnotType {with AnnotType} */ - def classTemplate(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]]): Pair[ValDef, Template] = { + def classTemplate(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]]): (ValDef, Template) = { val pos = in.currentPos; def acceptEmptyTemplateBody(msg: String): unit = { if (in.token == LPAREN && settings.migrate.value) @@ -2039,10 +2039,10 @@ trait Parsers requires SyntaxAnalyzer { } val ps = parents.toList newLineOptWhenFollowedBy(LBRACE) - val Pair(self, body) = + val (self, body) = if (in.token == LBRACE) templateBody() - else { acceptEmptyTemplateBody("`{' expected"); Pair(emptyValDef, List()) } - Pair(self, + else { acceptEmptyTemplateBody("`{' expected"); (emptyValDef, List()) } + (self, atPos(pos) { if (!mods.hasFlag(Flags.TRAIT)) Template(ps, constrMods, vparamss, argss.toList, body) else Template(ps, body) @@ -2053,11 +2053,11 @@ trait Parsers requires SyntaxAnalyzer { /** TemplateBody ::= [nl] `{' TemplateStatSeq `}' */ - def templateBody(): Pair[ValDef, List[Tree]] = { + def templateBody(): (ValDef, List[Tree]) = { accept(LBRACE) - val result @ Pair(self, stats) = templateStatSeq() + val result @ (self, stats) = templateStatSeq() accept(RBRACE) - if (stats.isEmpty) Pair(self, List(EmptyTree)) else result + if (stats.isEmpty) (self, List(EmptyTree)) else result } /** Refinement ::= [nl] `{' RefineStat {semi RefineStat} `}' @@ -2122,7 +2122,7 @@ trait Parsers requires SyntaxAnalyzer { * | Expr1 * | */ - def templateStatSeq(): Pair[ValDef, List[Tree]] = { + def templateStatSeq(): (ValDef, List[Tree]) = { var self: ValDef = emptyValDef val stats = new ListBuffer[Tree] if (isExprIntro) { @@ -2149,7 +2149,7 @@ trait Parsers requires SyntaxAnalyzer { } if (in.token != RBRACE && in.token != EOF) acceptStatSep() } - Pair(self, stats.toList) + (self, stats.toList) } /** RefineStatSeq ::= RefineStat {semi RefineStat} diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 251d1a774f..e6efb6e76a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -57,16 +57,16 @@ abstract class TreeBuilder { /** Traverse pattern and collect all variable names with their types in buffer */ private object getvarTraverser extends Traverser { - val buf = new ListBuffer[Pair[Name, Tree]] + val buf = new ListBuffer[(Name, Tree)] def init: Traverser = { buf.clear; this } override def traverse(tree: Tree): unit = tree match { case Bind(name, Typed(tree1, tpt)) => if ((name != nme.WILDCARD) && (buf.elements forall (name !=))) - buf += Pair(name, tpt) + buf += (name, tpt) traverse(tree1) case Bind(name, tree1) => if ((name != nme.WILDCARD) && (buf.elements forall (name !=))) - buf += Pair(name, TypeTree()) + buf += (name, TypeTree()) traverse(tree1) case _ => super.traverse(tree) @@ -76,7 +76,7 @@ abstract class TreeBuilder { /** Returns list of all pattern variables, possibly with their types, * without duplicates */ - private def getVariables(tree: Tree): List[Pair[Name, Tree]] = { + private def getVariables(tree: Tree): List[(Name, Tree)] = { getvarTraverser.init.traverse(tree) getvarTraverser.buf.toList } @@ -112,11 +112,11 @@ abstract class TreeBuilder { /** If tree is a variable pattern, return Some("its name and type"). * Otherwise return none */ - private def matchVarPattern(tree: Tree): Option[Pair[Name, Tree]] = tree match { - case Ident(name) => Some(Pair(name, TypeTree())) - case Bind(name, Ident(nme.WILDCARD)) => Some(Pair(name, TypeTree())) - case Typed(Ident(name), tpt) => Some(Pair(name, tpt)) - case Bind(name, Typed(Ident(nme.WILDCARD), tpt)) => Some(Pair(name, tpt)) + private def matchVarPattern(tree: Tree): Option[(Name, Tree)] = tree match { + case Ident(name) => Some((name, TypeTree())) + case Bind(name, Ident(nme.WILDCARD)) => Some((name, TypeTree())) + case Typed(Ident(name), tpt) => Some((name, tpt)) + case Bind(name, Typed(Ident(nme.WILDCARD), tpt)) => Some((name, tpt)) case _ => None } @@ -265,7 +265,7 @@ abstract class TreeBuilder { private def makeFor(mapName: Name, flatMapName: Name, enums: List[Enumerator], body: Tree): Tree = { def makeClosure(pat: Tree, body: Tree): Tree = matchVarPattern(pat) match { - case Some(Pair(name, tpt)) => + case Some((name, tpt)) => Function(List(ValDef(Modifiers(PARAM), name, tpt, EmptyTree)), body) case None => makeVisitor(List(CaseDef(pat, EmptyTree, body)), false) @@ -390,7 +390,7 @@ abstract class TreeBuilder { /** Create tree for pattern definition <mods val pat0 = rhs> */ def makePatDef(mods: Modifiers, pat: Tree, rhs: Tree): List[Tree] = matchVarPattern(pat) match { - case Some(Pair(name, tpt)) => + case Some((name, tpt)) => List(ValDef(mods, name, tpt, rhs)) case None => @@ -415,13 +415,13 @@ abstract class TreeBuilder { vars match { case List() => List(matchExpr) - case List(Pair(vname, tpt)) => + case List((vname, tpt)) => List(ValDef(mods, vname, tpt, matchExpr)) case _ => val tmp = freshName() val firstDef = ValDef(Modifiers(PRIVATE | LOCAL | SYNTHETIC), tmp, TypeTree(), matchExpr) var cnt = 0 - val restDefs = for (val Pair(vname, tpt) <- vars) yield { + val restDefs = for (val (vname, tpt) <- vars) yield { cnt = cnt + 1 ValDef(mods, vname, tpt, Select(Ident(tmp), newTermName("_" + cnt))) } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala index e7a456aee6..f7dd446c0d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala @@ -209,7 +209,7 @@ abstract class Checkers { * kind TypeKind. */ def checkBinop(kind: TypeKind) = { - val Pair(a, b) = stack.pop2 + val (a, b) = stack.pop2 checkType(a, kind) checkType(b, kind) } @@ -269,11 +269,11 @@ abstract class Checkers { case LOAD_ARRAY_ITEM(kind) => checkStack(2) stack.pop2 match { - case Pair(INT, ARRAY(elem)) => + case (INT, ARRAY(elem)) => if (!(elem <:< kind)) typeError(kind, elem); stack.push(elem); - case Pair(a, b) => + case (a, b) => error(" expected and INT and a array reference, but " + a + ", " + b + " found"); } @@ -302,12 +302,12 @@ abstract class Checkers { case STORE_ARRAY_ITEM(kind) => checkStack(3); stack.pop3 match { - case Triple(k, INT, ARRAY(elem)) => + case (k, INT, ARRAY(elem)) => if (!(k <:< kind)) typeError(kind, k); if (!(k <:< elem)) typeError(elem, k); - case Triple(a, b, c) => + case (a, b, c) => error(" expected and array reference, and int and " + kind + " but " + a + ", " + b + ", " + c + " found"); } @@ -333,7 +333,7 @@ abstract class Checkers { } else { checkStack(2); stack.pop2 match { - case Pair(value, obj) => + case (value, obj) => checkField(obj, field); val fieldType = toTypeKind(field.tpe); if (fieldType != SCALA_ALL_REF && !(value <:< fieldType)) @@ -378,7 +378,7 @@ abstract class Checkers { case Shift(op, kind) => checkType(kind, BYTE, CHAR, SHORT, INT, LONG) - val Pair(a, b) = stack.pop2 + val (a, b) = stack.pop2 checkType(a, INT) checkType(b, kind) stack push kind diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index e60ea9a341..0abf72055f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -484,14 +484,14 @@ abstract class GenICode extends SubComponent { val kind = toTypeKind(tree.tpe) var handlers = for (val CaseDef(pat, _, body) <- catches.reverse) yield pat match { - case Typed(Ident(nme.WILDCARD), tpt) => Triple(tpt.tpe.symbol, kind, { + case Typed(Ident(nme.WILDCARD), tpt) => (tpt.tpe.symbol, kind, { ctx: Context => ctx.bb.emit(DROP(REFERENCE(tpt.tpe.symbol))); val ctx1 = genLoad(body, ctx, kind); genLoad(finalizer, ctx1, UNIT); }) - case Ident(nme.WILDCARD) => Triple(definitions.ThrowableClass, kind, { + case Ident(nme.WILDCARD) => (definitions.ThrowableClass, kind, { ctx: Context => ctx.bb.emit(DROP(REFERENCE(definitions.ThrowableClass))) val ctx1 = genLoad(body, ctx, kind) @@ -502,7 +502,7 @@ abstract class GenICode extends SubComponent { val exception = new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false) ctx.method.addLocal(exception); - Triple(pat.symbol.tpe.symbol, kind, { + (pat.symbol.tpe.symbol, kind, { ctx: Context => ctx.bb.emit(STORE_LOCAL(exception), pat.pos); val ctx1 = genLoad(body, ctx, kind); @@ -511,7 +511,7 @@ abstract class GenICode extends SubComponent { } if (finalizer != EmptyTree) - handlers = Triple(NoSymbol, kind, { + handlers = (NoSymbol, kind, { ctx: Context => val exception = new Local(ctx.method.symbol .newVariable(finalizer.pos, unit.fresh.newName("exc")) @@ -747,7 +747,7 @@ abstract class GenICode extends SubComponent { ctx1 }, List( // tree.tpe / fun.tpe is object, which is no longer true after this transformation - Triple(NoSymbol, expectedType, exhCtx => { + (NoSymbol, expectedType, exhCtx => { exhCtx.bb.emit(LOAD_LOCAL(monitor)) exhCtx.bb.emit(MONITOR_EXIT(), tree.pos) exhCtx.bb.emit(THROW()) @@ -1277,9 +1277,9 @@ abstract class GenICode extends SubComponent { def genComparisonOp(l: Tree, r: Tree, code: Int): Unit = { // special-case reference (in)equality test for null if (code == scalaPrimitives.ID || code == scalaPrimitives.NI) { - val expr: Tree = Pair(l, r) match { - case Pair(Literal(Constant(null)), expr) => expr - case Pair(expr, Literal(Constant(null))) => expr + val expr: Tree = (l, r) match { + case (Literal(Constant(null)), expr) => expr + case (expr, Literal(Constant(null))) => expr case _ => null } if (expr ne null) { @@ -1397,15 +1397,15 @@ abstract class GenICode extends SubComponent { local } - Pair(l, r) match { + (l, r) match { // null == expr -> expr eq null - case Pair(Literal(Constant(null)), expr) => + case (Literal(Constant(null)), expr) => val ctx1 = genLoad(expr, ctx, ANY_REF_CLASS) ctx1.bb.emit(CZJUMP(thenCtx.bb, elseCtx.bb, EQ, ANY_REF_CLASS)) ctx1.bb.close // expr == null -> if(expr eq null) true else expr.equals(null) - case Pair(expr, Literal(Constant(null))) => + case (expr, Literal(Constant(null))) => val eqEqTempLocal = getTempLocal var ctx1 = genLoad(expr, ctx, ANY_REF_CLASS) ctx1.bb.emit(DUP(ANY_REF_CLASS)) @@ -1804,15 +1804,15 @@ abstract class GenICode extends SubComponent { * * <code> ctx.Try( ctx => { * ctx.bb.emit(...) // protected block - * }, Pair(definitions.ThrowableClass, + * }, (definitions.ThrowableClass, * ctx => { * ctx.bb.emit(...); // exception handler - * }), Pair(AnotherExceptionClass, + * }), (AnotherExceptionClass, * ctx => {... * } ))</code> */ def Try(body: Context => Context, - handlers: List[Triple[Symbol, TypeKind, (Context => Context)]], + handlers: List[(Symbol, TypeKind, (Context => Context))], finalizer: Tree) = { val outerCtx = this.dup val afterCtx = outerCtx.newBlock diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala index a780a233d5..9b08ac20e7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala @@ -73,7 +73,7 @@ abstract class ICodes extends AnyRef succ.predecessors.length == 1; succ.predecessors.head == b; !(m.exh.contains { (e: ExceptionHandler) => e.covers(b) && !e.covers(succ) })) - yield Pair(b, succ) + yield (b, succ) () } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 654da7762e..f185c4c4b3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -77,7 +77,7 @@ trait Members requires ICodes { /* This method applies the given function to each basic block. */ def traverseFeedBack(f: (BasicBlock, HashMap[BasicBlock, Boolean]) => Unit) = { val visited : HashMap[BasicBlock, Boolean] = new HashMap; - visited ++= blocks.elements.map(x => Pair(x, false)); + visited ++= blocks.elements.map(x => (x, false)); var blockToVisit : List[BasicBlock] = startBlock::Nil; @@ -243,7 +243,7 @@ trait Members requires ICodes { var end: Int = _ /** PC-based ranges for this local variable's visibility */ - var ranges: List[Pair[Int, Int]] = Nil + var ranges: List[(Int, Int)] = Nil override def equals(other: Any): Boolean = ( other.isInstanceOf[Local] && diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala index 00faaa19c8..1639b9fd12 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala @@ -52,12 +52,12 @@ trait TypeStacks requires ICodes { /** Return the topmost two values on the stack. It assumes the stack * is large enough. Topmost element first. */ - def pop2: Pair[TypeKind, TypeKind] = Pair(pop, pop) + def pop2: (TypeKind, TypeKind) = (pop, pop) /** Return the topmost three values on the stack. It assumes the stack * is large enough. Topmost element first. */ - def pop3: Triple[TypeKind, TypeKind, TypeKind] = Triple(pop, pop, pop) + def pop3: (TypeKind, TypeKind, TypeKind) = (pop, pop, pop) /** Drop the first n elements of the stack. */ def pop(n: Int): Unit = types = types.drop(n) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 36a2307212..71ca0959bd 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -203,7 +203,7 @@ abstract class GenJVM extends SubComponent { } def addExceptionsAttribute(sym: Symbol): Unit = { - val Pair(excs, others) = sym.attributes.partition((a => a match { + val (excs, others) = sym.attributes.partition((a => a match { case AttrInfo(ThrowsAttr, _, _) => true case _ => false })) @@ -289,7 +289,7 @@ abstract class GenJVM extends SubComponent { buf.putShort(cpool.addUtf8("value").toShort) emitElement(consts.head) } - for (val Pair(name, value) <- nvPairs) { + for (val (name, value) <- nvPairs) { buf.putShort(cpool.addUtf8(name.toString()).toShort) emitElement(value) } @@ -583,9 +583,9 @@ abstract class GenJVM extends SubComponent { * The intervals in the list have to be inclusive in the beginning and * exclusive in the end: [start, end). */ - def ranges(e: ExceptionHandler): List[Pair[Int, Int]] = { + def ranges(e: ExceptionHandler): List[(Int, Int)] = { var covered = e.covered - var ranges: List[Pair[Int, Int]] = Nil + var ranges: List[(Int, Int)] = Nil var start = -1 var end = -1 @@ -593,7 +593,7 @@ abstract class GenJVM extends SubComponent { if (! (covered contains b) ) { if (start >= 0) { // we're inside a handler range end = labels(b).getAnchor() - ranges = Pair(start, end) :: ranges + ranges = (start, end) :: ranges start = -1 } } else { @@ -612,7 +612,7 @@ abstract class GenJVM extends SubComponent { * code! */ if (start >= 0) { - ranges = Pair(start, jcode.getPC()) :: ranges; + ranges = (start, jcode.getPC()) :: ranges; } if (covered != Nil) @@ -989,10 +989,10 @@ abstract class GenJVM extends SubComponent { case SCOPE_EXIT(lv) => if (varsInBlock contains lv) { - lv.ranges = Pair(lv.start, jcode.getPC()) :: lv.ranges + lv.ranges = (lv.start, jcode.getPC()) :: lv.ranges varsInBlock -= lv } else if (b.varsInScope contains lv) { - lv.ranges = Pair(labels(b).getAnchor(), jcode.getPC()) :: lv.ranges + lv.ranges = (labels(b).getAnchor(), jcode.getPC()) :: lv.ranges b.varsInScope -= lv } else assert(false, "Illegal local var nesting: " + method) @@ -1022,10 +1022,10 @@ abstract class GenJVM extends SubComponent { // local vars that survived this basic block for (val lv <- varsInBlock) { - lv.ranges = Pair(lv.start, jcode.getPC()) :: lv.ranges + lv.ranges = (lv.start, jcode.getPC()) :: lv.ranges } for (val lv <- b.varsInScope) { - lv.ranges = Pair(labels(b).getAnchor(), jcode.getPC()) :: lv.ranges + lv.ranges = (labels(b).getAnchor(), jcode.getPC()) :: lv.ranges } } @@ -1101,67 +1101,67 @@ abstract class GenJVM extends SubComponent { abort("Unknown arithmetic primitive " + primitive) } - case Logical(op, kind) => Pair(op, kind) match { - case Pair(AND, LONG) => + case Logical(op, kind) => (op, kind) match { + case (AND, LONG) => jcode.emitLAND() - case Pair(AND, INT) => + case (AND, INT) => jcode.emitIAND() - case Pair(AND, _) => + case (AND, _) => jcode.emitIAND() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); - case Pair(OR, LONG) => + case (OR, LONG) => jcode.emitLOR() - case Pair(OR, INT) => + case (OR, INT) => jcode.emitIOR() - case Pair(OR, _) => + case (OR, _) => jcode.emitIOR() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); - case Pair(XOR, LONG) => + case (XOR, LONG) => jcode.emitLXOR() - case Pair(XOR, INT) => + case (XOR, INT) => jcode.emitIXOR() - case Pair(XOR, _) => + case (XOR, _) => jcode.emitIXOR() if (kind != BOOL) jcode.emitT2T(javaType(INT), javaType(kind)); } - case Shift(op, kind) => Pair(op, kind) match { - case Pair(LSL, LONG) => + case Shift(op, kind) => (op, kind) match { + case (LSL, LONG) => jcode.emitLSHL() - case Pair(LSL, INT) => + case (LSL, INT) => jcode.emitISHL() - case Pair(LSL, _) => + case (LSL, _) => jcode.emitISHL() jcode.emitT2T(javaType(INT), javaType(kind)) - case Pair(ASR, LONG) => + case (ASR, LONG) => jcode.emitLSHR() - case Pair(ASR, INT) => + case (ASR, INT) => jcode.emitISHR() - case Pair(ASR, _) => + case (ASR, _) => jcode.emitISHR() jcode.emitT2T(javaType(INT), javaType(kind)) - case Pair(LSR, LONG) => + case (LSR, LONG) => jcode.emitLUSHR() - case Pair(LSR, INT) => + case (LSR, INT) => jcode.emitIUSHR() - case Pair(LSR, _) => + case (LSR, _) => jcode.emitIUSHR() jcode.emitT2T(javaType(INT), javaType(kind)) } - case Comparison(op, kind) => Pair(op, kind) match { - case Pair(CMP, LONG) => jcode.emitLCMP() - case Pair(CMPL, FLOAT) => jcode.emitFCMPL() - case Pair(CMPG, FLOAT) => jcode.emitFCMPG() - case Pair(CMPL, DOUBLE) => jcode.emitDCMPL() - case Pair(CMPG, DOUBLE) => jcode.emitDCMPL() + case Comparison(op, kind) => (op, kind) match { + case (CMP, LONG) => jcode.emitLCMP() + case (CMPL, FLOAT) => jcode.emitFCMPL() + case (CMPG, FLOAT) => jcode.emitFCMPG() + case (CMPL, DOUBLE) => jcode.emitDCMPL() + case (CMPG, DOUBLE) => jcode.emitDCMPL() } case Conversion(src, dst) => @@ -1449,7 +1449,7 @@ abstract class GenJVM extends SubComponent { val index = indexOf(lv).asInstanceOf[Short] val tpe = javaType(lv.kind).getSignature() - for (val Pair(start, end) <- lv.ranges) { + for (val (start, end) <- lv.ranges) { emitEntry(name, tpe, index, start.asInstanceOf[Short], (end - start).asInstanceOf[Short]) } } @@ -1463,10 +1463,10 @@ abstract class GenJVM extends SubComponent { /** Merge adjacent ranges. */ - private def mergeEntries(ranges: List[Pair[Int, Int]]): List[Pair[Int, Int]] = - (ranges.foldLeft(Nil: List[Pair[Int, Int]]) { (collapsed: List[Pair[Int, Int]], p: Pair[Int, Int]) => Pair(collapsed, p) match { - case Pair(Nil, _) => List(p) - case Pair(Pair(s1, e1) :: rest, Pair(s2, e2)) if (e1 == s2) => Pair(s1, e2) :: rest + private def mergeEntries(ranges: List[(Int, Int)]): List[(Int, Int)] = + (ranges.foldLeft(Nil: List[(Int, Int)]) { (collapsed: List[(Int, Int)], p: (Int, Int)) => (collapsed, p) match { + case (Nil, _) => List(p) + case ((s1, e1) :: rest, (s2, e2)) if (e1 == s2) => (s1, e2) :: rest case _ => p :: collapsed }}).reverse diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 3623d125ea..8ffd4da396 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -322,7 +322,7 @@ abstract class GenMSIL extends SubComponent { } } - def getAttributeArgs(consts: List[Constant], nvPairs: List[Pair[Name, Constant]]): Array[Byte] = { + def getAttributeArgs(consts: List[Constant], nvPairs: List[(Name, Constant)]): Array[Byte] = { val buf = ByteBuffer.allocate(2048) // FIXME: this may be not enough! buf.order(ByteOrder.LITTLE_ENDIAN) buf.putShort(1.toShort) // signature @@ -384,7 +384,7 @@ abstract class GenMSIL extends SubComponent { consts foreach emitConst buf.putShort(nvPairs.length.toShort) - def emitNamedArg(nvPair: Pair[Name, Constant]): Unit = { + def emitNamedArg(nvPair: (Name, Constant)): Unit = { // the named argument is a property of the attribute (it can't be a field, since // all fields in scala are private) buf.put(0x54.toByte) @@ -881,18 +881,18 @@ abstract class GenMSIL extends SubComponent { * returns: the output blocks plus an Option containing the possibly created * new block **/ - def adaptBlocks(blocks: List[BasicBlock], exh: ExceptionHandler): Pair[List[BasicBlock], Option[BasicBlock]] = { + def adaptBlocks(blocks: List[BasicBlock], exh: ExceptionHandler): (List[BasicBlock], Option[BasicBlock]) = { def outsideTargets(block: BasicBlock, blocks: List[BasicBlock]) = { block.successors.filter(scc => !blocks.contains(scc)) } // get leaving blocks and their outside targets - def leavingBlocks(blocks: List[BasicBlock]): List[Pair[BasicBlock, List[BasicBlock]]] = { + def leavingBlocks(blocks: List[BasicBlock]): List[(BasicBlock, List[BasicBlock])] = { for {val b <- blocks val t = outsideTargets(b, blocks) - t.length != 0 } yield Pair(b, t) + t.length != 0 } yield (b, t) } - def replaceOutJumps(blocks: List[BasicBlock], leaving: List[Pair[BasicBlock, List[BasicBlock]]], exh: ExceptionHandler):Pair[List[BasicBlock], Option[BasicBlock]] = { + def replaceOutJumps(blocks: List[BasicBlock], leaving: List[(BasicBlock, List[BasicBlock])], exh: ExceptionHandler): (List[BasicBlock], Option[BasicBlock]) = { def replaceJump(block: BasicBlock, from: BasicBlock, to: BasicBlock) = block.lastInstruction match { case JUMP(where) => assert(from == where) @@ -926,12 +926,12 @@ abstract class GenMSIL extends SubComponent { val target = p._2(0) // the elemets of p._2 are all the same, checked before replaceJump(lBlock, target, jumpOutBlock) }) - Pair(blocks ::: List(jumpOutBlock), Some(jumpOutBlock)) + (blocks ::: List(jumpOutBlock), Some(jumpOutBlock)) } val leaving = leavingBlocks(blocks) if (leaving.length == 0) - Pair(blocks, None) + (blocks, None) else if (leaving.length == 1) { val outside = leaving(0)._2 assert(outside.forall(b => b == outside(0)), "exception-block leaving to multiple targets") @@ -940,7 +940,7 @@ abstract class GenMSIL extends SubComponent { else assert(firstBlockAfter(exh) == outside(0), "try/catch leaving to multiple targets: " + firstBlockAfter(exh) + ", new: " + outside(0)) val last = leaving(0)._1 - Pair(blocks.diff(List(last)) ::: List(last), None) + (blocks.diff(List(last)) ::: List(last), None) } else { val outside = leaving.flatMap(p => p._2) assert(outside.forall(b => b == outside(0)), "exception-block leaving to multiple targets") @@ -968,7 +968,7 @@ abstract class GenMSIL extends SubComponent { var singleAffectedHandler: ExceptionHandler = affectedHandlers(0) // List[ExceptionHandler] = Nil var exceptionBlock: Option[ExceptionBlock] = None affectedHandlers.foreach(h1 => { - val Pair(adaptedBlocks, newBlock) = adaptBlocks(blocksToPut.intersect(h1.blocks), singleAffectedHandler) + val (adaptedBlocks, newBlock) = adaptBlocks(blocksToPut.intersect(h1.blocks), singleAffectedHandler) newBlock match { case Some(block) => blocksToPut = blocksToPut ::: List(block) @@ -986,7 +986,7 @@ abstract class GenMSIL extends SubComponent { val excBlock = currentBlock.addExceptionBlock(singleAffectedHandler) exceptionBlock = Some(excBlock) - val Pair(tryBlocks, newBlock) = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.covered), singleAffectedHandler) + val (tryBlocks, newBlock) = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.covered), singleAffectedHandler) newBlock match { case Some(block) => @@ -998,7 +998,7 @@ abstract class GenMSIL extends SubComponent { addBlocks(tryBlocks) if (singleAffectedHandler.finalizer != null && singleAffectedHandler.finalizer != NoFinalizer) { - val Pair(blocks0, newBlock) = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.finalizer.blocks), singleAffectedHandler) + val (blocks0, newBlock) = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.finalizer.blocks), singleAffectedHandler) newBlock match { case Some(block) => blocksToPut = blocksToPut ::: List(block) @@ -1379,13 +1379,13 @@ abstract class GenMSIL extends SubComponent { } // method: implicit view(FunctionX[PType0, PType1, ...,PTypeN, ResType]):DelegateType - val Triple(isDelegateView, paramType, resType) = atPhase(currentRun.typerPhase){ + val (isDelegateView, paramType, resType) = atPhase(currentRun.typerPhase){ msym.tpe match { case MethodType(parameterTypes, resultType) if (parameterTypes.length == 1 && msym.name == nme.view_) => val isDel = definitions.isCorrespondingDelegate(resultType, parameterTypes(0)) - Triple(isDel, parameterTypes(0), resultType) - case _ => Triple(false, null, null) + (isDel, parameterTypes(0), resultType) + case _ => (false, null, null) } } if (doEmit && isDelegateView) { @@ -2206,8 +2206,8 @@ abstract class GenMSIL extends SubComponent { // create the static caller method and the delegate object - val Pair(paramTypes, returnType) = delegateType.member(nme.apply).tpe match { - case MethodType(delParams, delReturn) => Pair(delParams, delReturn) + val (paramTypes, returnType) = delegateType.member(nme.apply).tpe match { + case MethodType(delParams, delReturn) => (delParams, delReturn) case _ => abort("not a delegate type: " + delegateType) } val caller: MethodBuilder = delegateCallers.DefineMethod( diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index 354bf647a8..8b7fa9a3f3 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -53,20 +53,20 @@ abstract class ClosureElimination extends SubComponent { /** A simple peephole optimizer. */ val peephole = new PeepholeOpt( (i1, i2) => - Pair(i1, i2) match { - case Pair(CONSTANT(c), DROP(_)) => + (i1, i2) match { + case (CONSTANT(c), DROP(_)) => if (c.tag == UnitTag) Some(List(i2)) else Some(Nil); - case Pair(LOAD_LOCAL(x), STORE_LOCAL(y)) => + case (LOAD_LOCAL(x), STORE_LOCAL(y)) => if (x eq y) Some(Nil) else None - case Pair(LOAD_LOCAL(_), DROP(_)) => + case (LOAD_LOCAL(_), DROP(_)) => Some(Nil) - case Pair(LOAD_FIELD(sym, isStatic), DROP(_)) => + case (LOAD_FIELD(sym, isStatic), DROP(_)) => if (isStatic) Some(Nil) else diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 8b987cdf79..152d33354e 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -51,7 +51,7 @@ abstract class DeadCodeElimination extends SubComponent { a.run; for (val bb <- m.code.blocks.toList; - val Pair(i, pos) <- bb.toList.zipWithIndex.reverse) { + val (i, pos) <- bb.toList.zipWithIndex.reverse) { var live = a.out(bb); i match { diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 3944e1444d..744e9f9a45 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -105,7 +105,7 @@ abstract class DocGenerator extends Models { val n = tpe.typeArgs.length if (n > 0) { if (definitions.isFunctionType(tpe)) { - val Pair(ts, List(r)) = tpe.typeArgs.splitAt(n-1) + val (ts, List(r)) = tpe.typeArgs.splitAt(n-1) Text("(") ++ ( if (ts.isEmpty) NodeSeq.Empty else @@ -318,7 +318,7 @@ abstract class DocGenerator extends Models { if (!args.isEmpty) buf.append(args.map(.escapedStringValue).mkString("(", ",", ")")) if (!nvPairs.isEmpty) - for (val Pair(Pair(name, value), index) <- nvPairs.zipWithIndex) { + for (val ((name, value), index) <- nvPairs.zipWithIndex) { if (index > 0) buf.append(", ") buf.append(name).append(" = ").append(value) @@ -509,9 +509,9 @@ abstract class DocGenerator extends Models { def fullComment(mmbr: HasTree): NodeSeq = { val sym = mmbr.tree.symbol - val Pair(sym1, kind1) = - if (sym.isPrimaryConstructor) Pair(sym.owner, CONSTRUCTOR) - else Pair(sym, if (sym.isConstructor) DEF else kindOf(mmbr.tree)) + val (sym1, kind1) = + if (sym.isPrimaryConstructor) (sym.owner, CONSTRUCTOR) + else (sym, if (sym.isConstructor) DEF else kindOf(mmbr.tree)) comments.get(sym1) match { case Some(text) => comment(text, false, kind1) case None => NodeSeq.Empty @@ -739,8 +739,8 @@ abstract class DocGenerator extends Models { val decls = sym.tpe.decls.toList //compute table members once for each relevant kind val tables = for (val k <- kinds.keys.toList) - yield Pair(k, decls filter kinds(k)) - for (val Pair(k, members) <- tables; !members.isEmpty) yield + yield (k, decls filter kinds(k)) + for (val (k, members) <- tables; !members.isEmpty) yield <table cellpadding="3" class="member" summary=""> <tr> <td colspan="2" class="title">{k} Summary</td> @@ -1202,7 +1202,7 @@ abstract class DocGenerator extends Models { assert(comment0 endsWith JDOC_END) comment0 = comment0.substring(0, comment0.length() - JDOC_END.length()) val buf = new StringBuilder - type AttrDescr = Triple[String, String, StringBuilder] + type AttrDescr = (String, String, StringBuilder) val attributes = new ListBuffer[AttrDescr] var attr: AttrDescr = null val tok = new StringTokenizer(comment0, LINE_SEPARATOR) @@ -1210,12 +1210,12 @@ abstract class DocGenerator extends Models { val s = tok.nextToken.replaceFirst("\\p{Space}?\\*", "") val mat1 = pat1.matcher(s) if (mat1.matches) { - attr = Triple(mat1.group(1), null, new StringBuilder(mat1.group(2))) + attr = (mat1.group(1), null, new StringBuilder(mat1.group(2))) if (kind != CONSTRUCTOR) attributes += attr } else { val mat2 = pat2.matcher(s) if (mat2.matches) { - attr = Triple(mat2.group(1), mat2.group(2), new StringBuilder(mat2.group(3))) + attr = (mat2.group(1), mat2.group(2), new StringBuilder(mat2.group(3))) if (kind != CLASS) attributes += attr } else if (attr ne null) attr._3.append(s + LINE_SEPARATOR) @@ -1223,15 +1223,15 @@ abstract class DocGenerator extends Models { buf.append(s + LINE_SEPARATOR) } } - val exceptions = new TreeMap[String, Pair[Symbol, String]] + + val exceptions = new TreeMap[String, (Symbol, String)] + "Predef.IndexOutOfBoundsException" -> - Pair(definitions.PredefModule, "IndexOutOfBoundsException") + + (definitions.PredefModule, "IndexOutOfBoundsException") + "Predef.NoSuchElementException" -> - Pair(definitions.PredefModule, "NoSuchElementException") + + (definitions.PredefModule, "NoSuchElementException") + "Predef.NullPointerException" -> - Pair(definitions.PredefModule, "NullPointerException") + + (definitions.PredefModule, "NullPointerException") + "Predef.UnsupportedOperationException" -> - Pair(definitions.PredefModule, "UnsupportedOperationException") + (definitions.PredefModule, "UnsupportedOperationException") val body = buf.toString if (isShort) <span>{parse(body)}</span>; @@ -1247,7 +1247,7 @@ abstract class DocGenerator extends Models { else if (attr._1.equals("throws")) <code>{ exceptions.get(attr._2) match { case Some(p) => - val Pair(sym, s) = p + val (sym, s) = p val path = "../" //todo: fix path val href = path + sym.fullNameString('/') + (if (sym.isModule || sym.isModuleClass) NAME_SUFFIX_OBJECT else "") + diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 75ab5623fd..bed3aed1fe 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -1044,7 +1044,7 @@ print() //Console.println("sel:"+selector+" last"+lastSelector+" - "+(selector == lastSelector)) val next = _h.next; //res = And(mkNegate(res), toTree(node.or, selector)); - val Triple(doOptimize, coveredCases, remainingCases) = _h.optimize1() + val (doOptimize, coveredCases, remainingCases) = _h.optimize1() if(!remainingCases.isEmpty && doCheckExhaustive) { carryCovered = carryCovered ++ coveredCases // ?? if(next != null && next.or.and.isUnguardedBody) { @@ -1296,12 +1296,12 @@ print() toTree(node.or, selector.duplicate)) case ConstrPat(casted) => - def outerAlwaysEqual(left: Type, right: Type) = Pair(left,right) match { - case Pair(TypeRef(lprefix, _,_), TypeRef(rprefix,_,_)) if lprefix =:= rprefix => + def outerAlwaysEqual(left: Type, right: Type) = (left,right) match { + case (TypeRef(lprefix, _,_), TypeRef(rprefix,_,_)) if lprefix =:= rprefix => true case _ => if(settings.XprintOuterMatches.value) - cunit.warning(node.pos, "can't be sure statically that these outers are equal:"+Pair(left,right).toString) + cunit.warning(node.pos, "can't be sure statically that these outers are equal:"+(left,right).toString) false } diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala index b436dccefb..ad1a32674f 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala @@ -327,16 +327,16 @@ trait PatternNodes requires transform.ExplicitOuter { /** returns true if this tree is optimizable * throws a warning if is not exhaustive */ - def optimize1(): Triple[Boolean, SymSet, SymSet] = { + def optimize1(): (Boolean, SymSet, SymSet) = { import symtab.Flags val selType = this.getTpe if (!isSubType(selType, definitions.ScalaObjectClass.tpe)) - return Triple(false, null, emptySymbolSet) + return (false, null, emptySymbolSet) if(this.or eq null) - return Triple(false, null, emptySymbolSet) // only case _ + return (false, null, emptySymbolSet) // only case _ def checkExCoverage(tpesym:Symbol): SymSet = if(!tpesym.hasFlag(Flags.SEALED)) emptySymbolSet @@ -409,7 +409,7 @@ trait PatternNodes requires transform.ExplicitOuter { } this.forEachBranch(traverse) - return Triple(res && (cases > 2), coveredCases, remainingCases) + return (res && (cases > 2), coveredCases, remainingCases) } // def optimize } diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala index 433a33f3a7..8fa8bb6437 100644 --- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala +++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala @@ -163,7 +163,7 @@ with PatternMatchers */ { * * case .. () .. => val x = Nil; body */ - def isRegular(pats: List[CaseDef]): Pair[List[CaseDef],Boolean] = { + def isRegular(pats: List[CaseDef]): (List[CaseDef],Boolean) = { var existsReg = false var isReg = false var nilVars: List[Symbol] = null @@ -273,7 +273,7 @@ with PatternMatchers */ { res = copy.CaseDef(cdef, newt, cdef.guard, nbody) :: res } - Pair(res.reverse, existsReg) + (res.reverse, existsReg) } /** handles all translation of pattern matching @@ -284,7 +284,7 @@ with PatternMatchers */ { // // 1. is there a regular pattern? - val Pair(cases, containsReg) = isRegular(ocases) + val (cases, containsReg) = isRegular(ocases) // @todo: remove unused variables diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala index 52934c95fc..a61e9ae549 100644 --- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala +++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala @@ -67,7 +67,7 @@ class SemanticTokens(val compiler: Global) { } abstract class Actual extends HasNext with HasPrev { - def convertToGap: Pair[Int, Actual] = { + def convertToGap: (Int, Actual) = { val nextGap = next.isInstanceOf[Gap] val prevGap = prev.isInstanceOf[Gap] @@ -83,21 +83,21 @@ class SemanticTokens(val compiler: Global) { gap.next0 = next next.prev0 = gap } - new Pair(ret, gap) + (ret, gap) } else if (nextGap) { val gap = next.asInstanceOf[Gap] gap.setLength(gap.length + length) gap.prev0 = prev prev.next0 = gap - new Pair(0, gap) + (0, gap) } else { prev.next0 = next next.prev0 = prev val gap = new Gap(prev) gap.setLength(length) - new Pair(0, gap) + (0, gap) } } @@ -122,7 +122,7 @@ class SemanticTokens(val compiler: Global) { def setLength(length1: Int) = length0 = length1 // already gap - override def convertToGap: Pair[Int,Actual] = new Pair(0, this) + override def convertToGap: (Int,Actual) = (0, this) } def Process(unit: CompilationUnit) = new Process(unit) diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 7f2f08a495..8467bcb302 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -45,7 +45,7 @@ trait Definitions requires SymbolTable { var DelegateClass: Symbol = _ // System.MulticastDelegate var Delegate_scalaCallers: List[Symbol] = List() // Symbol -> (Symbol, Type): scalaCaller -> (scalaMethodSym, DelegateType) - // var Delegate_scalaCallerInfos: HashMap[Symbol, Pair[Symbol, Type]] = _ + // var Delegate_scalaCallerInfos: HashMap[Symbol, (Symbol, Type)] = _ var Delegate_scalaCallerTargets: HashMap[Symbol, Symbol] = _ // the scala value classes @@ -921,7 +921,7 @@ trait Definitions requires SymbolTable { // def addScalaCallerInfo(scalaCaller: Symbol, methSym: Symbol, delType: Type) = { // assert(Delegate_scalaCallers contains scalaCaller) - // Delegate_scalaCallerInfos += scalaCaller -> Pair(methSym, delType) + // Delegate_scalaCallerInfos += scalaCaller -> (methSym, delType) // } def addScalaCallerInfo(scalaCaller: Symbol, methSym: Symbol) = { diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index a621cab408..8ab60f8459 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -89,6 +89,8 @@ trait StdNames requires SymbolTable { def isLocalName(name: Name) = name.endsWith(LOCAL_SUFFIX) def isSetterName(name: Name) = name.endsWith(SETTER_SUFFIX) def isLocalDummyName(name: Name) = name.startsWith(LOCALDUMMY_PREFIX) + def isOpAssignmentName(name: Name) = + name.endsWith(nme.EQL) && name != nme.EQEQ && !name.endsWith(nme.USCOREEQL) /** If `name' is an expandedName, the original name. Otherwise `name' itself. * @see Symbol.expandedName @@ -182,6 +184,8 @@ trait StdNames requires SymbolTable { val AMPAMP = encode("&&") val COLONCOLON = encode("::") val PERCENT = encode("%") + val EQL = encode("=") + val USCOREEQL = encode("_=") val Nothing = newTermName("Nothing") val Null = newTermName("Null") diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 8fe03975f3..25fc9448d3 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -174,7 +174,7 @@ abstract class SymbolLoaders { } // do classes first - for (val Pair(name, file) <- classes.elements) { + for (val (name, file) <- classes.elements) { val loader = if (!file.isSourceFile) { new ClassfileLoader(file.classFile, file.sourceFile, file.sourcePath) } else { @@ -184,7 +184,7 @@ abstract class SymbolLoaders { enterClassAndModule(name, loader) } - for (val Pair(name, file) <- packages.elements) + for (val (name, file) <- packages.elements) enterPackage(name, newPackageLoader(file)) } } @@ -228,7 +228,7 @@ abstract class SymbolLoaders { } // import the CLR types contained in the package (namespace) - for (val Pair(name, typ) <- types.elements) { + for (val (name, typ) <- types.elements) { assert(namespace == typ.Namespace, typ.FullName); if (typ.IsDefined(clrTypes.SCALA_SYMTAB_ATTR, false)) { diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 66d1913608..f0b18dc5ab 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -1309,13 +1309,13 @@ trait Symbols requires SymbolTable { def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error() } - case class AttrInfo(atp: Type, args: List[Constant], assocs: List[Pair[Name, Constant]]) { + case class AttrInfo(atp: Type, args: List[Constant], assocs: List[(Name, Constant)]) { override def toString: String = atp + (if (args.isEmpty) "" else args.mkString("(", ", ", ")")) + (if (assocs.isEmpty) "" - else (assocs map { case Pair(x, y) => x+" = "+y } mkString ("{", ", ", "}"))) + else (assocs map { case (x, y) => x+" = "+y } mkString ("{", ", ", "}"))) } def cloneSymbols(syms: List[Symbol]): List[Symbol] = { diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 163683401a..4e887d93ed 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -918,7 +918,7 @@ trait Types requires SymbolTable { def apply(tp: Type): Type = { tp match { case TypeRef(_, sym, args) => - for (val Pair(tparam1, arg) <- sym.info.typeParams zip args) + for (val (tparam1, arg) <- sym.info.typeParams zip args) if (arg contains tparam) { addRef(NonExpansive, tparam, tparam1) if (arg.symbol != tparam) addRef(Expansive, tparam, tparam1) @@ -943,7 +943,7 @@ trait Types requires SymbolTable { val lastRefs = Array(refs(0), refs(1)) state = Initialized var change = false - for (val Pair(from, targets) <- refs(NonExpansive).elements) + for (val (from, targets) <- refs(NonExpansive).elements) for (val target <- targets) { var thatInfo = classInfo(target) if (thatInfo.state != Initialized) @@ -951,7 +951,7 @@ trait Types requires SymbolTable { addRefs(NonExpansive, from, thatInfo.getRefs(NonExpansive, target)) addRefs(Expansive, from, thatInfo.getRefs(Expansive, target)) } - for (val Pair(from, targets) <- refs(Expansive).elements) + for (val (from, targets) <- refs(Expansive).elements) for (val target <- targets) { var thatInfo = classInfo(target) addRefs(Expansive, from, thatInfo.getRefs(NonExpansive, target)) @@ -2012,40 +2012,40 @@ trait Types requires SymbolTable { * equivalent types. */ def isSameType(tp1: Type, tp2: Type): boolean = { - Pair(tp1, tp2) match { - case Pair(ErrorType, _) => true - case Pair(WildcardType, _) => true - case Pair(_, ErrorType) => true - case Pair(_, WildcardType) => true - - case Pair(NoType, _) => false - case Pair(NoPrefix, _) => tp2.symbol.isPackageClass - case Pair(_, NoType) => false - case Pair(_, NoPrefix) => tp1.symbol.isPackageClass - - case Pair(ThisType(sym1), ThisType(sym2)) + (tp1, tp2) match { + case (ErrorType, _) => true + case (WildcardType, _) => true + case (_, ErrorType) => true + case (_, WildcardType) => true + + case (NoType, _) => false + case (NoPrefix, _) => tp2.symbol.isPackageClass + case (_, NoType) => false + case (_, NoPrefix) => tp1.symbol.isPackageClass + + case (ThisType(sym1), ThisType(sym2)) if (sym1 == sym2) => true - case Pair(SingleType(pre1, sym1), SingleType(pre2, sym2)) + case (SingleType(pre1, sym1), SingleType(pre2, sym2)) if ((sym1 == sym2) && (pre1 =:= pre2)) => true /* - case Pair(SingleType(pre1, sym1), ThisType(sym2)) + case (SingleType(pre1, sym1), ThisType(sym2)) if (sym1.isModule && sym1.moduleClass == sym2 && pre1 =:= sym2.owner.thisType) => true - case Pair(ThisType(sym1), SingleType(pre2, sym2)) + case (ThisType(sym1), SingleType(pre2, sym2)) if (sym2.isModule && sym2.moduleClass == sym1 && pre2 =:= sym1.owner.thisType) => true */ - case Pair(ConstantType(value1), ConstantType(value2)) => + case (ConstantType(value1), ConstantType(value2)) => value1 == value2 - case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => + case (TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => sym1 == sym2 && (phase.erasedTypes || pre1 =:= pre2) && isSameTypes(args1, args2) - case Pair(RefinedType(parents1, ref1), RefinedType(parents2, ref2)) => + case (RefinedType(parents1, ref1), RefinedType(parents2, ref2)) => def isSubScope(s1: Scope, s2: Scope): boolean = s2.toList.forall { sym2 => val sym1 = s1.lookup(sym2.name) @@ -2054,31 +2054,31 @@ trait Types requires SymbolTable { } //Console.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)//DEBUG isSameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1) - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + case (MethodType(pts1, res1), MethodType(pts2, res2)) => (pts1.length == pts2.length && isSameTypes(pts1, pts2) && res1 =:= res2 && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => (tparams1.length == tparams2.length && List.forall2(tparams1, tparams2) ((p1, p2) => p1.info =:= p2.info.substSym(tparams2, tparams1)) && res1 =:= res2.substSym(tparams2, tparams1)) - case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => + case (TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => lo1 =:= lo2 && hi1 =:= hi2 - case Pair(BoundedWildcardType(bounds), _) => + case (BoundedWildcardType(bounds), _) => bounds containsType tp2 - case Pair(_, BoundedWildcardType(bounds)) => + case (_, BoundedWildcardType(bounds)) => bounds containsType tp1 - case Pair(TypeVar(_, constr1), _) => + case (TypeVar(_, constr1), _) => if (constr1.inst != NoType) constr1.inst =:= tp2 else constr1 instantiate (wildcardToTypeVarMap(tp2)) - case Pair(_, TypeVar(_, constr2)) => + case (_, TypeVar(_, constr2)) => if (constr2.inst != NoType) tp1 =:= constr2.inst else constr2 instantiate (wildcardToTypeVarMap(tp1)) - case Pair(AttributedType(_,atp), _) => + case (AttributedType(_,atp), _) => isSameType(atp, tp2) - case Pair(_, AttributedType(_,atp)) => + case (_, AttributedType(_,atp)) => isSameType(tp1, atp) case _ => if (tp1.isStable && tp2.isStable) { @@ -2127,24 +2127,24 @@ trait Types requires SymbolTable { * @return ... */ def isSubType0(tp1: Type, tp2: Type): boolean = { - Pair(tp1, tp2) match { - case Pair(ErrorType, _) => true - case Pair(WildcardType, _) => true - case Pair(_, ErrorType) => true - case Pair(_, WildcardType) => true - - case Pair(NoType, _) => false - case Pair(NoPrefix, _) => tp2.symbol.isPackageClass - case Pair(_, NoType) => false - case Pair(_, NoPrefix) => tp1.symbol.isPackageClass - - case Pair(ThisType(_), ThisType(_)) => tp1 =:= tp2 - case Pair(ThisType(_), SingleType(_, _)) => tp1 =:= tp2 - case Pair(SingleType(_, _), ThisType(_)) => tp1 =:= tp2 - case Pair(SingleType(_, _), SingleType(_, _)) => tp1 =:= tp2 - case Pair(ConstantType(_), ConstantType(_)) => tp1 =:= tp2 - - case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => + (tp1, tp2) match { + case (ErrorType, _) => true + case (WildcardType, _) => true + case (_, ErrorType) => true + case (_, WildcardType) => true + + case (NoType, _) => false + case (NoPrefix, _) => tp2.symbol.isPackageClass + case (_, NoType) => false + case (_, NoPrefix) => tp1.symbol.isPackageClass + + case (ThisType(_), ThisType(_)) => tp1 =:= tp2 + case (ThisType(_), SingleType(_, _)) => tp1 =:= tp2 + case (SingleType(_, _), ThisType(_)) => tp1 =:= tp2 + case (SingleType(_, _), SingleType(_, _)) => tp1 =:= tp2 + case (ConstantType(_), ConstantType(_)) => tp1 =:= tp2 + + case (TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => //Console.println("isSubType " + tp1 + " " + tp2);//DEBUG def isSubArgs(tps1: List[Type], tps2: List[Type], tparams: List[Symbol]): boolean = ( @@ -2172,50 +2172,50 @@ trait Types requires SymbolTable { || // Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass)) sym1 == AllRefClass && sym2.isClass && sym2 != AllClass && (sym2 isSubClass ObjectClass)) - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + case (MethodType(pts1, res1), MethodType(pts2, res2)) => (pts1.length == pts2.length && matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && (res1 <:< res2) && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => (tparams1.length == tparams2.length && List.forall2(tparams1, tparams2) ((p1, p2) => p2.info.substSym(tparams2, tparams1) <:< p1.info) && res1 <:< res2.substSym(tparams2, tparams1)) - case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => + case (TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => lo2 <:< lo1 && hi1 <:< hi2 - case Pair(BoundedWildcardType(bounds), _) => + case (BoundedWildcardType(bounds), _) => bounds.lo <:< tp2 - case Pair(_, BoundedWildcardType(bounds)) => + case (_, BoundedWildcardType(bounds)) => tp1 <:< bounds.hi - case Pair(_, TypeVar(_, constr2)) => + case (_, TypeVar(_, constr2)) => if (constr2.inst != NoType) tp1 <:< constr2.inst else { constr2.lobounds = tp1 :: constr2.lobounds; true } - case Pair(TypeVar(_, constr1), _) => + case (TypeVar(_, constr1), _) => if (constr1.inst != NoType) constr1.inst <:< tp2 else { constr1.hibounds = tp2 :: constr1.hibounds; true } - case Pair(AttributedType(_,atp1), _) => + case (AttributedType(_,atp1), _) => atp1 <:< tp2 - case Pair(_, AttributedType(_,atp2)) => + case (_, AttributedType(_,atp2)) => tp1 <:< atp2 - case Pair(_, TypeRef(pre2, sym2, args2)) + case (_, TypeRef(pre2, sym2, args2)) if sym2.isAbstractType && !(tp2 =:= tp2.bounds.lo) && (tp1 <:< tp2.bounds.lo) => true - case Pair(_, RefinedType(parents2, ref2)) => + case (_, RefinedType(parents2, ref2)) => (parents2 forall tp1.<:<) && (ref2.toList forall tp1.specializes) && (!parents2.exists(.symbol.isAbstractType) || tp1.symbol != AllRefClass) - case Pair(RefinedType(parents1, ref1), _) => + case (RefinedType(parents1, ref1), _) => parents1 exists (.<:<(tp2)) /* todo: replace following with - case Pair(ThisType(_), _) + case (ThisType(_), _) | {SingleType(_, _), _} | {ConstantType(_), _} => once patern matching bug is fixed */ - case Pair(ThisType(_), _) => tp1.singleDeref <:< tp2 - case Pair(SingleType(_, _), _) => tp1.singleDeref <:< tp2 - case Pair(ConstantType(_), _) => tp1.singleDeref <:< tp2 + case (ThisType(_), _) => tp1.singleDeref <:< tp2 + case (SingleType(_, _), _) => tp1.singleDeref <:< tp2 + case (ConstantType(_), _) => tp1.singleDeref <:< tp2 - case Pair(TypeRef(pre1, sym1, args1), _) => + case (TypeRef(pre1, sym1, args1), _) => (sym1 == AllClass && tp2 <:< AnyClass.tpe || sym1 == AllRefClass && tp2.isInstanceOf[SingletonType] && (tp1 <:< tp2.widen)) @@ -2260,21 +2260,21 @@ trait Types requires SymbolTable { } /** A function implementing <code>tp1</code> matches <code>tp2</code> */ - private def matchesType(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match { - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + private def matchesType(tp1: Type, tp2: Type): boolean = (tp1, tp2) match { + case (MethodType(pts1, res1), MethodType(pts2, res2)) => (matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && (res1 matches res2) && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => (tparams1.length == tparams2.length && (res1 matches res2.substSym(tparams2, tparams1))) - case Pair(PolyType(List(), rtp1), MethodType(List(), rtp2)) => matchesType(rtp1, rtp2) - case Pair(MethodType(List(), rtp1), PolyType(List(), rtp2)) => matchesType(rtp1, rtp2) - case Pair(PolyType(List(), rtp1), _) => matchesType(rtp1, tp2) - case Pair(_, PolyType(List(), rtp2)) => matchesType(tp1, rtp2) - case Pair(MethodType(_, _), _) => false - case Pair(PolyType(_, _), _) => false - case Pair(_, MethodType(_, _)) => false - case Pair(_, PolyType(_, _)) => false + case (PolyType(List(), rtp1), MethodType(List(), rtp2)) => matchesType(rtp1, rtp2) + case (MethodType(List(), rtp1), PolyType(List(), rtp2)) => matchesType(rtp1, rtp2) + case (PolyType(List(), rtp1), _) => matchesType(rtp1, tp2) + case (_, PolyType(List(), rtp2)) => matchesType(tp1, rtp2) + case (MethodType(_, _), _) => false + case (PolyType(_, _), _) => false + case (_, MethodType(_, _)) => false + case (_, PolyType(_, _)) => false case _ => !phase.erasedTypes || tp1 =:= tp2 } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index e36c40cfc0..40012423a9 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -193,7 +193,7 @@ abstract class ClassfileParser { in.buf(start) != CONSTANT_METHODREF && in.buf(start) != CONSTANT_INTFMETHODREF) errorBadTag(start) val ownerTpe = getClassOrArrayType(in.getChar(start + 1)) - val Pair(name, tpe) = getNameAndType(in.getChar(start + 3), ownerTpe) + val (name, tpe) = getNameAndType(in.getChar(start + 3), ownerTpe) if (name == nme.MODULE_INSTANCE_FIELD) { val index = in.getChar(start + 1) val name = getExternalName(in.getChar(starts(index) + 1)) @@ -217,9 +217,9 @@ abstract class ClassfileParser { f } - def getNameAndType(index: Int, ownerTpe: Type): Pair[Name, Type] = { + def getNameAndType(index: Int, ownerTpe: Type): (Name, Type) = { if (index <= 0 || len <= index) errorBadIndex(index) - var p = values(index).asInstanceOf[Pair[Name, Type]] + var p = values(index).asInstanceOf[(Name, Type)] if (p eq null) { val start = starts(index) if (in.buf(start) != CONSTANT_NAMEANDTYPE) errorBadTag(start) @@ -232,7 +232,7 @@ abstract class ClassfileParser { tpe = MethodType(formals, ownerTpe) } - p = Pair(name, tpe) + p = (name, tpe) } p } @@ -697,10 +697,10 @@ abstract class ClassfileParser { val attrNameIndex = in.nextChar val attrType = pool.getType(attrNameIndex) val nargs = in.nextChar - val nvpairs = new ListBuffer[Pair[Name,Constant]] + val nvpairs = new ListBuffer[(Name,Constant)] for (val i <- 0 until nargs) { val name = pool.getName(in.nextChar) - nvpairs += Pair(name, parseTaggedConstant()) + nvpairs += (name, parseTaggedConstant()) } sym.attributes = AttrInfo(attrType, List(), nvpairs.toList) :: sym.attributes } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 2dcd983b0c..5b521f12c8 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -40,7 +40,7 @@ abstract class ICodeReader extends ClassfileParser { * two IClass objects, one for static members and one * for non-static members. */ - def readClass(cls: Symbol): Pair[IClass, IClass] = { + def readClass(cls: Symbol): (IClass, IClass) = { var classFile: AbstractFile = null; var sym = cls isScalaModule = cls.isModule && !cls.hasFlag(JAVA) @@ -56,7 +56,7 @@ abstract class ICodeReader extends ClassfileParser { this.staticCode = new IClass(sym.linkedClassOfClass) parse(classFile, sym) - Pair(staticCode, instanceCode) + (staticCode, instanceCode) } /** If we're parsing a scala module, the owner of members is always @@ -86,12 +86,12 @@ abstract class ICodeReader extends ClassfileParser { } override def parseField(): Unit = { - val Pair(jflags, sym) = parseMember() + val (jflags, sym) = parseMember() getCode(jflags).addField(new IField(sym)) skipAttributes() } - private def parseMember(): Pair[Int, Symbol] = { + private def parseMember(): (Int, Symbol) = { val jflags = in.nextChar val name = pool.getName(in.nextChar) var tpe = pool.getType(in.nextChar) @@ -103,19 +103,19 @@ abstract class ICodeReader extends ClassfileParser { } if ("<clinit>" == name.toString) - Pair(jflags, NoSymbol) + (jflags, NoSymbol) else { var sym = getOwner(jflags).info.member(name).suchThat(old => old.tpe =:= tpe); if (sym == NoSymbol) sym = getOwner(jflags).info.member(newTermName(name.toString + nme.LOCAL_SUFFIX)).suchThat(old => old.tpe =:= tpe); if (sym == NoSymbol) Console.println("Could not find symbol for " + name + ": " + tpe); - Pair(jflags, sym) + (jflags, sym) } } override def parseMethod(): Unit = { - val Pair(jflags, sym) = parseMember(); + val (jflags, sym) = parseMember(); if (sym != NoSymbol) { Console.println("Parsing method " + sym.fullNameString); this.method = new IMethod(sym); @@ -568,15 +568,15 @@ abstract class ICodeReader extends ClassfileParser { if ((flags & JAVA_ACC_STATIC) != 0) staticCode else instanceCode class LinearCode { - var instrs: ListBuffer[Pair[Int, Instruction]] = new ListBuffer + var instrs: ListBuffer[(Int, Instruction)] = new ListBuffer var jmpTargets: Set[Int] = new HashSet[Int] - var locals: Map[Int, List[Pair[Local, TypeKind]]] = new HashMap() + var locals: Map[Int, List[(Local, TypeKind)]] = new HashMap() var containsDUPX = false def emit(i: Instruction) = { // Console.println(i); - instrs += Pair(pc, i) + instrs += (pc, i) if (i.isInstanceOf[DupX]) containsDUPX = true } @@ -601,7 +601,7 @@ abstract class ICodeReader extends ClassfileParser { var otherBlock: BasicBlock = null var disableJmpTarget = false - for (val Pair(pc, instr) <- instrs.elements) { + for (val (pc, instr) <- instrs.elements) { // Console.println("> " + pc + ": " + instr); if (jmpTargets contains pc) { otherBlock = blocks(pc) @@ -652,21 +652,21 @@ abstract class ICodeReader extends ClassfileParser { import analysis._ /** Abstract interpretation for one instruction. */ override def interpret(in: typeFlowLattice.Elem, i: Instruction): typeFlowLattice.Elem = { - var out = Pair(new VarBinding(in._1), new TypeStack(in._2)); + var out = (new VarBinding(in._1), new TypeStack(in._2)); val bindings = out._1; val stack = out._2; import stack.push i match { case DUP_X1 => - val Pair(one, two) = stack.pop2 + val (one, two) = stack.pop2 push(one); push(two); push(one); case DUP_X2 => - val Triple(one, two, three) = stack.pop3 + val (one, two, three) = stack.pop3 push(one); push(three); push(two); push(one); case DUP2_X1 => - val Pair(one, two) = stack.pop2 + val (one, two) = stack.pop2 if (one.isWideType) { push(one); push(two); push(one); } else { @@ -675,7 +675,7 @@ abstract class ICodeReader extends ClassfileParser { } case DUP2_X2 => - val Pair(one, two) = stack.pop2 + val (one, two) = stack.pop2 if (one.isWideType && two.isWideType) { push(one); push(two); push(one); } else if (one.isWideType) { @@ -842,10 +842,10 @@ abstract class ICodeReader extends ClassfileParser { case Some(ls) => val l = ls find { loc => loc._2 == kind } l match { - case Some(Pair(loc, _)) => loc + case Some((loc, _)) => loc case None => val l = freshLocal(kind) - locals(idx) = Pair(l, kind) :: locals(idx) + locals(idx) = (l, kind) :: locals(idx) log("Expected kind " + kind + " for local " + idx + " but only " + ls + " found. Added new local.") l @@ -853,7 +853,7 @@ abstract class ICodeReader extends ClassfileParser { case None => checkValidIndex val l = freshLocal(idx, kind, false) - locals += idx -> List(Pair(l, kind)) + locals += idx -> List((l, kind)) l } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index f1ed8f36c0..5dc137e102 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -169,15 +169,15 @@ abstract class Pickler extends SubComponent { } private def putChildren(sym: Symbol, children: List[Symbol]): unit = { - assert(putEntry(Pair(sym, children))) + assert(putEntry((sym, children))) children foreach putSymbol } private def putAnnotation(sym: Symbol, attr: AttrInfo): unit = { - assert(putEntry(Pair(sym, attr))) + assert(putEntry((sym, attr))) putType(attr.atp) for (val c <- attr.args) putConstant(c) - for (val Pair(name, c) <- attr.assocs) { putEntry(name); putConstant(c) } + for (val (name, c) <- attr.assocs) { putEntry(name); putConstant(c) } } // Phase 2 methods: Write all entries to byte array ------------------------------ @@ -279,13 +279,13 @@ abstract class Pickler extends SubComponent { LITERAL + c.tag case AttributedType(attribs, tp) => writeBody(tp) // obviously, this should be improved - case Pair(target: Symbol, attr @ AttrInfo(atp, args, assocs)) => + case (target: Symbol, attr @ AttrInfo(atp, args, assocs)) => writeRef(target) writeRef(atp) for (val c <- args) writeRef(c) - for (val Pair(name, c) <- assocs) { writeRef(name); writeRef(c) } + for (val (name, c) <- assocs) { writeRef(name); writeRef(c) } ATTRIBUTE - case Pair(target: Symbol, children: List[_]) => + case (target: Symbol, children: List[_]) => writeRef(target) for (val c <- children) writeRef(c.asInstanceOf[Symbol]) CHILDREN diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index ac1d10e9be..a338824c8b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -288,10 +288,10 @@ abstract class UnPickler { if (tag == ATTRIBUTE) { val attrType = readTypeRef() val args = new ListBuffer[Constant] - val assocs = new ListBuffer[Pair[Name, Constant]] + val assocs = new ListBuffer[(Name, Constant)] while (readIndex != end) { val argref = readNat() - if (isNameEntry(argref)) assocs += Pair(at(argref, readName), readConstantRef()) + if (isNameEntry(argref)) assocs += (at(argref, readName), readConstantRef()) else args += at(argref, readConstant) } val attr = AttrInfo(attrType, args.toList, assocs.toList) diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 4c80a56704..6d6dca90a3 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -164,16 +164,6 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } } - private def evalOnce(expr: Tree, owner: Symbol, unit: CompilationUnit) - (within: (() => Tree) => Tree): Tree = - if (treeInfo.isPureExpr(expr)) { - within(() => expr); - } else { - val temp = owner.newValue(expr.pos, unit.fresh.newName()) - .setFlag(SYNTHETIC).setInfo(expr.tpe); - Block(List(ValDef(temp, expr)), within(() => Ident(temp) setType expr.tpe)) - } - // -------- boxing/unboxing -------------------------------------------------------- override def newTyper(context: Context) = new Eraser(context) @@ -258,7 +248,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { if (pt.symbol == ArrayClass) typed { atPos(tree.pos) { - evalOnce(tree, context.owner, context.unit) { x => + gen.evalOnce(tree, context.owner, context.unit) { x => gen.mkAttributedCast( If( Apply( @@ -275,7 +265,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { else if (pt.symbol isNonBottomSubClass BoxedArrayClass) typed { atPos(tree.pos) { - evalOnce(tree, context.owner, context.unit) { x => + gen.evalOnce(tree, context.owner, context.unit) { x => gen.mkAttributedCast( If( Apply( @@ -292,7 +282,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { else if ((SeqClass isNonBottomSubClass pt.symbol) && pt.symbol != ObjectClass) typed { atPos(tree.pos) { - evalOnce(tree, context.owner, context.unit) { x => + gen.evalOnce(tree, context.owner, context.unit) { x => gen.mkAttributedCast( If( Apply( @@ -760,7 +750,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { Apply(Select(qual, cmpOp), List(gen.mkAttributedQualifier(targ.tpe))) } case RefinedType(parents, decls) if (parents.length >= 2) => - evalOnce(qual, currentOwner, unit) { + gen.evalOnce(qual, currentOwner, unit) { q => def mkIsInstanceOf(tp: Type) = copy.Apply(tree, diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index 68dd7368a9..489808c492 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -49,21 +49,21 @@ abstract class ConstantFolder { // compiler itself crashing } - private def foldUnop(op: Name, x: Constant): Constant = Pair(op, x.tag) match { - case Pair(nme.UNARY_!, BooleanTag) => Constant(!x.booleanValue) + private def foldUnop(op: Name, x: Constant): Constant = (op, x.tag) match { + case (nme.UNARY_!, BooleanTag) => Constant(!x.booleanValue) - case Pair(nme.UNARY_~ , IntTag ) => Constant(~x.intValue) - case Pair(nme.UNARY_~ , LongTag ) => Constant(~x.longValue) + case (nme.UNARY_~ , IntTag ) => Constant(~x.intValue) + case (nme.UNARY_~ , LongTag ) => Constant(~x.longValue) - case Pair(nme.UNARY_+ , IntTag ) => Constant(+x.intValue) - case Pair(nme.UNARY_+ , LongTag ) => Constant(+x.longValue) - case Pair(nme.UNARY_+ , FloatTag ) => Constant(+x.floatValue) - case Pair(nme.UNARY_+ , DoubleTag ) => Constant(+x.doubleValue) + case (nme.UNARY_+ , IntTag ) => Constant(+x.intValue) + case (nme.UNARY_+ , LongTag ) => Constant(+x.longValue) + case (nme.UNARY_+ , FloatTag ) => Constant(+x.floatValue) + case (nme.UNARY_+ , DoubleTag ) => Constant(+x.doubleValue) - case Pair(nme.UNARY_- , IntTag ) => Constant(-x.intValue) - case Pair(nme.UNARY_- , LongTag ) => Constant(-x.longValue) - case Pair(nme.UNARY_- , FloatTag ) => Constant(-x.floatValue) - case Pair(nme.UNARY_- , DoubleTag ) => Constant(-x.doubleValue) + case (nme.UNARY_- , IntTag ) => Constant(-x.intValue) + case (nme.UNARY_- , LongTag ) => Constant(-x.longValue) + case (nme.UNARY_- , FloatTag ) => Constant(-x.floatValue) + case (nme.UNARY_- , DoubleTag ) => Constant(-x.doubleValue) case _ => null } diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 0fb3d02cc5..34bafa6705 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -41,7 +41,7 @@ trait Contexts requires Analyzer { assert(pkg ne null) val qual = gen.mkAttributedStableRef(pkg) sc = sc.makeNewImport( - Import(qual, List(Pair(nme.WILDCARD, null))) + Import(qual, List((nme.WILDCARD, null))) .setSymbol(NoSymbol.newImport(NoPos).setFlag(SYNTHETIC).setInfo(ImportType(qual))) .setType(NoType)) sc.depth = sc.depth + 1 @@ -95,7 +95,7 @@ trait Contexts requires Analyzer { var checking = false var retyping = false - var savedTypeBounds: List[Pair[Symbol, Type]] = List() + var savedTypeBounds: List[(Symbol, Type)] = List() override def equals(that : Any) = that match { case that if (super.equals(that)) => true @@ -364,12 +364,12 @@ trait Contexts requires Analyzer { } def pushTypeBounds(sym: Symbol): unit = { - savedTypeBounds = Pair(sym, sym.info) :: savedTypeBounds + savedTypeBounds = (sym, sym.info) :: savedTypeBounds } def restoreTypeBounds(tp: Type): Type = { var current = tp - for (val Pair(sym, info) <- savedTypeBounds) { + for (val (sym, info) <- savedTypeBounds) { if (settings.debug.value) log("resetting " + sym + " to " + info); sym.info match { case TypeBounds(lo, hi) if (hi <:< lo && lo <:< hi) => @@ -391,10 +391,10 @@ trait Contexts requires Analyzer { private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = { val pre = imp.qual.tpe - def collect(sels: List[Pair[Name, Name]]): List[ImplicitInfo] = sels match { + def collect(sels: List[(Name, Name)]): List[ImplicitInfo] = sels match { case List() => List() - case List(Pair(nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre) - case Pair(from, to) :: sels1 => + case List((nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre) + case (from, to) :: sels1 => var impls = collect(sels1) filter (info => info.name != from) if (to != nme.WILDCARD) { val sym = imp.importedSymbol(to) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index fe0ffa65f8..85186da712 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -142,7 +142,7 @@ trait Infer requires Analyzer { val bound: Type = if (up) tparam.info.bounds.hi else tparam.info.bounds.lo //Console.println("solveOne0 "+tvar+" "+config+" "+bound);//DEBUG var cyclic = false - for (val Pair(tvar2, Pair(tparam2, variance2)) <- config) { + for (val (tvar2, (tparam2, variance2)) <- config) { if (tparam2 != tparam && ((bound contains tparam2) || up && (tparam2.info.bounds.lo =:= tparam.tpe) || @@ -178,7 +178,7 @@ trait Infer requires Analyzer { assertNonCyclic(tvar)//debug } } - for (val Pair(tvar, Pair(tparam, variance)) <- config) + for (val (tvar, (tparam, variance)) <- config) solveOne(tvar, tparam, variance) tvars map instantiate } @@ -303,13 +303,13 @@ trait Infer requires Analyzer { explainName(sym1) explainName(sym2) if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name) - Triple(sym1, sym2, name) + (sym1, sym2, name) } } val result = op - for (val Triple(sym1, sym2, name) <- patches) { + for (val (sym1, sym2, name) <- patches) { sym1.name = name sym2.name = name } @@ -693,8 +693,8 @@ trait Infer requires Analyzer { * any correspondiong non-variant type arguments of bt1 and bt2 are the same */ def isPopulated(tp1: Type, tp2: Type): boolean = { - def isConsistent(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match { - case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => + def isConsistent(tp1: Type, tp2: Type): boolean = (tp1, tp2) match { + case (TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => assert(sym1 == sym2) pre1 =:= pre2 && !(List.map3(args1, args2, sym1.typeParams) { @@ -781,9 +781,9 @@ trait Infer requires Analyzer { if (settings.debug.value) log("new alias of " + tparam + " = " + tparam.info) } else { val instType = toOrigin(tvar.constr.inst) - val Pair(loBounds, hiBounds) = - if (instType != NoType && isFullyDefined(instType)) Pair(List(instType), List(instType)) - else Pair(tvar.constr.lobounds, tvar.constr.hibounds) + val (loBounds, hiBounds) = + if (instType != NoType && isFullyDefined(instType)) (List(instType), List(instType)) + else (tvar.constr.lobounds, tvar.constr.hibounds) val lo = lub(tparam.info.bounds.lo :: loBounds map toOrigin) val hi = glb(tparam.info.bounds.hi :: hiBounds map toOrigin) if (!(lo <:< hi)) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 949740adde..6a877e9f50 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -219,7 +219,7 @@ trait Namers requires Analyzer { def skolemize(tparams: List[AbsTypeDef]): unit = { val tskolems = newTypeSkolems(tparams map (.symbol)) - for (val Pair(tparam, tskolem) <- tparams zip tskolems) tparam.symbol = tskolem + for (val (tparam, tskolem) <- tparams zip tskolems) tparam.symbol = tskolem } def applicableTypeParams(owner: Symbol): List[Symbol] = @@ -648,8 +648,8 @@ trait Namers requires Analyzer { } true } - def checkSelectors(selectors: List[Pair[Name, Name]]): unit = selectors match { - case Pair(from, to) :: rest => + def checkSelectors(selectors: List[(Name, Name)]): unit = selectors match { + case (from, to) :: rest => if (from != nme.WILDCARD && base != ErrorType) { if (base.member(from) == NoSymbol && base.member(from.toTypeName) == NoSymbol) context.error(tree.pos, from.decode + " is not a member of " + expr); @@ -747,8 +747,8 @@ trait Namers requires Analyzer { else if (isFunctionType(tp) && (!isFunctionType(elemtp) || tp.typeArgs.length > elemtp.typeArgs.length)) result = true - else Pair(tp, elemtp) match { - case Pair(TypeRef(pre, sym, args), TypeRef(elempre, elemsym, elemargs)) => + else (tp, elemtp) match { + case (TypeRef(pre, sym, args), TypeRef(elempre, elemsym, elemargs)) => if ((sym == elemsym) && (pre =:= elempre) && (args.length == elemargs.length)) result = List.forall2(elemargs, args) (isContainedIn) case _ => diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 7a06d45cb5..5d377b5a12 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -100,12 +100,12 @@ abstract class RefChecks extends InfoTransform { else ""))) } - def overridesType(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match { - case Pair(MethodType(List(), rtp1), PolyType(List(), rtp2)) => + def overridesType(tp1: Type, tp2: Type): boolean = (tp1, tp2) match { + case (MethodType(List(), rtp1), PolyType(List(), rtp2)) => rtp1 <:< rtp2 - case Pair(PolyType(List(), rtp1), MethodType(List(), rtp2)) => + case (PolyType(List(), rtp1), MethodType(List(), rtp2)) => rtp1 <:< rtp2 - case Pair(TypeRef(_, sym, _), _) if (sym.isModuleClass) => + case (TypeRef(_, sym, _), _) if (sym.isModuleClass) => overridesType(PolyType(List(), tp1), tp2) case _ => tp1 <:< tp2 @@ -375,7 +375,7 @@ abstract class RefChecks extends InfoTransform { def validateVarianceArgs(tps: List[Type], variance: int, tparams: List[Symbol]): unit = (tps zip tparams) foreach { - case Pair(tp, tparam) => validateVariance(tp, variance * tparam.variance) + case (tp, tparam) => validateVariance(tp, variance * tparam.variance) } validateVariance(all, variance) diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 51ed171076..61bd300472 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -36,7 +36,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT class SuperAccTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { private var validCurrentOwner = true - private var accDefs: List[Pair[Symbol, ListBuffer[Tree]]] = List() + private var accDefs: List[(Symbol, ListBuffer[Tree])] = List() private def accDefBuf(clazz: Symbol) = accDefs.dropWhile(._1.!=(clazz)).head._2 @@ -63,7 +63,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT super.transform(tree) case Template(parents, body) => val ownAccDefs = new ListBuffer[Tree]; - accDefs = Pair(currentOwner, ownAccDefs) :: accDefs; + accDefs = (currentOwner, ownAccDefs) :: accDefs; // ugly hack... normally, the following line should not be // necessary, the 'super' method taking care of that. but because diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index bd534813c2..9c4dca6e59 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -81,7 +81,7 @@ trait SyntheticMethods requires Analyzer { //val retTpe = lub(accs map (.tpe.resultType)) val method = syntheticMethod(nme.element, FINAL, MethodType(List(IntClass.tpe), AnyClass.tpe/*retTpe*/)) typed(DefDef(method, vparamss => Match(Ident(vparamss.head.head), { - (for(val Pair(sym,i) <- accs.zipWithIndex) yield { + (for(val (sym,i) <- accs.zipWithIndex) yield { CaseDef(Literal(Constant(i)),EmptyTree, Ident(sym)) }):::List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Throw(New(TypeTree(IndexOutOfBoundsExceptionClass.tpe), List(List( diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 46f3573edb..d6e833b916 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -275,7 +275,7 @@ trait Typers requires Analyzer { def checkParamsConvertible(pos: PositionType, tpe: Type): unit = tpe match { case MethodType(formals, restpe) => if (formals.exists(.symbol.==(ByNameParamClass)) && formals.length != 1) - error(pos, "methods with `=>'-parameter can be converted to function values only if they are unary") + error(pos, "methods with `=>'-parameter can be converted to function values only if they take no other parameters") if (formals exists (.symbol.==(RepeatedParamClass))) error(pos, "methods with `*'-parameters cannot be converted to function values"); checkParamsConvertible(pos, restpe) @@ -464,7 +464,7 @@ trait Typers requires Analyzer { else tree } - /** The member with givne name of given qualifier tree */ + /** The member with given name of given qualifier tree */ def member(qual: Tree, name: Name) = qual.tpe match { case ThisType(clazz) if (context.enclClass.owner.ownerChain contains clazz) => qual.tpe.member(name) @@ -473,6 +473,22 @@ trait Typers requires Analyzer { else qual.tpe.nonLocalMember(name) } + def silent(op: Typer => Tree): AnyRef /* in fact, TypeError or Tree */ = try { + if (context.reportGeneralErrors) { + val context1 = context.makeSilent(context.reportAmbiguousErrors) + context1.undetparams = context.undetparams + val typer1 = newTyper(context1) + val result = op(typer1) + context.undetparams = context1.undetparams + result + } else { + op(this) + } + } catch { + case ex: CyclicReference => throw ex + case ex: TypeError => ex + } + /** Perform the following adaptations of expression, pattern or type `tree' wrt to * given mode `mode' and given prototype `pt': * (0) Convert expressions with constant types to literals @@ -979,21 +995,21 @@ trait Typers requires Analyzer { */ def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree): unit = { if (settings.debug.value) log("computing param aliases for "+clazz+":"+clazz.primaryConstructor.tpe+":"+rhs);//debug - def decompose(call: Tree): Pair[Tree, List[Tree]] = call match { + def decompose(call: Tree): (Tree, List[Tree]) = call match { case Apply(fn, args) => - val Pair(superConstr, args1) = decompose(fn) + val (superConstr, args1) = decompose(fn) val formals = fn.tpe.paramTypes val args2 = if (formals.isEmpty || formals.last.symbol != RepeatedParamClass) args else args.take(formals.length - 1) ::: List(EmptyTree) if (args2.length != formals.length) assert(false, "mismatch " + clazz + " " + formals + " " + args2);//debug - Pair(superConstr, args1 ::: args2) + (superConstr, args1 ::: args2) case Block(stats, expr) => decompose(stats.head) case _ => - Pair(call, List()) + (call, List()) } - val Pair(superConstr, superArgs) = decompose(rhs) + val (superConstr, superArgs) = decompose(rhs) assert(superConstr.symbol ne null)//debug if (superConstr.symbol.isPrimaryConstructor) { val superClazz = superConstr.symbol.owner @@ -1226,16 +1242,16 @@ trait Typers requires Analyzer { def typedFunction(fun: Function, mode: int, pt: Type): Tree = { val codeExpected = !forCLDC && !forMSIL && (pt.symbol isNonBottomSubClass CodeClass) - def decompose(pt: Type): Triple[Symbol, List[Type], Type] = + def decompose(pt: Type): (Symbol, List[Type], Type) = if (isFunctionType(pt) || pt.symbol == PartialFunctionClass && fun.vparams.length == 1 && fun.body.isInstanceOf[Match]) - Triple(pt.symbol, pt.typeArgs.init, pt.typeArgs.last) + (pt.symbol, pt.typeArgs.init, pt.typeArgs.last) else - Triple(FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType) + (FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType) - val Triple(clazz, argpts, respt) = decompose(if (codeExpected) pt.typeArgs.head else pt) + val (clazz, argpts, respt) = decompose(if (codeExpected) pt.typeArgs.head else pt) if (fun.vparams.length != argpts.length) errorTree(fun, "wrong number of parameters; expected = " + argpts.length) @@ -1388,11 +1404,9 @@ trait Typers requires Analyzer { val formals = formalTypes(formals0, args.length) var args1 = actualArgs(tree.pos, args, formals.length) if (args1.length != args.length) { - try { - silentTypedApply(tree, fun, args1, mode, pt) - } catch { - case ex: TypeError => - errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) + silent(.typedApply(tree, fun, args1, mode, pt)) match { + case t: Tree => t + case ex => errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) } } else if (formals.length != args1.length) { errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) @@ -1511,14 +1525,14 @@ trait Typers requires Analyzer { val oldArgType = arg.tpe if (!isApplicable(List(), unappType, List(arg.tpe), WildcardType)) { //Console.println("UNAPP: need to typetest, arg.tpe = "+arg.tpe+", unappType = "+unappType) - def freshArgType(tp: Type): Pair[Type, List[Symbol]] = tp match { + def freshArgType(tp: Type): (Type, List[Symbol]) = tp match { case MethodType(formals, restpe) => - Pair(formals(0), List()) + (formals(0), List()) case PolyType(tparams, restype) => val tparams1 = cloneSymbols(tparams) - Pair(freshArgType(restype)._1.substSym(tparams, tparams1), tparams1) + (freshArgType(restype)._1.substSym(tparams, tparams1), tparams1) } - val Pair(unappFormal, freeVars) = freshArgType(unappType) + val (unappFormal, freeVars) = freshArgType(unappType) val context1 = context.makeNewScope(context.tree, context.owner) freeVars foreach context1.scope.enter val typer1 = new Typer(context1) @@ -1548,18 +1562,6 @@ trait Typers requires Analyzer { } } - def silentTypedApply(tree: Tree, fun: Tree, args: List[Tree], mode: int, pt: Type): Tree = - if (context.reportGeneralErrors) { - val context1 = context.makeSilent(context.reportAmbiguousErrors) - context1.undetparams = context.undetparams - val typer1 = newTyper(context1) - val result = typer1.typedApply(tree, fun, args, mode, pt) - context.undetparams = context1.undetparams - result - } else { - typedApply(tree, fun, args, mode, pt) - } - def typedAnnotation(constr: Tree, elements: List[Tree]): AttrInfo = { var attrError: Boolean = false; def error(pos: PositionType, msg: String): Null = { @@ -1591,12 +1593,12 @@ trait Typers requires Analyzer { error(ntree.pos, "duplicate value for element " + name) } else { names -= sym - Pair(sym.name, getConstant(typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType))) + (sym.name, getConstant(typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType))) } } } for (val name <- names) { - if (!name.attributes.contains(Triple(AnnotationDefaultAttr.tpe, List(), List()))) { + if (!name.attributes.contains((AnnotationDefaultAttr.tpe, List(), List()))) { error(constr.pos, "attribute " + tpt.tpe.symbol.fullNameString + " is missing element " + name.name) } } @@ -1651,10 +1653,8 @@ trait Typers requires Analyzer { try { newTyper(c).typedArgs(args, mode) } catch { - case ex: TypeError => - null - case t : Throwable => - throw t + case ex: TypeError => + null } } @@ -1665,58 +1665,70 @@ trait Typers requires Analyzer { * @param args ... * @return ... */ - def tryTypedApply(fun: Tree, args: List[Tree]): Tree = try { - silentTypedApply(tree, fun, args, mode, pt) - } catch { - case ex: CyclicReference => - throw ex - case ex: TypeError => - val Select(qual, name) = fun - val args1 = tryTypedArgs(args, ex) - val qual1 = - if ((args1 ne null) && !pt.isError) { - def templateArgType(arg: Tree) = - new BoundedWildcardType(mkTypeBounds(arg.tpe, AnyClass.tpe)) - adaptToMember(qual, name, MethodType(args1 map templateArgType, pt)) - } else qual - if (qual1 ne qual) { - val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos - typed1(tree1, mode | SNDTRYmode, pt) - } else { - reportTypeError(tree.pos, ex) - setError(tree) - } - case t => throw t; - } -/* - /** Try to apply function to arguments; if it does not work try to insert an implicit - * conversion - */ - def tryTypedApply(fun: Tree, args: List[Tree]): Tree = { - val reportGeneralErrors = context.reportGeneralErrors - val undetparams = context.undetparams - try { - context.reportGeneralErrors = false - typedApply(tree, fun, args, mode, pt) - } catch { - case ex: CyclicReference => - throw ex + def tryTypedApply(fun: Tree, args: List[Tree]): Tree = + silent(.typedApply(tree, fun, args, mode, pt)) match { + case t: Tree => + t case ex: TypeError => val Select(qual, name) = fun - context.undetparams = undetparams - val args1 = tryTypedArgs(args map (arg => UnTyper.apply(arg))) - context.reportGeneralErrors = reportGeneralErrors - def templateArgType(arg: Tree) = - new BoundedWildcardType(TypeBounds(arg.tpe, AnyClass.tpe)) - val qual1 = if ((args1 eq null) || pt.isError) qual - else adaptToMember(qual, name, MethodType(args1 map templateArgType, pt)) - val tree1 = Apply(Select(qual1, name) setPos fun.pos, args map (arg => UnTyper.apply(arg))) setPos tree.pos - typed1(tree1, mode | SNDTRYmode, pt) - } finally { - context.reportGeneralErrors = reportGeneralErrors + val args1 = tryTypedArgs(args, ex) + val qual1 = + if ((args1 ne null) && !pt.isError) { + def templateArgType(arg: Tree) = + new BoundedWildcardType(mkTypeBounds(arg.tpe, AnyClass.tpe)) + adaptToMember(qual, name, MethodType(args1 map templateArgType, pt)) + } else qual + if (qual1 ne qual) { + val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos + typed1(tree1, mode | SNDTRYmode, pt) + } else { + reportTypeError(tree.pos, ex) + setError(tree) + } + } + + def convertToAssignment(fun: Tree, qual: Tree, name: Name, args: List[Tree], ex: TypeError): Tree = { + val prefix = name.subName(0, name.length - nme.EQL.length) + def mkAssign(vble: Tree): Tree = + Assign( + vble, + Apply(Select(vble.duplicate, prefix) setPos fun.pos, args) setPos tree.pos + ) setPos tree.pos + val tree1 = qual match { + case Select(qualqual, vname) => + gen.evalOnce(qualqual, context.owner, context.unit) { qq => + mkAssign(Select(qq(), vname) setPos qual.pos) + } + case Apply(Select(table, nme.apply), indices) => + gen.evalOnceAll(table :: indices, context.owner, context.unit) { ts => + val tab = ts.head + val is = ts.tail + Apply( + Select(tab(), nme.update) setPos table.pos, + ((is map (i => i())) ::: List( + Apply( + Select( + Apply( + Select(tab(), nme.apply) setPos table.pos, + is map (i => i())) setPos qual.pos, + prefix) setPos fun.pos, + args) setPos tree.pos) + ) + ) setPos tree.pos + } + case Ident(_) => + mkAssign(qual) + } + if (settings.debug.value) log("retry assign: "+tree1) + silent(.typed1(tree1, mode, pt)) match { + case t: Tree => + t + case _ => + reportTypeError(tree.pos, ex) + setError(tree) } } -*/ + /** Attribute a selection where <code>tree</code> is <code>qual.name</code>. * <code>qual</code> is already attributed. * @@ -2198,29 +2210,44 @@ trait Typers requires Analyzer { typed1(tree, mode & ~PATTERNmode | EXPRmode, pt) } else { val funpt = if ((mode & PATTERNmode) != 0) pt else WildcardType - var fun1 = typed(fun, funMode(mode), funpt) - if (stableApplication) fun1 = stabilizeFun(fun1, mode, pt) - // if function is overloaded, filter all alternatives that match - // number of arguments and expected result type. - if (util.Statistics.enabled) appcnt = appcnt + 1 - val ret = if (phase.id <= currentRun.typerPhase.id && - fun1.isInstanceOf[Select] && - !fun1.tpe.isInstanceOf[ImplicitMethodType] && - ((fun1.symbol eq null) || !fun1.symbol.isConstructor) && - (mode & (EXPRmode | SNDTRYmode)) == EXPRmode) tryTypedApply(fun1, args) - else { - typedApply(tree, fun1, args, mode, pt) + silent(.typed(fun, funMode(mode), funpt)) match { + case fun1: Tree => + val fun2 = if (stableApplication) stabilizeFun(fun1, mode, pt) else fun1 + if (util.Statistics.enabled) appcnt = appcnt + 1 + if (phase.id <= currentRun.typerPhase.id && + fun2.isInstanceOf[Select] && + !fun2.tpe.isInstanceOf[ImplicitMethodType] && + ((fun2.symbol eq null) || !fun2.symbol.isConstructor) && + (mode & (EXPRmode | SNDTRYmode)) == EXPRmode) tryTypedApply(fun2, args) + else { + typedApply(tree, fun2, args, mode, pt) + } + case ex: TypeError => + fun match { + case Select(qual, name) => + val qual1 = typedQualifier(qual) + if ((mode & PATTERNmode) == 0 && + nme.isOpAssignmentName(name) && + treeInfo.isVariableOrGetter(qual1)) { + convertToAssignment(fun, qual1, name, args, ex) + } else { + reportTypeError(fun.pos, ex) + setError(tree) + } + case _ => + reportTypeError(fun.pos, ex) + setError(tree) + } } - ret } case Super(qual, mix) => - val Pair(clazz, selftype) = + val (clazz, selftype) = if (tree.symbol != NoSymbol) { - Pair(tree.symbol, tree.symbol.thisType) + (tree.symbol, tree.symbol.thisType) } else { val clazzContext = qualifyingClassContext(tree, qual) - Pair(clazzContext.owner, clazzContext.prefix) + (clazzContext.owner, clazzContext.prefix) } if (clazz == NoSymbol) setError(tree) else { @@ -2246,12 +2273,12 @@ trait Typers requires Analyzer { } case This(qual) => - val Pair(clazz, selftype) = + val (clazz, selftype) = if (tree.symbol != NoSymbol) { - Pair(tree.symbol, tree.symbol.thisType) + (tree.symbol, tree.symbol.thisType) } else { val clazzContext = qualifyingClassContext(tree, qual) - Pair(clazzContext.owner, clazzContext.prefix) + (clazzContext.owner, clazzContext.prefix) } if (clazz == NoSymbol) setError(tree) else { diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index 43e394cd91..1e112d320f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -53,7 +53,7 @@ trait Variances { * `tps' which correspond to formal type parameters `tparams1'. */ def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol): int = { var v: int = VARIANCES; - for (val Pair(tp, tparam1) <- tps zip tparams1) { + for (val (tp, tparam1) <- tps zip tparams1) { val v1 = varianceInType(tp)(tparam); v = v & (if (tparam1.isCovariant) v1 else if (tparam1.isContravariant) flip(v1) diff --git a/src/library/scala/AllRef$.scala b/src/library/scala/AllRef$.scala index b0dc552b05..de1fa94bff 100644 --- a/src/library/scala/AllRef$.scala +++ b/src/library/scala/AllRef$.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id$ +// $Id: AllRef$.scala 9262 2006-11-14 17:29:59 +0000 (Tue, 14 Nov 2006) mihaylov $ package scala diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala index 81f82ab662..79e680ae39 100644 --- a/src/library/scala/BigInt.scala +++ b/src/library/scala/BigInt.scala @@ -175,9 +175,9 @@ class BigInt(val bigInteger: BigInteger) extends runtime.BoxedNumber { /** Returns a pair of two BigInts containing (this / that) and (this % that). */ - def /% (that: BigInt): Pair[BigInt, BigInt] = { + def /% (that: BigInt): (BigInt, BigInt) = { val dr = this.bigInteger.divideAndRemainder(that.bigInteger) - Pair(new BigInt(dr(0)), new BigInt(dr(1))) + (new BigInt(dr(0)), new BigInt(dr(1))) } /** Leftshift of BigInt diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala index ea2968fc03..d2f926a652 100644 --- a/src/library/scala/Console.scala +++ b/src/library/scala/Console.scala @@ -272,9 +272,9 @@ object Console { * @param format ... * @return ... */ - def readf2(format: String): Pair[Any, Any] = { + def readf2(format: String): (Any, Any) = { val res = readf(format) - Pair(res.head, res.tail.head) + (res.head, res.tail.head) } /** Read in some structured input, specified by a format specifier. @@ -285,9 +285,9 @@ object Console { * @param format ... * @return ... */ - def readf3(format: String): Triple[Any, Any, Any] = { + def readf3(format: String): (Any, Any, Any) = { val res = readf(format) - Triple(res.head, res.tail.head, res.tail.tail.head) + (res.head, res.tail.head, res.tail.tail.head) } private def textComponents(a: Array[AnyRef]): List[Any] = { diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala index 4dd5d46433..1a3a022ca6 100644 --- a/src/library/scala/Iterator.scala +++ b/src/library/scala/Iterator.scala @@ -349,9 +349,9 @@ trait Iterator[+A] { * and <code>b<sub>i</sub></code> are the elements from iterator * <code>that</code>. */ - def zip[B](that: Iterator[B]) = new Iterator[Pair[A, B]] { + def zip[B](that: Iterator[B]) = new Iterator[(A, B)] { def hasNext = Iterator.this.hasNext && that.hasNext - def next = Pair(Iterator.this.next, that.next) + def next = (Iterator.this.next, that.next) } /** Return an iterator that pairs each element of this iterator @@ -362,11 +362,11 @@ trait Iterator[+A] { * {a<sub>1</sub>,1}...</code> where <code>a<sub>i</sub></code> * are the elements from this iterator. */ - def zipWithIndex = new Iterator[Pair[A, int]] { + def zipWithIndex = new Iterator[(A, int)] { var idx = 0 def hasNext = Iterator.this.hasNext def next = { - val ret = Pair(Iterator.this.next, idx) + val ret = (Iterator.this.next, idx) idx = idx + 1 ret } @@ -542,7 +542,7 @@ trait Iterator[+A] { * * @return a pair of iterators */ - def duplicate: Pair[Iterator[A], Iterator[A]] = { + def duplicate: (Iterator[A], Iterator[A]) = { var xs: List[A] = Nil var ahead: Iterator[A] = null class Partner extends Iterator[A] { @@ -572,7 +572,7 @@ trait Iterator[+A] { } } ahead = new Partner - Pair(ahead, new Partner) + (ahead, new Partner) } /** Fills the given array <code>xs</code> with the elements of diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index b45292caa2..71109f2fe8 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -140,7 +140,7 @@ object List { * @param xs the list of pairs to unzip * @return a pair of lists: the first list in the pair contains the list */ - def unzip[a,b](xs: List[Pair[a,b]]): Pair[List[a], List[b]] = { + def unzip[a,b](xs: List[(a,b)]): (List[a], List[b]) = { val b1 = new ListBuffer[a] val b2 = new ListBuffer[b] var xc = xs @@ -149,7 +149,7 @@ object List { b2 += xc.head._2 xc = xc.tail } - Pair(b1.toList, b2.toList) + (b1.toList, b2.toList) } /** Converts an iterator to a list @@ -590,7 +590,7 @@ sealed abstract class List[+a] extends Seq[a] { * @return a pair of lists composed of the first <code>n</code> * elements, and the other elements. */ - def splitAt(n: Int): Pair[List[a], List[a]] = { + def splitAt(n: Int): (List[a], List[a]) = { val b = new ListBuffer[a] var i = 0 var these = this @@ -599,7 +599,7 @@ sealed abstract class List[+a] extends Seq[a] { b += these.head these = these.tail } - Pair(b.toList, these) + (b.toList, these) } /** Returns the longest prefix of this list whose elements satisfy @@ -637,19 +637,19 @@ sealed abstract class List[+a] extends Seq[a] { * @return a pair consisting of the longest prefix of the list whose * elements all satisfy <code>p</code>, and the rest of the list. */ - def span(p: a => Boolean): Pair[List[a], List[a]] = { + def span(p: a => Boolean): (List[a], List[a]) = { val b = new ListBuffer[a] var these = this while (!these.isEmpty && p(these.head)) { b += these.head these = these.tail } - Pair(b.toList, these) + (b.toList, these) } /** Like <code>span</code> but with the predicate inverted. */ - def break(p: a => Boolean): Pair[List[a], List[a]] = span { x => !p(x) } + def break(p: a => Boolean): (List[a], List[a]) = span { x => !p(x) } /** Returns the <code>n</code>-th element of this list. The first element * (head of the list) is at position 0. @@ -752,7 +752,7 @@ sealed abstract class List[+a] extends Seq[a] { * The relative order of the elements in the sub-lists is the * same as in the original list. */ - def partition(p: a => Boolean): Pair[List[a], List[a]] = { + def partition(p: a => Boolean): (List[a], List[a]) = { val btrue = new ListBuffer[a] val bfalse = new ListBuffer[a] var these = this @@ -760,7 +760,7 @@ sealed abstract class List[+a] extends Seq[a] { (if (p(these.head)) btrue else bfalse) += these.head these = these.tail } - Pair(btrue.toList, bfalse.toList) + (btrue.toList, bfalse.toList) } /** <p> @@ -804,7 +804,7 @@ sealed abstract class List[+a] extends Seq[a] { else y::z::x::acc case hd1::hd2::hd3::tail => { val List(x, y, z) = sort_1(hd1::hd2::hd3::Nil, Nil) - val Pair(small, large) = tail.partition((e2) => lt(e2, y)) + val (small, large) = tail.partition((e2) => lt(e2, y)) sort_1(x::small, y::sort_1(z::large, acc)) } } @@ -828,7 +828,7 @@ sealed abstract class List[+a] extends Seq[a] { else y::z::x::Nil case hd1::hd2::hd3::tail => { val List(x, y, z) = sort_1(hd1::hd2::hd3::Nil, Nil) - val Pair(small,large) = tail.partition((e2) => lt(e2, y)) + val (small,large) = tail.partition((e2) => lt(e2, y)) sort_1(x::small, y::sort_1(z::large, Nil)); } } @@ -999,12 +999,12 @@ sealed abstract class List[+a] extends Seq[a] { * <code>List(a<sub>0</sub>, ..., a<sub>m</sub>) * zip List(b<sub>0</sub>, ..., b<sub>n</sub>)</code> is invoked. */ - def zip[b](that: List[b]): List[Pair[a,b]] = { - val b = new ListBuffer[Pair[a, b]] + def zip[b](that: List[b]): List[(a,b)] = { + val b = new ListBuffer[(a, b)] var these = this var those = that while (!these.isEmpty && !those.isEmpty) { - b += Pair(these.head, those.head) + b += (these.head, those.head) these = these.tail those = those.tail } @@ -1018,12 +1018,12 @@ sealed abstract class List[+a] extends Seq[a] { * where <code>a<sub>i</sub></code> are the elements of this list. */ def zipWithIndex = { - val b = new ListBuffer[Pair[a,int]] + val b = new ListBuffer[(a,int)] var these = this var idx = 0 while(!these.isEmpty) { - b += Pair(these.head, idx) + b += (these.head, idx) these = these.tail idx = idx + 1 } @@ -1050,21 +1050,21 @@ sealed abstract class List[+a] extends Seq[a] { * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is * invoked where <code>m > n</code>. */ - def zipAll[b, c >: a, d >: b](that: List[b], thisElem: c, thatElem: d): List[Pair[c,d]] = { - val b = new ListBuffer[Pair[c, d]] + def zipAll[b, c >: a, d >: b](that: List[b], thisElem: c, thatElem: d): List[(c,d)] = { + val b = new ListBuffer[(c, d)] var these = this var those = that while (!these.isEmpty && !those.isEmpty) { - b += Pair(these.head, those.head) + b += (these.head, those.head) these = these.tail those = those.tail } while (!these.isEmpty) { - b += Pair(these.head, thatElem) + b += (these.head, thatElem) these = these.tail } while (!those.isEmpty) { - Pair(thisElem, those.head) + (thisElem, those.head) those = those.tail } b.toList diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala index fe140f2598..48273ee62b 100644 --- a/src/library/scala/Stream.scala +++ b/src/library/scala/Stream.scala @@ -53,11 +53,11 @@ object Stream { } } - def unapply[a](str: Stream[a]): Option[Pair[a,Stream[a]]] = + def unapply[a](str: Stream[a]): Option[(a,Stream[a])] = if(str.isEmpty) None else - Some(Pair(str.head, str.tail)) + Some((str.head, str.tail)) } /** A stream containing all elements of a given iterator, in the order they are produced. diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index c02c195086..1d00aaf44b 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -35,7 +35,7 @@ import Predef._ * @author Martin Odersky * @version 1.2, 31/12/2006 */ -trait Map[A, +B] extends PartialFunction[A, B] with Iterable[Pair[A, B]] { +trait Map[A, +B] extends PartialFunction[A, B] with Iterable[(A, B)] { /** Compute the number of key-to-value mappings. * @@ -125,7 +125,7 @@ trait Map[A, +B] extends PartialFunction[A, B] with Iterable[Pair[A, B]] { override def equals(that: Any): Boolean = that match { case other: Map[a, b] => this.size == other.size && this.elements.forall { - case Pair(key, value) => other.get(key.asInstanceOf[a]) match { + case (key, value) => other.get(key.asInstanceOf[a]) match { case None => false case Some(otherval) => value == otherval } diff --git a/src/library/scala/collection/MapProxy.scala b/src/library/scala/collection/MapProxy.scala index 2585f24c7d..617c3bc79a 100644 --- a/src/library/scala/collection/MapProxy.scala +++ b/src/library/scala/collection/MapProxy.scala @@ -20,7 +20,7 @@ package scala.collection * @author Matthias Zenger * @version 1.0, 21/07/2003 */ -trait MapProxy[A, +B] extends Map[A, B] with IterableProxy[Pair[A, B]] { +trait MapProxy[A, +B] extends Map[A, B] with IterableProxy[(A, B)] { def self: Map[A, B] diff --git a/src/library/scala/collection/immutable/EmptyMap.scala b/src/library/scala/collection/immutable/EmptyMap.scala index d6d4b8aec3..75b71338ee 100755 --- a/src/library/scala/collection/immutable/EmptyMap.scala +++ b/src/library/scala/collection/immutable/EmptyMap.scala @@ -25,7 +25,7 @@ class EmptyMap[A, +B] extends Map[A, B] { def get(key: A): Option[B] = None - def elements: Iterator[Pair[A, B]] = Iterator.empty + def elements: Iterator[(A, B)] = Iterator.empty def empty[C]: Map[A, C] = new EmptyMap[A, C] diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index b708c15203..34a4a5ed1c 100755 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -25,7 +25,7 @@ object HashMap { /** The canonical factory for this type */ - def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A, B](elems: (A, B)*) = empty[A, B] ++ elems } @serializable @@ -92,7 +92,7 @@ class HashMap[A, B] extends Map[A,B] with mutable.HashTable[A] { def elements = { makeCopyIfUpdated() - entries map {e => Pair(e.key, getValue(e))} + entries map {e => (e.key, getValue(e))} } private def getValue(e: Entry) = diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index 9d67709ae1..c0c20a32e7 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -25,7 +25,7 @@ object ListMap { /** The canonical factory for this type */ - def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A, B](elems: (A, B)*) = empty[A, B] ++ elems } /** This class implements immutable maps using a list-based data @@ -80,13 +80,13 @@ class ListMap[A, +B] extends Map[A, B] { /** Returns an iterator over key-value pairs. */ - def elements: Iterator[Pair[A,B]] = - new Iterator[Pair[A,B]] { + def elements: Iterator[(A,B)] = + new Iterator[(A,B)] { var self: ListMap[A,B] = ListMap.this def hasNext = !self.isEmpty - def next: Pair[A,B] = + def next: (A,B) = if (!hasNext) throw new NoSuchElementException("next on empty iterator") - else { val res = Pair(self.key, self.value); self = self.next; res } + else { val res = (self.key, self.value); self = self.next; res } }.toList.reverse.elements protected def key: A = throw new NoSuchElementException("empty map") diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index 1fe98d41ea..4c9bc33d05 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -41,7 +41,7 @@ object Map { /** The canonical factory for this type */ - def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A, B](elems: (A, B)*) = empty[A, B] ++ elems } trait Map[A, +B] extends collection.Map[A, B] { @@ -68,7 +68,7 @@ trait Map[A, +B] extends collection.Map[A, B] { * @param kv the key/value pair. * @return A new map with the new binding added to this map */ - def + [B1 >: B] (kv: Pair[A, B1]): Map[A, B1] = update(kv._1, kv._2) + def + [B1 >: B] (kv: (A, B1)): Map[A, B1] = update(kv._1, kv._2) /** Add two or more key/value pairs to this map. * @param kv1 the first key/value pair. @@ -76,21 +76,21 @@ trait Map[A, +B] extends collection.Map[A, B] { * @param kvs the remaining key/value pairs. * @return A new map with the new bindings added */ - def + [B1 >: B] (kv1: Pair[A, B1], kv2: Pair[A, B1], kvs: Pair[A, B1]*): Map[A, B1] = + def + [B1 >: B] (kv1: (A, B1), kv2: (A, B1), kvs: (A, B1)*): Map[A, B1] = this + kv1 + kv2 ++ kvs /** Add a sequence of key/value pairs to this map. * @param kvs the iterable object containing all key/value pairs. * @return A new map with the new bindings added */ - def ++ [B1 >: B] (kvs: Iterable[Pair[A, B1]]): Map[A, B1] = + def ++ [B1 >: B] (kvs: Iterable[(A, B1)]): Map[A, B1] = ((this: Map[A, B1]) /: kvs) ((m, kv) => m + kv) /** Add a sequence of key/value pairs to this map. * @param kvs the iterator containing all key/value pairs. * @return A new map with the new bindings added */ - def ++ [B1 >: B] (kvs: Iterator[Pair[A, B1]]): Map[A, B1] = + def ++ [B1 >: B] (kvs: Iterator[(A, B1)]): Map[A, B1] = ((this: Map[A, B1]) /: kvs) ((m, kv) => m + kv) /** Remove a key from this map @@ -156,7 +156,7 @@ trait Map[A, +B] extends collection.Map[A, B] { */ def transform[C](f: (A, B) => C): Map[A, C] = { var res = empty[C] - foreach { case Pair(key, value) => res = res.update(key, f(key, value)) } + foreach { case (key, value) => res = res.update(key, f(key, value)) } res } @@ -166,10 +166,10 @@ trait Map[A, +B] extends collection.Map[A, B] { * @param p A prediacte over key-value pairs * @return the updated map */ - override def filter(p: Pair[A, B] => Boolean): Map[A, B] = { + override def filter(p: ((A, B)) => Boolean): Map[A, B] = { var res = this foreach { - case kv @ Pair(key, _) => if (!p(kv)) { res = res - key } + case kv @ (key, _) => if (!p(kv)) { res = res - key } } res } @@ -194,7 +194,7 @@ trait Map[A, +B] extends collection.Map[A, B] { * @return ... * @deprecated use <code>+</code> instead */ - @deprecated def incl[B1 >: B](mappings: Pair[A, B1]*): Map[A, B1] = incl(mappings) + @deprecated def incl[B1 >: B](mappings: (A, B1)*): Map[A, B1] = incl(mappings) /** <code>incl</code> can be used to add many mappings at the same time * to the map. The method assumes that each mapping is represented @@ -203,11 +203,11 @@ trait Map[A, +B] extends collection.Map[A, B] { * * @deprecated use <code>++</code> instead */ - @deprecated def incl[B1 >: B](map: Iterable[Pair[A, B1]]): Map[A, B1] = { + @deprecated def incl[B1 >: B](map: Iterable[(A, B1)]): Map[A, B1] = { val iter = map.elements var res: Map[A, B1] = this while (iter.hasNext) { - val Pair(key, value) = iter.next + val (key, value) = iter.next res = res.update(key, value) } res @@ -244,7 +244,7 @@ trait Map[A, +B] extends collection.Map[A, B] { * @param p ... * @return the string representation of a map entry */ - @deprecated def mappingToString[B1 >: B](p: Pair[A, B1]) = + @deprecated def mappingToString[B1 >: B](p: (A, B1)) = p._1.toString() + " -> " + p._2 /** @deprecated use <code>+({A, B})</code> instead diff --git a/src/library/scala/collection/immutable/Map1.scala b/src/library/scala/collection/immutable/Map1.scala index 82d3ab4d3d..54767c464d 100755 --- a/src/library/scala/collection/immutable/Map1.scala +++ b/src/library/scala/collection/immutable/Map1.scala @@ -27,7 +27,7 @@ class Map1[A, +B](key1: A, value1: B) extends Map[A, B] { def get(key: A): Option[B] = if (key == key1) Some(value1) else None - def elements = Iterator.single(Pair(key1, value1)) + def elements = Iterator.single((key1, value1)) def empty[B]: Map[A, B] = new EmptyMap[A, B] diff --git a/src/library/scala/collection/immutable/Map2.scala b/src/library/scala/collection/immutable/Map2.scala index dbde4b1fb5..7ff45271fa 100755 --- a/src/library/scala/collection/immutable/Map2.scala +++ b/src/library/scala/collection/immutable/Map2.scala @@ -29,7 +29,7 @@ class Map2[A, +B](key1: A, value1: B, key2: A, value2: B) extends Map[A, B] { else None def elements = Iterator.fromValues( - Pair(key1, value1), Pair(key2, value2)) + (key1, value1), (key2, value2)) def empty[C]: Map[A, C] = new EmptyMap[A, C] diff --git a/src/library/scala/collection/immutable/Map3.scala b/src/library/scala/collection/immutable/Map3.scala index 7a743b1668..a4a85b22a8 100755 --- a/src/library/scala/collection/immutable/Map3.scala +++ b/src/library/scala/collection/immutable/Map3.scala @@ -30,7 +30,7 @@ class Map3[A, +B](key1: A, value1: B, key2: A, value2: B, key3: A, value3: B) ex else None def elements = Iterator.fromValues( - Pair(key1, value1), Pair(key2, value2), Pair(key3, value3)) + (key1, value1), (key2, value2), (key3, value3)) def empty[C]: Map[A, C] = new EmptyMap[A, C] diff --git a/src/library/scala/collection/immutable/Map4.scala b/src/library/scala/collection/immutable/Map4.scala index e85a85868c..72aeed36b9 100755 --- a/src/library/scala/collection/immutable/Map4.scala +++ b/src/library/scala/collection/immutable/Map4.scala @@ -29,7 +29,7 @@ class Map4[A, +B](key1: A, value1: B, key2: A, value2: B, key3: A, value3: B, ke else None def elements = Iterator.fromValues( - Pair(key1, value1), Pair(key2, value2), Pair(key3, value3), Pair(key4, value4)) + (key1, value1), (key2, value2), (key3, value3), (key4, value4)) def empty[C]: Map[A, C] = new EmptyMap[A, C] diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index 3f294cd055..d04188a363 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -100,12 +100,12 @@ class Queue[+A](elem: A*) extends Seq[A] { * @throws Predef.NoSuchElementException * @return the first element of the queue. */ - def dequeue: Pair[A, Queue[A]] = { - val Pair(newOut, newIn) = - if (out.isEmpty) Pair(in.reverse, Nil) - else Pair(out, in) + def dequeue: (A, Queue[A]) = { + val (newOut, newIn) = + if (out.isEmpty) (in.reverse, Nil) + else (out, in) if (newOut.isEmpty) throw new NoSuchElementException("queue empty") - else Pair(newOut.head, mkQueue(newIn, newOut.tail)) + else (newOut.head, mkQueue(newIn, newOut.tail)) } /** Returns the first element in the queue, or throws an error if there @@ -155,7 +155,7 @@ class Queue[+A](elem: A*) extends Seq[A] { override def hashCode(): Int = if (isEmpty) 0 else { - val q: Pair[A,Queue[A]] = dequeue; + val q: (A,Queue[A]) = dequeue; q._1.hashCode() + q._2.hashCode() } } diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala index 976f149b7a..9c71016a1b 100755 --- a/src/library/scala/collection/immutable/RedBlack.scala +++ b/src/library/scala/collection/immutable/RedBlack.scala @@ -29,7 +29,7 @@ abstract class RedBlack[A] { def lookup(x: A): Tree[B] def update[B1 >: B](k: A, v: B1): Tree[B1] = blacken(upd(k, v)) def delete(k: A): Tree[B] = del(k) - def elements: Iterator[Pair[A, B]] + def elements: Iterator[(A, B)] def upd[B1 >: B](k: A, v: B1): Tree[B1] def del(k: A): Tree[B] def smallest: NonEmpty[B] @@ -77,8 +77,8 @@ abstract class RedBlack[A] { } } def smallest: NonEmpty[B] = if (left.isEmpty) this else left.smallest - def elements: Iterator[Pair[A, B]] = - left.elements append Iterator.single(Pair(key, value)) append right.elements + def elements: Iterator[(A, B)] = + left.elements append Iterator.single((key, value)) append right.elements } @serializable case object Empty extends Tree[Nothing] { @@ -88,7 +88,7 @@ abstract class RedBlack[A] { def upd[B](k: A, v: B): Tree[B] = RedTree(k, v, Empty, Empty) def del(k: A): Tree[Nothing] = this def smallest: NonEmpty[Nothing] = throw new NoSuchElementException("empty map") - def elements: Iterator[Pair[A, Nothing]] = Iterator.empty + def elements: Iterator[(A, Nothing)] = Iterator.empty } @serializable case class RedTree[+B](override val key: A, diff --git a/src/library/scala/collection/immutable/Tree.scala b/src/library/scala/collection/immutable/Tree.scala index 709ab1224d..83184965d7 100644 --- a/src/library/scala/collection/immutable/Tree.scala +++ b/src/library/scala/collection/immutable/Tree.scala @@ -235,7 +235,7 @@ private case class INode[A <% Ordered[A],B](t1: GBTree[A,B], def insertRight(key: A, value: B, smaller: GBTree[A,B]) = balance_p(GBNode(key, value, smaller, t1),smaller); protected def balance_p(t:GBTree[A,B],subtree:GBTree[A,B]):InsertTree[A,B] = { - val Pair(subHeight, subSize) = subtree.count + val (subHeight, subSize) = subtree.count val totalHeight = 2 * compat.Math.max(height, subHeight) val totalSize = size + subSize + 1 val BalanceHeight = totalSize * totalSize @@ -260,22 +260,22 @@ protected abstract class GBTree[A <% Ordered[A],B] extends AnyRef { /** Calculates 2^h, and size, where h is the height of the tree * and size is the number of nodes in the tree. */ - def count: Pair[Int,Int] + def count: (Int,Int) def isDefinedAt(Key: A): Boolean def get(key: A): Option[B] def apply(key: A): B def update(key: A, value: B): aNode def insert(key: A, value: B, size: Int): anInsertTree - def toList(acc: List[Pair[A,B]]): List[Pair[A,B]] + def toList(acc: List[(A,B)]): List[(A,B)] def mk_iter(iter_tail: List[aNode]): List[aNode] def delete(key: A): aNode def merge(t: aNode): aNode - def takeSmallest: Triple[A,B,aNode] + def takeSmallest: (A,B,aNode) def balance(s: int): GBTree[A,B] } private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] { - def count = Pair(1, 0) + def count = (1, 0) def isDefinedAt(key: A) = false def get(_key: A) = None def apply(key: A) = throw new NoSuchElementException("key " + key + " not found") @@ -286,10 +286,10 @@ private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] { else ITree(GBNode(key, value, this, this)) } - def toList(acc: List[Pair[A,B]]): List[Pair[A,B]] = acc + def toList(acc: List[(A,B)]): List[(A,B)] = acc def mk_iter(iter_tail: List[GBTree[A,B]]) = iter_tail def merge(larger: GBTree[A,B]) = larger - def takeSmallest: Triple[A,B, GBTree[A,B]] = + def takeSmallest: (A,B, GBTree[A,B]) = throw new NoSuchElementException("takeSmallest on empty tree") def delete(_key: A) = throw new NoSuchElementException("Delete on empty tree.") def balance(s: int) = this @@ -301,14 +301,14 @@ private case class GBNode[A <% Ordered[A],B](key: A, smaller: GBTree[A,B], bigger: GBTree[A,B]) extends GBTree[A,B] { - def count: Pair[Int,Int] = { - val Pair(sHeight, sSize) = smaller.count - val Pair(bHeight, bSize) = bigger.count + def count: (Int,Int) = { + val (sHeight, sSize) = smaller.count + val (bHeight, bSize) = bigger.count val mySize = sSize + bSize + 1 if (mySize == 1) - Pair(1, mySize) + (1, mySize) else - Pair(2 * compat.Math.max(sHeight, bHeight), mySize) + (2 * compat.Math.max(sHeight, bHeight), mySize) } def isDefinedAt(sKey: A): Boolean = @@ -343,8 +343,8 @@ private case class GBNode[A <% Ordered[A],B](key: A, throw new NoSuchElementException("Key exists: " + newKey) } - def toList(acc: List[Pair[A,B]]): List[Pair[A,B]] = - smaller.toList(Pair(key, value) :: bigger.toList(acc)) + def toList(acc: List[(A,B)]): List[(A,B)] = + smaller.toList((key, value) :: bigger.toList(acc)) def mk_iter(iter_tail:List[aNode]):List[aNode] = smaller.mk_iter(this :: iter_tail) @@ -362,16 +362,16 @@ private case class GBNode[A <% Ordered[A],B](key: A, case GBLeaf() => this case _ => - val Triple(key1, value1, larger1) = larger.takeSmallest + val (key1, value1, larger1) = larger.takeSmallest GBNode(key1, value1, this, larger1) } - def takeSmallest: Triple[A, B, aNode] = smaller match { + def takeSmallest: (A, B, aNode) = smaller match { case GBLeaf() => - Triple(key, value, bigger) + (key, value, bigger) case _ => - val Triple(key1, value1, smaller1) = smaller.takeSmallest - Triple(key1, value1, GBNode(key, value, smaller1, bigger)) + val (key1, value1, smaller1) = smaller.takeSmallest + (key1, value1, GBNode(key, value, smaller1, bigger)) } /** @@ -381,22 +381,22 @@ private case class GBNode[A <% Ordered[A],B](key: A, def balance(s: int): GBTree[A,B] = balance_list(toList(scala.Nil), s) - protected def balance_list(list: List[Pair[A,B]], s: int): GBTree[A,B] = { + protected def balance_list(list: List[(A,B)], s: int): GBTree[A,B] = { val empty = GBLeaf[A,B](); - def bal(list: List[Pair[A,B]], s: Int): Pair[aNode, List[Pair[A,B]]] = { + def bal(list: List[(A,B)], s: Int): (aNode, List[(A,B)]) = { if (s > 1) { val sm = s - 1 val s2 = sm / 2 val s1 = sm - s2 - val Pair(t1, Pair(k, v) :: l1) = bal(list, s1) - val Pair(t2, l2) = bal(l1, s2) + val (t1, (k, v) :: l1) = bal(list, s1) + val (t2, l2) = bal(l1, s2) val t = GBNode(k, v, t1, t2) - Pair(t, l2) + (t, l2) } else if (s == 1) { - val Pair(k,v) :: rest = list - Pair(GBNode(k, v, empty, empty), rest) + val (k,v) :: rest = list + (GBNode(k, v, empty, empty), rest) } else - Pair(empty, list) + (empty, list) } bal(list, s)._1 } diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala index b9078e6bc1..2a61f3d46f 100644 --- a/src/library/scala/collection/immutable/TreeMap.scala +++ b/src/library/scala/collection/immutable/TreeMap.scala @@ -26,7 +26,7 @@ object TreeMap { /** The canonical factory for this type */ - def apply[A <% Ordered[A], B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A <% Ordered[A], B](elems: (A, B)*) = empty[A, B] ++ elems } /** This class implements immutable maps using a tree. @@ -105,7 +105,7 @@ extends RedBlack[A] with Map[A, B] { * * @return the new iterator */ - def elements: Iterator[Pair[A, B]] = tree.elements + def elements: Iterator[(A, B)] = tree.elements } diff --git a/src/library/scala/collection/immutable/UnbalancedTreeMap.scala b/src/library/scala/collection/immutable/UnbalancedTreeMap.scala index cf1817ab64..a0679168ab 100755 --- a/src/library/scala/collection/immutable/UnbalancedTreeMap.scala +++ b/src/library/scala/collection/immutable/UnbalancedTreeMap.scala @@ -20,7 +20,7 @@ object UnbalancedTreeMap { /** The canonical factory for this type */ - def apply[A<% Ordered[A], B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A<% Ordered[A], B](elems: (A, B)*) = empty[A, B] ++ elems } /** This class implements immutable maps using a tree. @@ -95,7 +95,7 @@ class UnbalancedTreeMap[A <% Ordered[A], +B] extends Map[A, B] { * * @return the new iterator */ - def elements: Iterator[Pair[A, B]] = Iterator.empty + def elements: Iterator[(A, B)] = Iterator.empty protected class Node[+B](override protected val key: A, override protected val value: B, @@ -133,8 +133,8 @@ class UnbalancedTreeMap[A <% Ordered[A], +B] extends Map[A, B] { } } - override def elements: Iterator[Pair[A, B]] = - left.elements append Iterator.single(Pair(key, value)) append right.elements + override def elements: Iterator[(A, B)] = + left.elements append Iterator.single((key, value)) append right.elements } } diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index e4956b135b..58bd61bbb2 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -166,7 +166,7 @@ class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] { case that: ArrayBuffer[_] => this.length == that.length && elements.zip(that.elements).forall { - case Pair(thiselem, thatelem) => thiselem == thatelem + case (thiselem, thatelem) => thiselem == thatelem } case _ => false diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala index fa9c5a02ba..af64e7783c 100644 --- a/src/library/scala/collection/mutable/Buffer.scala +++ b/src/library/scala/collection/mutable/Buffer.scala @@ -25,7 +25,7 @@ import Predef._ @cloneable trait Buffer[A] extends AnyRef with Seq[A] - with Scriptable[Message[Pair[Location, A]]] + with Scriptable[Message[(Location, A)]] { /** Append a single element to this buffer. @@ -202,20 +202,20 @@ trait Buffer[A] extends AnyRef * * @param cmd the message to send. */ - def <<(cmd: Message[Pair[Location, A]]): Unit = cmd match { - case Include(Pair(l, elem)) => l match { + def <<(cmd: Message[(Location, A)]): Unit = cmd match { + case Include((l, elem)) => l match { case Start => prepend(elem) case End => append(elem) case Index(n) => insert(n, elem) case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } - case Update(Pair(l, elem)) => l match { + case Update((l, elem)) => l match { case Start => update(0, elem) case End => update(length - 1, elem) case Index(n) => update(n, elem) case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") } - case Remove(Pair(l, _)) => l match { + case Remove((l, _)) => l match { case Start => remove(0) case End => remove(length - 1) case Index(n) => remove(n) diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala index 5f1d60e333..fddda07980 100644 --- a/src/library/scala/collection/mutable/BufferProxy.scala +++ b/src/library/scala/collection/mutable/BufferProxy.scala @@ -142,7 +142,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy { * * @param cmd the message to send. */ - override def <<(cmd: Message[Pair[Location, A]]): Unit = self << cmd + override def <<(cmd: Message[(Location, A)]): Unit = self << cmd /** Return a clone of this buffer. * diff --git a/src/library/scala/collection/mutable/DefaultMapModel.scala b/src/library/scala/collection/mutable/DefaultMapModel.scala index 7148667849..2dee309990 100644 --- a/src/library/scala/collection/mutable/DefaultMapModel.scala +++ b/src/library/scala/collection/mutable/DefaultMapModel.scala @@ -40,6 +40,6 @@ trait DefaultMapModel[A, B] extends Map[A, B] { else e.value = value } - def elements = entries map {e => Pair(e.key, e.value)} + def elements = entries map {e => (e.key, e.value)} } diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index 799451a6ca..092a20bf26 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -26,7 +26,7 @@ object HashMap { /** The canonical factory for this type */ - def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A, B](elems: (A, B)*) = empty[A, B] ++ elems } @serializable diff --git a/src/library/scala/collection/mutable/History.scala b/src/library/scala/collection/mutable/History.scala index f1bb2230b1..bb077c3fa3 100644 --- a/src/library/scala/collection/mutable/History.scala +++ b/src/library/scala/collection/mutable/History.scala @@ -21,9 +21,9 @@ package scala.collection.mutable * @version 1.0, 08/07/2003 */ @serializable -class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[Pair[B, A]] { +class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[(B, A)] { - protected val log: Queue[Pair[B, A]] = new Queue[Pair[B, A]] + protected val log: Queue[(B, A)] = new Queue[(B, A)] val maxHistory: Int = 1000 @@ -35,12 +35,12 @@ class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[Pair[B, A if (log.length >= maxHistory) { val old = log.dequeue; } - log.enqueue(Pair(pub, event)) + log.enqueue((pub, event)) } - def elements: Iterator[Pair[B, A]] = log.elements + def elements: Iterator[(B, A)] = log.elements - def events: Iterator[A] = log.elements.map { case Pair(_, e) => e } + def events: Iterator[A] = log.elements.map { case (_, e) => e } def size: Int = log.length diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala index 1bc55695d2..a5b818bfb5 100644 --- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala +++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala @@ -45,9 +45,9 @@ extends Map[A, B] override def values: Iterator[B] = imap.values - def elements: Iterator[Pair[A, B]] = imap.elements + def elements: Iterator[(A, B)] = imap.elements - override def toList: List[Pair[A, B]] = imap.toList + override def toList: List[(A, B)] = imap.toList def update(key: A, value: B): Unit = { imap = imap.update(key, value) } diff --git a/src/library/scala/collection/mutable/JavaMapAdaptor.scala b/src/library/scala/collection/mutable/JavaMapAdaptor.scala index 9b918836da..b4b9a923f2 100644 --- a/src/library/scala/collection/mutable/JavaMapAdaptor.scala +++ b/src/library/scala/collection/mutable/JavaMapAdaptor.scala @@ -45,12 +45,12 @@ class JavaMapAdaptor[A, B](jmap: java.util.Map) extends Map[A, B] { def next = iter.next().asInstanceOf[B] } - def elements: Iterator[Pair[A, B]] = new Iterator[Pair[A, B]] { + def elements: Iterator[(A, B)] = new Iterator[(A, B)] { val iter = jmap.keySet().iterator() def hasNext = iter.hasNext() def next = { val key = iter.next().asInstanceOf[A] - Pair(key, apply(key)) + (key, apply(key)) } } diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 55bd75d3fd..eb7caa9cc6 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -268,7 +268,7 @@ final class ListBuffer[A] extends Buffer[A] { case that: ListBuffer[_] => (this.length == that.length && elements.zip(that.elements).forall { - case Pair(thiselem, thatelem) => thiselem == thatelem + case (thiselem, thatelem) => thiselem == thatelem }) case _ => false diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index 92742d7d7b..05ee923133 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -32,13 +32,13 @@ object Map { /** The canonical factory for this type */ - def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems + def apply[A, B](elems: (A, B)*) = empty[A, B] ++ elems } @cloneable trait Map[A, B] extends AnyRef with collection.Map[A, B] - with Scriptable[Message[Pair[A, B]]] + with Scriptable[Message[(A, B)]] { /** This method allows one to add a new mapping from <code>key</code> * to <code>value</code> to the map. If the map already contains a @@ -53,32 +53,32 @@ trait Map[A, B] extends AnyRef /** Add a key/value pair to this map. * @param kv the key/value pair. */ - def += (kv: Pair[A, B]) { update(kv._1, kv._2) } + def += (kv: (A, B)) { update(kv._1, kv._2) } /** Add two or more key/value pairs to this map. * @param kv1 the first key/value pair. * @param kv2 the second key/value pair. * @param kvs the remaining key/value pairs. */ - def += (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*) { + def += (kv1: (A, B), kv2: (A, B), kvs: (A, B)*) { this += kv1; this += kv2; this ++= kvs } /** Add a sequence of key/value pairs to this map. * @param kvs the iterable object containing all key/value pairs. */ - def ++= (kvs: Iterable[Pair[A, B]]) { this ++= kvs.elements } + def ++= (kvs: Iterable[(A, B)]) { this ++= kvs.elements } /** Add a sequence of key/value pairs to this map. * @param kvs the iterator containing all key/value pairs. */ - def ++= (kvs: Iterator[Pair[A, B]]) { kvs foreach += } + def ++= (kvs: Iterator[(A, B)]) { kvs foreach += } /** Add a key/value pair to this map. * @param kv the key/value pair. * @return The map itself with the new binding added in place. */ - def + (kv: Pair[A, B]): Map[A, B] = { this += kv; this } + def + (kv: (A, B)): Map[A, B] = { this += kv; this } /** Add two or more key/value pairs to this map. * @param kv1 the first key/value pair. @@ -86,7 +86,7 @@ trait Map[A, B] extends AnyRef * @param kvs the remaining key/value pairs. * @return The map itself with the new bindings added in place. */ - def + (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*): Map[A, B] = { + def + (kv1: (A, B), kv2: (A, B), kvs: (A, B)*): Map[A, B] = { this.+=(kv1, kv2, kvs: _*); this } @@ -94,13 +94,13 @@ trait Map[A, B] extends AnyRef * @param kvs the iterable object containing all key/value pairs. * @return The itself map with the new bindings added in place. */ - def ++ (kvs: Iterable[Pair[A, B]]): Map[A, B] = { this ++= kvs; this } + def ++ (kvs: Iterable[(A, B)]): Map[A, B] = { this ++= kvs; this } /** Add a sequence of key/value pairs to this map. * @param kvs the iterator containing all key/value pairs. * @return The itself map with the new bindings added in place. */ - def ++ (kvs: Iterator[Pair[A, B]]): Map[A, B] = { this ++= kvs; this } + def ++ (kvs: Iterator[(A, B)]): Map[A, B] = { this ++= kvs; this } /** Remove a key from this map, noop if key is not present. * @param key the key to be removed @@ -163,7 +163,7 @@ trait Map[A, B] extends AnyRef */ def transform(f: (A, B) => B) { elements foreach { - case Pair(key, value) => update(key, f(key, value)) + case (key, value) => update(key, f(key, value)) } } @@ -173,17 +173,17 @@ trait Map[A, B] extends AnyRef * @param p The test predicate */ def retain(p: (A, B) => Boolean): Unit = toList foreach { - case Pair(key, value) => if (!p(key, value)) -=(key) + case (key, value) => if (!p(key, value)) -=(key) } /** Send a message to this scriptable object. * * @param cmd the message to send. */ - def <<(cmd: Message[Pair[A, B]]): Unit = cmd match { - case Include(Pair(k, v)) => update(k, v) - case Update(Pair(k, v)) => update(k, v) - case Remove(Pair(k, _)) => this -= k + def <<(cmd: Message[(A, B)]): Unit = cmd match { + case Include((k, v)) => update(k, v) + case Update((k, v)) => update(k, v) + case Remove((k, _)) => this -= k case Reset() => clear case s: Script[_] => s.elements foreach << case _ => throw new UnsupportedOperationException("message " + cmd + " not understood") @@ -214,7 +214,7 @@ trait Map[A, B] extends AnyRef * @deprecated use <code>+=</code> */ @deprecated - def incl(mappings: Pair[A, B]*): Unit = this ++= mappings.elements + def incl(mappings: (A, B)*): Unit = this ++= mappings.elements /** This method will remove all the mappings for the given sequence * of keys from the map. @@ -225,20 +225,6 @@ trait Map[A, B] extends AnyRef @deprecated def excl(keys: A*): Unit = this --= keys.elements - /** This method removes all the mappings for which the predicate - * <code>p</code> returns <code>false</code>. - * - * @deprecated use <code>retain</code> instead - * @param p - */ - @deprecated - override def filter(p: Pair[A, B] => Boolean): Iterable[Pair[A, B]] = { - toList foreach { - case kv @ Pair(key, _) => if (!p(kv)) -=(key) - } - this - } - @deprecated class MapTo(key: A) { def ->(value: B): Unit = update(key, value) diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala index a1c11e7de1..eb53261aac 100644 --- a/src/library/scala/collection/mutable/MapProxy.scala +++ b/src/library/scala/collection/mutable/MapProxy.scala @@ -29,14 +29,14 @@ trait MapProxy[A, B] extends Map[A, B] with collection.MapProxy[A, B] { def self: Map[A, B] override def update(key: A, value: B): Unit = self.update(key, value) - override def += (kv: Pair[A, B]) = self += kv - override def += (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*) = self.+=(kv1, kv2, kvs: _*) - override def ++= (kvs: Iterable[Pair[A, B]]) = self ++= kvs - override def ++= (kvs: Iterator[Pair[A, B]]) = self ++= kvs - override def + (kv: Pair[A, B]): Map[A, B] = self + kv - override def + (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*): Map[A, B] = self.+(kv1, kv2, kvs: _*) - override def ++ (kvs: Iterable[Pair[A, B]]): Map[A, B] = self ++ kvs - override def ++ (kvs: Iterator[Pair[A, B]]): Map[A, B] = self ++ kvs + override def += (kv: (A, B)) = self += kv + override def += (kv1: (A, B), kv2: (A, B), kvs: (A, B)*) = self.+=(kv1, kv2, kvs: _*) + override def ++= (kvs: Iterable[(A, B)]) = self ++= kvs + override def ++= (kvs: Iterator[(A, B)]) = self ++= kvs + override def + (kv: (A, B)): Map[A, B] = self + kv + override def + (kv1: (A, B), kv2: (A, B), kvs: (A, B)*): Map[A, B] = self.+(kv1, kv2, kvs: _*) + override def ++ (kvs: Iterable[(A, B)]): Map[A, B] = self ++ kvs + override def ++ (kvs: Iterator[(A, B)]): Map[A, B] = self ++ kvs override def -= (key: A) = self -= key override def -= (key1: A, key2: A, keys: A*) = self.-=(key1, key2, keys: _*) override def --= (keys: Iterable[A]) = self --= keys @@ -48,10 +48,10 @@ trait MapProxy[A, B] extends Map[A, B] with collection.MapProxy[A, B] { override def clear(): Unit = self.clear override def transform(f: (A, B) => B) = self transform f override def retain(p: (A, B) => Boolean): Unit = self retain p - override def <<(cmd: Message[Pair[A, B]]): Unit = self << cmd + override def <<(cmd: Message[(A, B)]): Unit = self << cmd override def clone(): Map[A, B] = self.clone() @deprecated - override def incl(mappings: Pair[A, B]*): Unit = self.incl(mappings: _*) + override def incl(mappings: (A, B)*): Unit = self.incl(mappings: _*) @deprecated override def excl(keys: A*): Unit = self.excl(keys: _*) } diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index 57f474f6e8..e1c98a1e85 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -24,13 +24,13 @@ package scala.collection.mutable */ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This extends Buffer[A] - with Publisher[Message[Pair[Location, A]] + with Publisher[Message[(Location, A)] with Undoable, This] { abstract override def +(element: A): Buffer[A] = { super.+(element) - publish(new Include(Pair(End, element)) with Undoable { + publish(new Include((End, element)) with Undoable { def undo: Unit = trimEnd(1) }) this @@ -38,7 +38,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def +:(element: A): Buffer[A] = { super.+:(element); - publish(new Include(Pair(Start, element)) with Undoable { + publish(new Include((Start, element)) with Undoable { def undo: Unit = trimStart(1) }) this @@ -49,7 +49,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This var i = n val it = iter.elements while (it.hasNext) { - publish(new Include(Pair(Index(i), it.next)) with Undoable { + publish(new Include((Index(i), it.next)) with Undoable { def undo: Unit = remove(i); }) i = i + 1 @@ -59,7 +59,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def update(n: Int, newelement: A): Unit = { val oldelement = apply(n) super.update(n, newelement) - publish(new Update(Pair(Index(n), newelement)) with Undoable { + publish(new Update((Index(n), newelement)) with Undoable { def undo: Unit = update(n, oldelement) }) } @@ -67,7 +67,7 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This abstract override def remove(n: Int): A = { val oldelement = apply(n) super.remove(n) - publish(new Remove(Pair(Index(n), oldelement)) with Undoable { + publish(new Remove((Index(n), oldelement)) with Undoable { def undo: Unit = insert(n, oldelement) }) oldelement diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala index 988eaf67c6..6841a3df5e 100644 --- a/src/library/scala/collection/mutable/ObservableMap.scala +++ b/src/library/scala/collection/mutable/ObservableMap.scala @@ -23,19 +23,19 @@ package scala.collection.mutable */ trait ObservableMap[A, B, This <: ObservableMap[A, B, This]] requires This extends Map[A, B] - with Publisher[Message[Pair[A, B]] + with Publisher[Message[(A, B)] with Undoable, This] { abstract override def update(key: A, value: B): Unit = get(key) match { case None => super.update(key, value) - publish(new Include(Pair(key, value)) with Undoable { + publish(new Include((key, value)) with Undoable { def undo = -=(key) }) case Some(old) => super.update(key, value) - publish(new Update(Pair(key, value)) with Undoable { + publish(new Update((key, value)) with Undoable { def undo = update(key, old) }) } @@ -44,7 +44,7 @@ trait ObservableMap[A, B, This <: ObservableMap[A, B, This]] requires This case None => case Some(old) => super.-=(key) - publish(new Remove(Pair(key, old)) with Undoable { + publish(new Remove((key, old)) with Undoable { def undo = update(key, old) }) } diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 84814862f7..9b3cba4928 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -157,7 +157,7 @@ class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] { that.isInstanceOf[PriorityQueue[A]] && { val other = that.asInstanceOf[PriorityQueue[A]] elements.zip(other.elements).forall { - case Pair(thiselem, thatelem) => thiselem == thatelem + case (thiselem, thatelem) => thiselem == thatelem }} /** The hashCode method always yields an error, since it is not diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 2814085b4b..9e610ac392 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -170,7 +170,7 @@ class Queue[A] extends MutableList[A] { that.isInstanceOf[Queue[A]] && { val other = that.asInstanceOf[Queue[A]] elements.zip(other.elements).forall { - case Pair(thiselem, thatelem) => thiselem == thatelem + case (thiselem, thatelem) => thiselem == thatelem }} /** The hashCode method always yields an error, since it is not diff --git a/src/library/scala/collection/mutable/RevertableHistory.scala b/src/library/scala/collection/mutable/RevertableHistory.scala index 6a9607083c..2e8fac1492 100644 --- a/src/library/scala/collection/mutable/RevertableHistory.scala +++ b/src/library/scala/collection/mutable/RevertableHistory.scala @@ -28,6 +28,6 @@ class RevertableHistory[A <: Undoable, B] extends History[A, B] with Undoable { def undo: Unit = { val old = log.toList.reverse clear - old.foreach { case Pair(sub, event) => event.undo } + old.foreach { case (sub, event) => event.undo } } } diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala index 0aef3243b5..8357e72a5f 100644 --- a/src/library/scala/collection/mutable/Set.scala +++ b/src/library/scala/collection/mutable/Set.scala @@ -168,18 +168,6 @@ trait Set[A] extends collection.Set[A] with Scriptable[Message[A]] { */ def intersect(that: Set[A]): Unit = retain(that.contains) - /** Method <code>filter</code> removes all elements from the set for - * which the predicate <code>p</code> yields the value <code>false</code>. - * @deprecated use retain instead - */ - @deprecated - override def filter(p: A => Boolean): Set[A] = { - toList.foreach { - elem => if (!p(elem)) -=(elem) - } - this - } - /** Method <code>retain removes all elements from the set for * which the predicate <code>p</code> yields the value <code>false</code>. */ diff --git a/src/library/scala/collection/mutable/SetProxy.scala b/src/library/scala/collection/mutable/SetProxy.scala index 69c07a10b1..12c071d8a3 100644 --- a/src/library/scala/collection/mutable/SetProxy.scala +++ b/src/library/scala/collection/mutable/SetProxy.scala @@ -48,9 +48,6 @@ trait SetProxy[A] extends Set[A] with collection.SetProxy[A] { override def retain(p: A => Boolean): Unit = self.retain(p) - @deprecated - override def filter(p: A => Boolean) = self.filter(p) - override def <<(cmd: Message[A]): Unit = self << cmd override def clone(): Set[A] = new SetProxy[A] { diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index a8623d69f1..9b7f0760b5 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -111,7 +111,7 @@ class Stack[A] extends MutableList[A] { that.isInstanceOf[Stack[A]] && { val other = that.asInstanceOf[Stack[A]]; elements.zip(other.elements).forall { - case Pair(thiselem, thatelem) => thiselem == thatelem + case (thiselem, thatelem) => thiselem == thatelem }} /** The hashCode method always yields an error, since it is not diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala index 652c6d535b..4bb1f5c81b 100644 --- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala +++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala @@ -168,7 +168,7 @@ trait SynchronizedBuffer[A] extends Buffer[A] { super.clear } - override def <<(cmd: Message[Pair[Location, A]]): Unit = synchronized { + override def <<(cmd: Message[(Location, A)]): Unit = synchronized { super.<<(cmd) } diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala index 800e6fc528..67e510e38e 100644 --- a/src/library/scala/collection/mutable/SynchronizedMap.scala +++ b/src/library/scala/collection/mutable/SynchronizedMap.scala @@ -56,11 +56,11 @@ trait SynchronizedMap[A, B] extends Map[A, B] { super.values } - abstract override def elements: Iterator[Pair[A, B]] = synchronized { + abstract override def elements: Iterator[(A, B)] = synchronized { super.elements } - override def toList: List[Pair[A, B]] = synchronized { + override def toList: List[(A, B)] = synchronized { super.toList } @@ -68,7 +68,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] { super.update(key, value) } - override def += (kv: Pair[A, B]): Unit = synchronized { + override def += (kv: (A, B)): Unit = synchronized { super.+=(kv) } @@ -77,20 +77,20 @@ trait SynchronizedMap[A, B] extends Map[A, B] { * @param kv2 the second key/first value pair. * @param kvs the remaining key/first value pairs. */ - override def += (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*): Unit = synchronized { + override def += (kv1: (A, B), kv2: (A, B), kvs: (A, B)*): Unit = synchronized { super.+=(kv1, kv2, kvs: _*) } - override def ++=(map: Iterable[Pair[A, B]]): Unit = synchronized { + override def ++=(map: Iterable[(A, B)]): Unit = synchronized { super.++=(map) } - override def ++=(it: Iterator[Pair[A, B]]): Unit = synchronized { + override def ++=(it: Iterator[(A, B)]): Unit = synchronized { super.++=(it) } @deprecated - override def incl(mappings: Pair[A, B]*): Unit = synchronized { + override def incl(mappings: (A, B)*): Unit = synchronized { super.incl(mappings: _*) } @@ -123,21 +123,10 @@ trait SynchronizedMap[A, B] extends Map[A, B] { super.transform(f) } - @deprecated - override def map[C](f: Pair[A, B] => C) = synchronized { - super.map(f) - } - override def retain(p: (A, B) => Boolean): Unit = synchronized { super.retain(p) } - /** @deprecated use retain instead */ - @deprecated - override def filter(p: Pair[A, B] => Boolean) = synchronized { - super.filter(p) - } - override def toString() = synchronized { super.toString() } @@ -150,7 +139,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] { super.hashCode() } - override def <<(cmd: Message[Pair[A, B]]): Unit = synchronized { + override def <<(cmd: Message[(A, B)]): Unit = synchronized { super.<<(cmd) } diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala index 2dfa6b651d..69726b1bc9 100644 --- a/src/library/scala/collection/mutable/SynchronizedSet.scala +++ b/src/library/scala/collection/mutable/SynchronizedSet.scala @@ -84,11 +84,6 @@ trait SynchronizedSet[A] extends Set[A] { super.foreach(f) } - @deprecated - override def filter(p: A => Boolean) = synchronized { - super.filter(p) - } - override def retain(p: A => Boolean) = synchronized { super.retain(p) } diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala index e1399e9e58..04a172bff4 100644 --- a/src/library/scala/concurrent/MailBox.scala +++ b/src/library/scala/concurrent/MailBox.scala @@ -58,7 +58,7 @@ class MailBox extends AnyRef with ListQueueCreator { private def scanSentMsgs[a](receiver: Receiver[a]): unit = synchronized { messageQueue.extractFirst(sent, msg => receiver.isDefinedAt(msg)) match { case None => receivers = receiverQueue.append(receivers, receiver) - case Some(Pair(msg, withoutMsg)) => { + case Some((msg, withoutMsg)) => { sent = withoutMsg receiver.msg = msg } @@ -73,7 +73,7 @@ class MailBox extends AnyRef with ListQueueCreator { def send(msg: Message): unit = synchronized { receiverQueue.extractFirst(receivers, r => r.isDefinedAt(msg)) match { case None => sent = messageQueue.append(sent, msg) - case Some(Pair(receiver, withoutReceiver)) => { + case Some((receiver, withoutReceiver)) => { receivers = withoutReceiver receiver.msg = msg receiver synchronized { receiver.notify() } @@ -116,7 +116,7 @@ trait QueueModule[a] { /** Append an element to a queue. */ def append(l: t, x: a): t /** Extract an element satisfying a predicate from a queue. */ - def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] + def extractFirst(l: t, p: a => boolean): Option[(a, t)] } /** Inefficient but simple queue module creator. */ @@ -125,16 +125,16 @@ trait ListQueueCreator { type t = List[a] def make: t = Nil def append(l: t, x: a): t = l ::: x :: Nil - def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] = + def extractFirst(l: t, p: a => boolean): Option[(a, t)] = l match { case Nil => None case head :: tail => if (p(head)) - Some(Pair(head, tail)) + Some((head, tail)) else extractFirst(tail, p) match { case None => None - case Some(Pair(x, without_x)) => Some(Pair(x, head :: without_x)) + case Some((x, without_x)) => Some((x, head :: without_x)) } } } @@ -144,17 +144,17 @@ trait ListQueueCreator { trait LinkedListQueueCreator { import scala.collection.mutable.LinkedList def queueCreate[a >: Null <: AnyRef]: QueueModule[a] = new QueueModule[a] { - type t = Pair[LinkedList[a], LinkedList[a]] // fst = the list, snd = last elem + type t = (LinkedList[a], LinkedList[a]) // fst = the list, snd = last elem def make: t = { val l = new LinkedList[a](null, null) - Pair(l, l) + (l, l) } def append(l: t, x: a): t = { val atTail = new LinkedList(x, null) l._2 append atTail; - Pair(l._1, atTail) + (l._1, atTail) } - def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] = { + def extractFirst(l: t, p: a => boolean): Option[(a, t)] = { var xs = l._1 var xs1 = xs.next while ((xs1 ne null) && !p(xs1.elem)) { @@ -164,9 +164,9 @@ trait LinkedListQueueCreator { if (xs1 ne null) { xs.next = xs1.next if (xs.next eq null) - Some(Pair(xs1.elem, Pair(l._1, xs))) + Some((xs1.elem, (l._1, xs))) else - Some(Pair(xs1.elem, l)) + Some((xs1.elem, l)) } else None diff --git a/src/library/scala/concurrent/Process.scala b/src/library/scala/concurrent/Process.scala index 6aa2e5ff53..8140433ce8 100644 --- a/src/library/scala/concurrent/Process.scala +++ b/src/library/scala/concurrent/Process.scala @@ -68,7 +68,7 @@ class Process(body: => Unit) extends Actor() { } private def signal(s: MailBox#Message) = - links.foreach { p: Process => p.send(Triple('EXIT, this, s)) } + links.foreach { p: Process => p.send(('EXIT, this, s)) } def !(msg: MailBox#Message) = send(msg) diff --git a/src/library/scala/concurrent/jolib.scala b/src/library/scala/concurrent/jolib.scala index d26190da20..2897857066 100644 --- a/src/library/scala/concurrent/jolib.scala +++ b/src/library/scala/concurrent/jolib.scala @@ -28,7 +28,7 @@ object jolib { class Join { - private var ruls: List[Pair[Pattern, Rule]] = null + private var ruls: List[(Pattern, Rule)] = null def canMatch(p: Pattern) = p forall { s => !s.queue.isEmpty } @@ -36,13 +36,13 @@ object jolib { def values(p: Pattern): List[Any] = p map { s => s.queue.dequeue: Any } - def rules(rs: Pair[Pattern, Rule]*) = - ruls = rs.asInstanceOf[List[Pair[Pattern, Rule]]] + def rules(rs: (Pattern, Rule)*) = + ruls = rs.asInstanceOf[List[(Pattern, Rule)]] def tryMatch = - ruls find { case Pair(p, _) => canMatch(p) } match { + ruls find { case (p, _) => canMatch(p) } match { case None => () => () - case Some(Pair(p, r)) => { + case Some((p, r)) => { val args = values(p) () => concurrent.ops.spawn(r(args)) } diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala index 73cfedc676..ed31099c30 100644 --- a/src/library/scala/concurrent/ops.scala +++ b/src/library/scala/concurrent/ops.scala @@ -44,10 +44,10 @@ object ops { * @param yp ... * @return ... */ - def par[a, b](xp: => a, yp: => b): Pair[a, b] = { + def par[a, b](xp: => a, yp: => b): (a, b) = { val y = new SyncVar[b] spawn { y set yp } - Pair(xp, y.get) + (xp, y.get) } /** diff --git a/src/library/scala/concurrent/pilib.scala b/src/library/scala/concurrent/pilib.scala index 449eb4f0fc..5d747f5188 100644 --- a/src/library/scala/concurrent/pilib.scala +++ b/src/library/scala/concurrent/pilib.scala @@ -157,13 +157,13 @@ object pilib { * @param gs2 ... * @return ... */ - private def matches(gs1: List[UGP], gs2: List[UGP]): Option[Triple[() => unit, () => Any, () => Any]] = - Pair(gs1, gs2) match { - case Pair(Nil, _) => None - case Pair(_, Nil) => None - case Pair(UGP(a1, d1, v1, c1) :: rest1, UGP(a2, d2, v2, c2) :: rest2) => + private def matches(gs1: List[UGP], gs2: List[UGP]): Option[(() => unit, () => Any, () => Any)] = + (gs1, gs2) match { + case (Nil, _) => None + case (_, Nil) => None + case (UGP(a1, d1, v1, c1) :: rest1, UGP(a2, d2, v2, c2) :: rest2) => if (a1 == a2 && d1 == !d2) - Some(Triple((() => if (d1) a1.log(v2) else a1.log(v1)), (() => c1(v2)), (() => c2(v1)))) + Some(((() => if (d1) a1.log(v2) else a1.log(v1)), (() => c1(v2)), (() => c2(v1)))) else matches(gs1, rest2) match { case None => matches(rest1, gs2) case Some(t) => Some(t) @@ -183,7 +183,7 @@ object pilib { case Nil => ss ::: List(s1) case s2 :: rest => matches(s1.gs, s2.gs) match { case None => s2 :: compare(s1, rest) - case Some(Triple(log, c1, c2)) => + case Some((log, c1, c2)) => log() s1.set(c1) s2.set(c2) diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala index 7354362665..91730cb5a4 100644 --- a/src/library/scala/io/BytePickle.scala +++ b/src/library/scala/io/BytePickle.scala @@ -25,7 +25,7 @@ import scala.collection.mutable.{HashMap, ArrayBuffer} object BytePickle { abstract class SPU[t] { def appP(a: t, state: PicklerState): PicklerState - def appU(state: UnPicklerState): Pair[t, UnPicklerState] + def appU(state: UnPicklerState): (t, UnPicklerState) } def pickle[t](p: SPU[t], a: t): Array[byte] = @@ -36,7 +36,7 @@ object BytePickle { abstract class PU[t] { def appP(a: t, state: Array[byte]): Array[byte] - def appU(state: Array[byte]): Pair[t, Array[byte]] + def appU(state: Array[byte]): (t, Array[byte]) } def upickle[t](p: PU[t], a: t): Array[byte] = @@ -68,9 +68,9 @@ object BytePickle { case Ref() => Array.concat(s, (List[byte](0)).toArray) case Def() => Array.concat(s, (List[byte](1)).toArray) }; - def appU(s: Array[byte]): Pair[RefDef, Array[byte]] = - if (s(0) == 0) Pair(Ref(), s.subArray(1, s.length)) - else Pair(Def(), s.subArray(1, s.length)); + def appU(s: Array[byte]): (RefDef, Array[byte]) = + if (s(0) == 0) (Ref(), s.subArray(1, s.length)) + else (Def(), s.subArray(1, s.length)); } val REF = 0 @@ -79,7 +79,7 @@ object BytePickle { def unat: PU[int] = new PU[int] { def appP(n: int, s: Array[byte]): Array[byte] = Array.concat(s, nat2Bytes(n)); - def appU(s: Array[byte]): Pair[int, Array[byte]] = { + def appU(s: Array[byte]): (int, Array[byte]) = { var num = 0 def readNat: int = { var b = 0; @@ -91,7 +91,7 @@ object BytePickle { } while ((b & 0x80) != 0); x } - Pair(readNat, s.subArray(num, s.length)) + (readNat, s.subArray(num, s.length)) } } @@ -123,7 +123,7 @@ object BytePickle { return new PicklerState(unat.appP(l, sPrime), pe) } } - def appU(state: UnPicklerState): Pair[a, UnPicklerState] = { + def appU(state: UnPicklerState): (a, UnPicklerState) = { /* - first, read tag (i.e. DEF or REF) - if REF: @@ -146,7 +146,7 @@ object BytePickle { val res2 = unat.appU(res._2) // read location upe.get(res2._1) match { // lookup value in unpickler env case None => throw new IllegalArgumentException("invalid unpickler environment"); return null - case Some(v) => return Pair(v.asInstanceOf[a], new UnPicklerState(res2._2, upe)) + case Some(v) => return (v.asInstanceOf[a], new UnPicklerState(res2._2, upe)) } } } @@ -156,14 +156,14 @@ object BytePickle { def appP(a: t, state: Array[byte]): Array[byte] = if (x != a) { throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x); state } else state; - def appU(state: Array[byte]) = Pair(x, state); + def appU(state: Array[byte]) = (x, state); } def lift[t](x: t): SPU[t] = new SPU[t] { def appP(a: t, state: PicklerState): PicklerState = if (x != a) { /*throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x);*/ state } else state; - def appU(state: UnPicklerState) = Pair(x, state); + def appU(state: UnPicklerState) = (x, state); } def usequ[t,u](f: u => t, pa: PU[t], k: t => PU[u]): PU[u] = new PU[u] { @@ -174,7 +174,7 @@ object BytePickle { val sPrimePrime = pb.appP(b, sPrime) sPrimePrime } - def appU(s: Array[byte]): Pair[u, Array[byte]] = { + def appU(s: Array[byte]): (u, Array[byte]) = { val resPa = pa.appU(s) val a = resPa._1 val sPrime = resPa._2 @@ -190,7 +190,7 @@ object BytePickle { val pb = k(a) pb.appP(b, sPrime) } - def appU(s: UnPicklerState): Pair[u, UnPicklerState] = { + def appU(s: UnPicklerState): (u, UnPicklerState) = { val resPa = pa.appU(s) val a = resPa._1 val sPrime = resPa._2 @@ -199,27 +199,27 @@ object BytePickle { } } - def upair[a,b](pa: PU[a], pb: PU[b]): PU[Pair[a,b]] = { - def fst(p: Pair[a,b]): a = p._1 - def snd(p: Pair[a,b]): b = p._2 - usequ(fst, pa, (x: a) => usequ(snd, pb, (y: b) => ulift(Pair(x, y)))) + def upair[a,b](pa: PU[a], pb: PU[b]): PU[(a,b)] = { + def fst(p: (a,b)): a = p._1 + def snd(p: (a,b)): b = p._2 + usequ(fst, pa, (x: a) => usequ(snd, pb, (y: b) => ulift((x, y)))) } - def pair[a,b](pa: SPU[a], pb: SPU[b]): SPU[Pair[a,b]] = { - def fst(p: Pair[a,b]): a = p._1 - def snd(p: Pair[a,b]): b = p._2 - sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => lift(Pair(x, y)))) + def pair[a,b](pa: SPU[a], pb: SPU[b]): SPU[(a,b)] = { + def fst(p: (a,b)): a = p._1 + def snd(p: (a,b)): b = p._2 + sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => lift((x, y)))) } - def triple[a,b,c](pa: SPU[a], pb: SPU[b], pc: SPU[c]): SPU[Triple[a,b,c]] = { - def fst(p: Triple[a,b,c]): a = p._1 - def snd(p: Triple[a,b,c]): b = p._2 - def trd(p: Triple[a,b,c]): c = p._3 + def triple[a,b,c](pa: SPU[a], pb: SPU[b], pc: SPU[c]): SPU[(a,b,c)] = { + def fst(p: (a,b,c)): a = p._1 + def snd(p: (a,b,c)): b = p._2 + def trd(p: (a,b,c)): c = p._3 sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => sequ(trd, pc, - (z: c) => lift(Triple(x, y, z))))) + (z: c) => lift((x, y, z))))) } def uwrap[a,b](i: a => b, j: b => a, pa: PU[a]): PU[b] = @@ -248,7 +248,7 @@ object BytePickle { def appP(n: int, s: PicklerState): PicklerState = { new PicklerState(Array.concat(s.stream, nat2Bytes(n)), s.dict); } - def appU(s: UnPicklerState): Pair[int,UnPicklerState] = { + def appU(s: UnPicklerState): (int,UnPicklerState) = { var num = 0 def readNat: int = { var b = 0 @@ -260,15 +260,15 @@ object BytePickle { } while ((b & 0x80) != 0); x } - Pair(readNat, new UnPicklerState(s.stream.subArray(num, s.stream.length), s.dict)) + (readNat, new UnPicklerState(s.stream.subArray(num, s.stream.length), s.dict)) } } def byte: SPU[byte] = new SPU[byte] { def appP(b: byte, s: PicklerState): PicklerState = new PicklerState(Array.concat(s.stream, (List[byte](b)).toArray), s.dict); - def appU(s: UnPicklerState): Pair[byte, UnPicklerState] = - Pair(s.stream(0), new UnPicklerState(s.stream.subArray(1, s.stream.length), s.dict)); + def appU(s: UnPicklerState): (byte, UnPicklerState) = + (s.stream(0), new UnPicklerState(s.stream.subArray(1, s.stream.length), s.dict)); } def string: SPU[String] = @@ -285,10 +285,10 @@ object BytePickle { } def ufixedList[a](pa: PU[a])(n: int): PU[List[a]] = { - def pairToList(p: Pair[a,List[a]]): List[a] = + def pairToList(p: (a,List[a])): List[a] = p._1 :: p._2; - def listToPair(l: List[a]): Pair[a,List[a]] = - (l: @unsealed) match { case x :: xs => Pair(x, xs) } + def listToPair(l: List[a]): (a,List[a]) = + (l: @unsealed) match { case x :: xs => (x, xs) } if (n == 0) ulift(Nil) else @@ -296,10 +296,10 @@ object BytePickle { } def fixedList[a](pa: SPU[a])(n: int): SPU[List[a]] = { - def pairToList(p: Pair[a,List[a]]): List[a] = + def pairToList(p: (a,List[a])): List[a] = p._1 :: p._2; - def listToPair(l: List[a]): Pair[a,List[a]] = - (l: @unsealed) match { case x :: xs => Pair(x, xs) } + def listToPair(l: List[a]): (a,List[a]) = + (l: @unsealed) match { case x :: xs => (x, xs) } if (n == 0) lift(Nil) else diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala index e90d7015a3..b462876ad1 100644 --- a/src/library/scala/mobile/Code.scala +++ b/src/library/scala/mobile/Code.scala @@ -158,17 +158,17 @@ class Code(clazz: java.lang.Class) { ////////////////////// private functions /////////////////////// private def boxValue(value: Any) = value match { - case x: Byte => Pair(new java.lang.Byte(x), java.lang.Byte.TYPE) - case x: Boolean => Pair(new java.lang.Boolean(x), java.lang.Boolean.TYPE) - case x: Char => Pair(new java.lang.Character(x), java.lang.Character.TYPE) - case x: Short => Pair(new java.lang.Short(x), java.lang.Short.TYPE) - case x: Int => Pair(new java.lang.Integer(x), java.lang.Integer.TYPE) - case x: Long => Pair(new java.lang.Long(x), java.lang.Long.TYPE) - case x: Float => Pair(new java.lang.Float(x), java.lang.Float.TYPE) - case x: Double => Pair(new java.lang.Double(x), java.lang.Double.TYPE) + case x: Byte => (new java.lang.Byte(x), java.lang.Byte.TYPE) + case x: Boolean => (new java.lang.Boolean(x), java.lang.Boolean.TYPE) + case x: Char => (new java.lang.Character(x), java.lang.Character.TYPE) + case x: Short => (new java.lang.Short(x), java.lang.Short.TYPE) + case x: Int => (new java.lang.Integer(x), java.lang.Integer.TYPE) + case x: Long => (new java.lang.Long(x), java.lang.Long.TYPE) + case x: Float => (new java.lang.Float(x), java.lang.Float.TYPE) + case x: Double => (new java.lang.Double(x), java.lang.Double.TYPE) case _ => val x = value.asInstanceOf[JObject] - Pair(x, x.getClass()) + (x, x.getClass()) } private def isConstructorName(methName: String) = { diff --git a/src/library/scala/reflect/Type.scala b/src/library/scala/reflect/Type.scala index de5dc52479..24462eb7c7 100644 --- a/src/library/scala/reflect/Type.scala +++ b/src/library/scala/reflect/Type.scala @@ -41,7 +41,7 @@ case class TypeBounds(lo: Type, hi: Type) extends Type case class MethodType(formals: List[Type], restpe: Type) extends Type /** */ -case class PolyType(typeParams: List[Symbol], typeBounds: List[Pair[Type, Type]], resultType: Type) extends Type +case class PolyType(typeParams: List[Symbol], typeBounds: List[(Type, Type)], resultType: Type) extends Type /** */ class ImplicitMethodType(formals: List[Type], restpe: Type) diff --git a/src/library/scala/runtime/Nothing$.scala b/src/library/scala/runtime/Nothing$.scala index c101637ff7..d6b9708bc0 100644 --- a/src/library/scala/runtime/Nothing$.scala +++ b/src/library/scala/runtime/Nothing$.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id$ +// $Id: Nothing$.scala 9261 2006-11-14 17:11:16 +0000 (Tue, 14 Nov 2006) mihaylov $ package scala.runtime diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala index b27dd848e8..5aa8518b9b 100644 --- a/src/library/scala/runtime/Null$.scala +++ b/src/library/scala/runtime/Null$.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id$ +// $Id: Null$.scala 9261 2006-11-14 17:11:16 +0000 (Tue, 14 Nov 2006) mihaylov $ package scala.runtime diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala index 95ed2326e1..63d0dd6c34 100644 --- a/src/library/scala/testing/SUnit.scala +++ b/src/library/scala/testing/SUnit.scala @@ -80,7 +80,7 @@ object SUnit { */ class TestFailure(val failedTest: Test, val thrownException: Throwable) { - def this(p: Pair[Test, Throwable]) = this(p._1, p._2) + def this(p: (Test, Throwable)) = this(p._1, p._2) override def toString() = failedTest.toString() + " failed due to " + thrownException.toString() @@ -91,10 +91,10 @@ object SUnit { /** a TestResult collects the result of executing a test case */ class TestResult { - val buf = new ArrayBuffer[Pair[Test, Throwable]]() + val buf = new ArrayBuffer[(Test, Throwable)]() def addFailure(test:Test, t:Throwable) = - buf += Pair(test, t) + buf += (test, t) def failureCount() = buf.length diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index 70e7bc8fc7..336ad30cc2 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -43,27 +43,27 @@ abstract class Document { * @param writer ... */ def format(width: Int, writer: Writer): Unit = { - type FmtState = Triple[Int,Boolean,Document] + type FmtState = (Int,Boolean,Document) def fits(w: Int, state: List[FmtState]): boolean = state match { case _ if w < 0 => false case List() => true - case Triple(_, _, DocNil) :: z => + case (_, _, DocNil) :: z => fits(w, z) - case Triple(i, b, DocCons(h, t)) :: z => - fits(w, Triple(i,b,h) :: Triple(i,b,t) :: z) - case Triple(_, _, DocText(t)) :: z => + case (i, b, DocCons(h, t)) :: z => + fits(w, (i,b,h) :: (i,b,t) :: z) + case (_, _, DocText(t)) :: z => fits(w - t.length(), z) - case Triple(i, b, DocNest(ii, d)) :: z => - fits(w, Triple(i + ii, b, d) :: z) - case Triple(_, false, DocBreak) :: z => + case (i, b, DocNest(ii, d)) :: z => + fits(w, (i + ii, b, d) :: z) + case (_, false, DocBreak) :: z => fits(w - 1, z) - case Triple(_, true, DocBreak) :: z => + case (_, true, DocBreak) :: z => true - case Triple(i, _, DocGroup(d)) :: z => - fits(w, Triple(i, false, d) :: z) + case (i, _, DocGroup(d)) :: z => + fits(w, (i, false, d) :: z) } def spaces(n: Int): Unit = { @@ -77,28 +77,28 @@ abstract class Document { def fmt(k: Int, state: List[FmtState]): Unit = state match { case List() => () - case Triple(_, _, DocNil) :: z => + case (_, _, DocNil) :: z => fmt(k, z) - case Triple(i, b, DocCons(h, t)) :: z => - fmt(k, Triple(i, b, h) :: Triple(i, b, t) :: z) - case Triple(i, _, DocText(t)) :: z => + case (i, b, DocCons(h, t)) :: z => + fmt(k, (i, b, h) :: (i, b, t) :: z) + case (i, _, DocText(t)) :: z => writer write t fmt(k + t.length(), z) - case Triple(i, b, DocNest(ii, d)) :: z => - fmt(k, Triple(i + ii, b, d) :: z) - case Triple(i, true, DocBreak) :: z => + case (i, b, DocNest(ii, d)) :: z => + fmt(k, (i + ii, b, d) :: z) + case (i, true, DocBreak) :: z => writer write "\n" spaces(i); fmt(i, z) - case Triple(i, false, DocBreak) :: z => + case (i, false, DocBreak) :: z => writer write " " fmt(k + 1, z) - case Triple(i, b, DocGroup(d)) :: z => - val fitsFlat = fits(width - k, Triple(i, false, d) :: z) - fmt(k, Triple(i, !fitsFlat, d) :: z) + case (i, b, DocGroup(d)) :: z => + val fitsFlat = fits(width - k, (i, false, d) :: z) + fmt(k, (i, !fitsFlat, d) :: z) } - fmt(0, Triple(0, false, DocGroup(this)) :: Nil) + fmt(0, (0, false, DocGroup(this)) :: Nil) } } diff --git a/src/library/scala/util/parsing/Parsers.scala b/src/library/scala/util/parsing/Parsers.scala index 6bc3f4a3ba..37ff73ac7b 100644 --- a/src/library/scala/util/parsing/Parsers.scala +++ b/src/library/scala/util/parsing/Parsers.scala @@ -24,28 +24,28 @@ abstract class Parsers { abstract class Parser[a] { - type Result = Option[Pair[a, inputType]] + type Result = Option[(a, inputType)] def apply(in: inputType): Result def filter(pred: a => boolean) = new Parser[a] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None - case Some(Pair(x, in1)) => if (pred(x)) Some(Pair(x, in1)) else None + case Some((x, in1)) => if (pred(x)) Some((x, in1)) else None } } def map[b](f: a => b) = new Parser[b] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None - case Some(Pair(x, in1)) => Some(Pair(f(x), in1)) + case Some((x, in1)) => Some((f(x), in1)) } } def flatMap[b](f: a => Parser[b]) = new Parser[b] { def apply(in: inputType): Result = Parser.this.apply(in) match { case None => None - case Some(Pair(x, in1)) => f(x).apply(in1) + case Some((x, in1)) => f(x).apply(in1) } } @@ -62,13 +62,13 @@ abstract class Parsers { def not[a](p: Parser[a]) = new Parser[unit] { def apply(in: inputType): Result = p.apply(in) match { - case None => Some(Pair((), in)) + case None => Some(((), in)) case Some(_) => None } } def succeed[a](x: a) = new Parser[a] { - def apply(in: inputType): Result = Some(Pair(x, in)) + def apply(in: inputType): Result = Some((x, in)) } def rep[a](p: Parser[a]): Parser[List[a]] = diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 6930cd96c7..05724ade14 100644 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -122,14 +122,14 @@ class PrettyPrinter( width:Int, step:Int ) { sb.toString() } - protected def startTag(n: Node, pscope: NamespaceBinding): Pair[String, Int] = { + protected def startTag(n: Node, pscope: NamespaceBinding): (String, Int) = { val sb = new StringBuilder("<") n.nameToString(sb) //Utility.appendPrefixedName( n.prefix, n.label, pmap, sb ); val i = sb.length() + 1 n.attributes.toString(sb) n.scope.toString(sb, pscope) sb.append('>') - Pair(sb.toString(), i) + (sb.toString(), i) } protected def endTag(n: Node) = { @@ -172,7 +172,7 @@ class PrettyPrinter( width:Int, step:Int ) { if (childrenAreLeaves(node) && fits(test)) { makeBox(ind, test) } else { - val Pair(stg, len2) = startTag(node, pscope) + val (stg, len2) = startTag(node, pscope) val etg = endTag(node) if (stg.length() < width - cur) { // start tag fits makeBox(ind, stg) diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 3a83d6be57..94e03d9502 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -229,7 +229,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @param label * @param attribs * @param children - def hashCode(uri: String, label: String, attribs: scala.collection.mutable.HashMap[Pair[String,String],String], scpe: Int, children: Seq[Node]): Int = { + def hashCode(uri: String, label: String, attribs: scala.collection.mutable.HashMap[(String,String),String], scpe: Int, children: Seq[Node]): Int = { 41 * uri.hashCode() % 7 + label.hashCode() + attribs.toList.hashCode() + scpe + children.hashCode() } */ diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index e1813fdac5..771ec50790 100644 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -81,7 +81,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit def xmlProcInstr(): MetaData = { xToken("xml") xSpace - val Pair(md,scp) = xAttributes(TopScope) + val (md,scp) = xAttributes(TopScope) if (scp != TopScope) reportSyntaxError("no xmlns definitions here, please."); xToken('?') @@ -278,7 +278,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit /** parse attribute and create namespace scope, metadata * [41] Attributes ::= { S Name Eq AttValue } */ - def xAttributes(pscope:NamespaceBinding): Pair[MetaData,NamespaceBinding] = { + def xAttributes(pscope:NamespaceBinding): (MetaData,NamespaceBinding) = { var scope: NamespaceBinding = pscope var aMap: MetaData = Null while (isNameStart(ch)) { @@ -311,7 +311,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit if(!aMap.wellformed(scope)) reportSyntaxError( "double attribute"); - Pair(aMap,scope) + (aMap,scope) } /** attribute value, terminated by either ' or ". value may not contain <. @@ -361,13 +361,13 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit val qname = xName xSpaceOpt - val Pair(aMap: MetaData, scope: NamespaceBinding) = { + val (aMap: MetaData, scope: NamespaceBinding) = { if (isNameStart(ch)) xAttributes(pscope) else - Pair(Null, pscope) + (Null, pscope) } - Triple(qname, aMap, scope) + (qname, aMap, scope) } /** [42] '<' xmlEndTag ::= '<' '/' Name S? '>' @@ -667,8 +667,8 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit val pos = this.pos val Tuple3(qname, aMap, scope) = xTag(pscope) val Tuple2(pre, local) = Utility.prefix(qname) match { - case Some(p) => Pair(p,qname.substring(p.length()+1, qname.length())) - case _ => Pair(null,qname) + case Some(p) => (p,qname.substring(p.length()+1, qname.length())) + case _ => (null,qname) } val ts = { if (ch == '/') { // empty element |