summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-02-13 22:06:58 +0000
committerMartin Odersky <odersky@gmail.com>2007-02-13 22:06:58 +0000
commite5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb (patch)
treeeada70e866264f0c52735024ce7a5804bb9f7bb8 /src
parentbd426ab6f97ad86266ea1f044f9945d76024eeac (diff)
downloadscala-e5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb.tar.gz
scala-e5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb.tar.bz2
scala-e5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb.zip
changed tuple syntax to (...)
Diffstat (limited to 'src')
-rw-r--r--src/actors/scala/actors/Actor.scala2
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala5
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreePrinters.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala10
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala313
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala48
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala30
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Members.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala78
-rw-r--r--src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala24
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternMatchers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternNodes.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala152
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala6
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala12
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala24
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala48
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala68
-rw-r--r--src/library/scala/BigInt.scala4
-rw-r--r--src/library/scala/Console.scala6
-rw-r--r--src/library/scala/Iterator.scala12
-rw-r--r--src/library/scala/List.scala42
-rw-r--r--src/library/scala/Stream.scala6
-rw-r--r--src/library/scala/collection/Map.scala4
-rw-r--r--src/library/scala/collection/MapProxy.scala2
-rwxr-xr-xsrc/library/scala/collection/immutable/EmptyMap.scala4
-rwxr-xr-xsrc/library/scala/collection/immutable/HashMap.scala4
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala10
-rw-r--r--src/library/scala/collection/immutable/Map.scala24
-rwxr-xr-xsrc/library/scala/collection/immutable/Map1.scala4
-rwxr-xr-xsrc/library/scala/collection/immutable/Map2.scala4
-rwxr-xr-xsrc/library/scala/collection/immutable/Map3.scala4
-rwxr-xr-xsrc/library/scala/collection/immutable/Map4.scala2
-rw-r--r--src/library/scala/collection/immutable/Queue.scala12
-rwxr-xr-xsrc/library/scala/collection/immutable/RedBlack.scala8
-rw-r--r--src/library/scala/collection/immutable/Tree.scala48
-rw-r--r--src/library/scala/collection/immutable/TreeMap.scala4
-rwxr-xr-xsrc/library/scala/collection/immutable/UnbalancedTreeMap.scala8
-rw-r--r--src/library/scala/collection/mutable/ArrayBuffer.scala2
-rw-r--r--src/library/scala/collection/mutable/Buffer.scala10
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala2
-rw-r--r--src/library/scala/collection/mutable/DefaultMapModel.scala2
-rw-r--r--src/library/scala/collection/mutable/HashMap.scala2
-rw-r--r--src/library/scala/collection/mutable/History.scala10
-rw-r--r--src/library/scala/collection/mutable/ImmutableMapAdaptor.scala4
-rw-r--r--src/library/scala/collection/mutable/JavaMapAdaptor.scala4
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala2
-rw-r--r--src/library/scala/collection/mutable/Map.scala38
-rw-r--r--src/library/scala/collection/mutable/MapProxy.scala20
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala12
-rw-r--r--src/library/scala/collection/mutable/ObservableMap.scala8
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala2
-rw-r--r--src/library/scala/collection/mutable/Queue.scala2
-rw-r--r--src/library/scala/collection/mutable/RevertableHistory.scala2
-rw-r--r--src/library/scala/collection/mutable/Stack.scala2
-rw-r--r--src/library/scala/collection/mutable/SynchronizedBuffer.scala2
-rw-r--r--src/library/scala/collection/mutable/SynchronizedMap.scala20
-rw-r--r--src/library/scala/concurrent/MailBox.scala22
-rw-r--r--src/library/scala/concurrent/Process.scala2
-rw-r--r--src/library/scala/concurrent/jolib.scala10
-rw-r--r--src/library/scala/concurrent/ops.scala4
-rw-r--r--src/library/scala/concurrent/pilib.scala14
-rw-r--r--src/library/scala/mobile/Code.scala18
-rw-r--r--src/library/scala/reflect/Type.scala2
-rw-r--r--src/library/scala/text/Document.scala44
77 files changed, 636 insertions, 734 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 2e0d0185d5..458e41c9b4 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -627,7 +627,7 @@ trait Actor extends OutputChannel[Any] {
// Assume !this.exiting
private[actors] def exit(from: Actor, reason: AnyRef) {
if (trapExit) {
- this ! {'EXIT, from, reason}
+ this ! Triple('EXIT, from, reason)
}
else if (reason != 'normal)
this.synchronized {
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index b16aacd2dd..7400cf610e 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -619,7 +619,7 @@ class Scalac extends MatchingTask {
/** Performs the compilation. */
override def execute() = {
- val {settings, sourceFiles} = initialize
+ val Pair(settings, sourceFiles) = initialize
val reporter = new ConsoleReporter(settings)
// Compiles the actual code
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 58f088002b..7636c39e9b 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 {sym, file} <- symSource.elements) {
+ for (val Pair(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 {sym, file} <- symSource.elements) resetPackageClass(sym.owner)
+ for (val Pair(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 119b68e5d3..6ea4d43143 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -102,7 +102,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter)
settings.outdir.value = classfilePath.getPath
/** the compiler to compile expressions with */
- val compiler = new Global(settings, reporter)
+ val compiler: Global = new Global(settings, reporter)
/** the compiler's classpath, as URL's */
val compilerClasspath: List[URL] =
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 8be11e40b4..f639fc3c44 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -164,8 +164,9 @@ abstract class TreeGen {
mkAttributedRef(definitions.NilModule)
/** Builds a pair */
- def mkNewPair(left: Tree, right: Tree) =
- New(Apply(mkAttributedRef(definitions.TupleClass(2)), List(left, right)))
+ def mkTuple(elems: List[Tree]): Tree =
+ if (elems.isEmpty) Literal(())
+ else New(TypeTree(definitions.TupleClass(elems.length).tpe), List(elems))
def mkCached(cvar: Symbol, expr: Tree): Tree = {
val cvarRef = if (cvar.owner.isClass) Select(This(cvar.owner), cvar) else Ident(cvar)
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
index 55b4bb0e2c..5d2afcc332 100644
--- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
@@ -167,7 +167,7 @@ abstract class TreePrinters {
print(symName(tree, name)); printRow(params, "(", ",", ")"); printBlock(rhs)
case Import(expr, selectors) =>
- def selectorToString(s: {Name, Name}): String =
+ def selectorToString(s: Pair[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 a7843c9fad..abcbcf3cf6 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -407,7 +407,7 @@ trait Trees requires Global {
* @param expr
* @param selectors
*/
- case class Import(expr: Tree, selectors: List[{Name, Name}])
+ case class Import(expr: Tree, selectors: List[Pair[Name, Name]])
extends SymTree
/** Annotation application (constructor arguments + name-value pairs) */
@@ -749,7 +749,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[{Name, Name}]): Import
+ def Import(tree: Tree, expr: Tree, selectors: List[Pair[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
@@ -804,7 +804,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[{Name, Name}]) =
+ def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) =
new Import(expr, selectors).copyAttrs(tree)
def Annotation(tree: Tree, constr: Tree, elements: List[Tree]) =
new Annotation(constr, elements)
@@ -921,7 +921,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[{Name, Name}]) = tree match {
+ def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) = tree match {
case t @ Import(expr0, selectors0)
if (expr0 == expr) && (selectors0 == selectors) => t
case _ => copy.Import(tree, expr, selectors)
@@ -1287,7 +1287,7 @@ trait Trees requires Global {
traverse(expr)
case Annotation(constr, elements) =>
traverse(constr); traverseTrees(elements)
- case Annotated(constr: Tree, elements: List[Tree], arg: Tree) =>
+ case Annotated(constr, elements, arg) =>
traverse(constr); traverseTrees(elements); traverse(arg)
case DocDef(comment, definition) =>
traverse(definition)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
index 4b85bd2b6d..4e1d73b53f 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
@@ -575,7 +575,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
*/
def xScalaPatterns: List[Tree] = {
sync;
- val b = p.patterns(true, false);
+ val b = p.patterns(true);
if (/*s.*/token != RBRACE) {
reportSyntaxError(" expected end of Scala patterns");
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index f85ffc8b4e..dfbc330145 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -256,16 +256,11 @@ trait Parsers requires SyntaxAnalyzer {
/** Convert tree to formal parameter list
*/
- def convertToParams(t: Tree): List[ValDef] = t match {
- case Function(params, TypeTree()) =>
- params
- case Ident(_) | Typed(Ident(_), _) =>
- List(convertToParam(t))
- case Literal(c) if c.tag == UnitTag =>
- Nil
+ def convertToParams(tree: Tree): List[ValDef] = tree match {
+ case Parens(ts) =>
+ ts map convertToParam
case _ =>
- syntaxError(t.pos, "malformed formal parameter list", false)
- Nil
+ List(convertToParam(tree))
}
/** Convert tree to formal parameter
@@ -278,7 +273,9 @@ trait Parsers requires SyntaxAnalyzer {
case Typed(Ident(name), tpe) =>
ValDef(Modifiers(Flags.PARAM), name, tpe, EmptyTree)
case _ =>
+ Console.println("CTP "+tree) //debug
syntaxError(tree.pos, "not a legal formal parameter", false)
+ throw new Error()
ValDef(Modifiers(Flags.PARAM), nme.ERROR, errorTypeTree, EmptyTree)
}
}
@@ -316,7 +313,7 @@ trait Parsers requires SyntaxAnalyzer {
Function(
List(ValDef(Modifiers(Flags.PARAM), pname, TypeTree(), EmptyTree)),
- wrapLiftedGenerators(insertParam(tree)))
+ insertParam(tree))
}
/////// OPERAND/OPERATOR STACK /////////////////////////////////////////////////
@@ -568,13 +565,15 @@ trait Parsers requires SyntaxAnalyzer {
}
else TypeTree()
- /** Types ::= Type {`,' Type}
- */
- def types(): List[Tree] = {
- val ts = new ListBuffer[Tree] + typ()
+ /** Types ::= Type {`,' Type} [`,']
+ * ArgTypePatterns ::= ArgTypePattern {`,' ArgTypePattern} [`,']
+ */
+ def types(isPattern: boolean): List[Tree] = {
+ val ts = new ListBuffer[Tree] + argType(isPattern)
while (in.token == COMMA) {
in.nextToken()
- ts += typ()
+ if (in.token == RPAREN) return List(makeTupleType(ts.toList, false))
+ ts += argType(isPattern)
}
ts.toList
}
@@ -584,14 +583,14 @@ trait Parsers requires SyntaxAnalyzer {
final val LeftOp = 1 // left associative
final val RightOp = 2 // right associative
- /** Type ::= InfixType `=>' Type
- * | `(' [Types | `=>' Type] `)' `=>' Type
- * | InfixType
+ /** Type ::= InfixType [`=>' Type]
+ * | (`=>' Type) `=>' Type
+ * | `(' `)' `=>' Type
*/
def typ(): Tree = {
val t =
if (in.token == LPAREN) {
- in.nextToken()
+ val pos = in.skipToken()
if (in.token == RPAREN) {
in.nextToken()
atPos(accept(ARROW)) { makeFunctionTypeTree(List(), typ()) }
@@ -601,24 +600,15 @@ trait Parsers requires SyntaxAnalyzer {
accept(RPAREN)
atPos(accept(ARROW)) { makeByNameFunctionTypeTree(t0, typ()) }
} else {
- val pos = in.currentPos
- val t0 = typ()
- if (in.token == COMMA) {
- in.nextToken()
- val ts = t0 :: types()
- accept(RPAREN)
- checkSize("function arguments", ts.length, definitions.MaxFunctionArity)
- atPos (accept(ARROW)) { makeFunctionTypeTree(ts, typ()) }
- } else {
- accept(RPAREN)
- infixTypeRest(pos, t0, false, FirstOp)
- }
+ val ts = types(false)
+ accept(RPAREN)
+ if (in.token == ARROW) atPos(in.skipToken()) { makeFunctionTypeTree(ts, typ()) }
+ else infixTypeRest(pos, makeTupleType(ts, true), false, FirstOp)
}
} else {
infixType(false, FirstOp)
}
- if (in.token == ARROW) atPos(in.skipToken()) {
- makeFunctionTypeTree(List(t), typ()) }
+ if (in.token == ARROW) atPos(in.skipToken()) { makeFunctionTypeTree(List(t), typ()) }
else t
}
@@ -667,35 +657,24 @@ trait Parsers requires SyntaxAnalyzer {
* | SimpleType1 `#' Id
* | StableId
* | Path `.' type
- * | `(' Type `)'
- * | `{' [Type `,' [Types [`,']]] `}'
- * SimpleTypePattern ::= SimpleTypePattern1 [TypePatternArgs]
- * SimpleTypePattern1 ::= SimpleTypePattern1 "#" Id
+ * | `(' Types `)'
+ * SimpleTypePattern ::= Annotations SimpleTypePattern1
+ * SimpleTypePattern1 ::= SimpleTypePattern2 [TypePatternArgs]
+ * SimpleTypePattern2 ::= SimpleTypePattern2 "#" Id
* | StableId
* | Path `.' type
- * | `{' [ArgTypePattern `,' [ArgTypePatterns [`,']]] `}'
+ * | `(' ArgTypePattern {`,' ArgTypePattern} [`,'] `)'
*/
def simpleType(isPattern: boolean): Tree = {
val annots = if (settings.Xplugtypes.value) typeAttributes()
else annotations()
val pos = in.currentPos
var t: Tree =
- if (in.token == LPAREN && !isPattern) {
+ if (in.token == LPAREN) {
in.nextToken()
- val t = typ()
+ val ts = types(isPattern)
accept(RPAREN)
- t
- } else if (in.token == LBRACE) {
- in.nextToken()
- val ts = if (in.token == RBRACE) List()
- else {
- val t1 = argType(isPattern)
- accept(COMMA)
- t1 :: (if (in.token == RBRACE) List() else argTypes(isPattern, true))
- }
- checkSize("tuple elements", ts.length, definitions.MaxTupleArity)
- accept(RBRACE)
- makeTupleType(ts, false)
+ atPos(pos) { makeTupleType(ts, true) }
} else {
val r = path(false, true)
val x = r match {
@@ -723,29 +702,16 @@ trait Parsers requires SyntaxAnalyzer {
else (t /: annots) (makeAnnotated)
}
- /** TypeArgs ::= `[' ArgTypes `]'
- * TypePatternArgs ::= '[' ArgTypePatterns `]'
+ /** TypeArgs ::= `[' ArgType {`,' ArgType} `]'
+ * TypePatternArgs ::= '[' ArgTypePattern {`,' ArgTypePattern} `]'
*/
def typeArgs(isPattern: boolean): List[Tree] = {
accept(LBRACKET)
- val ts = argTypes(isPattern, false)
+ val ts = types(isPattern)
accept(RBRACKET)
ts
}
- /** ArgTypes ::= ArgType {`,' ArgType}
- * ArgTypePatterns ::= ArgTypePattern {`,' ArgTypePattern}
- */
- def argTypes(isPattern: boolean, trailingComma: boolean): List[Tree] = {
- val ts = new ListBuffer[Tree] + argType(isPattern)
- while (in.token == COMMA) {
- in.nextToken()
- if (!trailingComma || in.token != RBRACE)
- ts += argType(isPattern)
- }
- ts.toList
- }
-
/** ArgType ::= Type
* ArgTypePattern ::= varid
* | `_'
@@ -764,6 +730,7 @@ trait Parsers requires SyntaxAnalyzer {
//////// EXPRESSIONS ////////////////////////////////////////////////////////
+/*
// XX_LIFTED
var liftedGenerators = new collection.mutable.ListBuffer[ValFrom]
@@ -797,7 +764,7 @@ trait Parsers requires SyntaxAnalyzer {
liftedGenerators = savedLiftedGenerators
t
}
-
+*/
/** EqualsExpr ::= `=' Expr
*/
def equalsExpr(): Tree = {
@@ -805,19 +772,20 @@ trait Parsers requires SyntaxAnalyzer {
expr()
}
- /** Exprs ::= Expr {`,' Expr} [ `:' `_' `*' ]
+ /** Exprs ::= Expr {`,' Expr} [`,']
*/
- def argExprs(): List[Tree] = {
+ def exprs(): List[Tree] = {
val ts = new ListBuffer[Tree] + argExpr()
while (in.token == COMMA) {
- in.nextToken(); ts += argExpr()
+ in.nextToken();
+ if (in.token == RPAREN) return List(makeTupleTerm(ts.toList, false))
+ ts += argExpr()
}
ts.toList
}
/** expression modifiles */
- final val IsArgument = 1
final val IsInBlock = 2
final val ClosureOK = 4
@@ -835,29 +803,27 @@ trait Parsers requires SyntaxAnalyzer {
* | [SimpleExpr `.'] Id `=' Expr
* | SimpleExpr ArgumentExprs `=' Expr
* | `.' SimpleExpr
- * | PostfixExpr [`:' CompoundType]
+ * | PostfixExpr [`:' (CompoundType | `_' `*')]
* | PostfixExpr match [`!'] `{' CaseClauses `}'
* | MethodClosure
* Bindings ::= `(' [Binding {`,' Binding}] `)'
* Binding ::= Id [`:' Type]
*/
def expr(): Tree =
- liftingScope(exprImpl(ClosureOK))
+ exprImpl(ClosureOK)
def blockStatExpr(): Tree = {
- liftingScope(exprImpl(IsInBlock | ClosureOK))
+ exprImpl(IsInBlock | ClosureOK)
}
def argExpr(): Tree = {
- exprImpl(IsArgument | ClosureOK)
+ exprImpl(ClosureOK)
}
def localExpr(): Tree = {
exprImpl(ClosureOK)
}
- def expr1(): Tree = exprImpl(0)
-
private def exprImpl(mode: int): Tree = in.token match {
case IF =>
val pos = in.skipToken()
@@ -892,7 +858,7 @@ trait Parsers requires SyntaxAnalyzer {
val lname: Name = unit.fresh.newName("while$")
val pos = in.skipToken()
accept(LPAREN)
- val cond = noLifting(localExpr())
+ val cond = localExpr()
accept(RPAREN)
newLinesOpt()
val body = expr()
@@ -904,7 +870,7 @@ trait Parsers requires SyntaxAnalyzer {
if (isStatSep) in.nextToken()
accept(WHILE)
accept(LPAREN)
- val cond = noLifting(localExpr())
+ val cond = localExpr()
accept(RPAREN)
atPos(pos) { makeDoWhile(lname, body, cond) }
case FOR =>
@@ -929,7 +895,7 @@ trait Parsers requires SyntaxAnalyzer {
case DOT =>
atPos(in.skipToken()) {
if (isIdent) {
- liftingScope(makeClosure(simpleExpr()))
+ makeClosure(stripParens(simpleExpr()))
// Note: makeClosure does some special treatment of liftedGenerators
} else {
syntaxErrorOrIncomplete("identifier expected", true)
@@ -945,17 +911,16 @@ trait Parsers requires SyntaxAnalyzer {
case _ =>
}
} else if (in.token == COLON) {
+ t = stripParens(t)
val pos = in.skipToken()
val annots = annotations()
- if ((mode & IsArgument) != 0 && in.token == USCORE) {
+ if (in.token == USCORE) {
val pos1 = in.skipToken()
if (isIdent && in.name == nme.STAR) {
in.nextToken()
t = atPos(pos) {
Typed(t, atPos(pos1) { Ident(nme.WILDCARD_STAR.toTypeName) })
}
- if (in.token != RPAREN)
- syntaxErrorOrIncomplete("`)' expected", false)
} else {
syntaxErrorOrIncomplete("`*' expected", true)
}
@@ -974,7 +939,7 @@ trait Parsers requires SyntaxAnalyzer {
accept(LBRACE)
val cases = caseClauses()
accept(RBRACE)
- Match(t, cases)
+ Match(stripParens(t), cases)
}
}
if ((mode & ClosureOK) != 0 && in.token == ARROW) {
@@ -982,12 +947,12 @@ trait Parsers requires SyntaxAnalyzer {
Function(convertToParams(t), if ((mode & IsInBlock) != 0) block() else expr())
}
}
- t
+ stripParens(t)
}
/** PostfixExpr ::= [`.'] InfixExpr [Id [NewLine]]
* InfixExpr ::= PrefixExpr
- * | InfixExpr Id [NewLine] (InfixExpr | ArgumentExprs)
+ * | InfixExpr Id [NewLine] InfixExpr
*/
def postfixExpr(): Tree = {
val base = opstack
@@ -1000,7 +965,7 @@ trait Parsers requires SyntaxAnalyzer {
ident()
newLineOptWhenFollowing(isExprIntroToken)
if (isExprIntro) {
- top = secondInfixOperandExpr(op)
+ top = prefixExpr()
} else {
val topinfo = opstack.head
opstack = opstack.tail
@@ -1012,17 +977,6 @@ trait Parsers requires SyntaxAnalyzer {
reduceStack(true, base, top, 0, true)
}
- def secondInfixOperandExpr(op: Name): Tree =
- if (in.token == LPAREN && treeInfo.isLeftAssoc(op)) {
- val pos = in.currentPos
- val args = argumentExprs()
- if (args.isEmpty) simpleExprRest(Literal(()) setPos pos, false)
- else if (args.tail.isEmpty) simpleExprRest(args.head, false)
- else ArgumentExprs(args)
- } else {
- prefixExpr()
- }
-
/** PrefixExpr ::= [`-' | `+' | `~' | `!' | `&' | `/'] SimpleExpr
*/
def prefixExpr(): Tree =
@@ -1030,16 +984,16 @@ trait Parsers requires SyntaxAnalyzer {
val name = ident()
in.token match {
case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => literal(false, true)
- case _ => atPos(in.currentPos) { Select(simpleExpr(), name) }
+ case _ => atPos(in.currentPos) { Select(stripParens(simpleExpr()), name) }
}
} else if (isIdent && (in.name == PLUS || in.name == TILDE || in.name == BANG)) {
val pos = in.currentPos
val name = ident()
- atPos(pos) { Select(simpleExpr(), name) }
+ atPos(pos) { Select(stripParens(simpleExpr()), name) }
} else if (isIdent && in.name == AMP) {
val pos = in.currentPos
val name = ident()
- atPos(pos) { Typed(simpleExpr(), Function(List(), EmptyTree)) }
+ atPos(pos) { Typed(stripParens(simpleExpr()), Function(List(), EmptyTree)) }
/* XX-LIFTING
} else if (settings.Xexperimental.value && isIdent && in.name == SLASH) {
val pos = in.skipToken()
@@ -1059,6 +1013,7 @@ trait Parsers requires SyntaxAnalyzer {
* | StableId `.' class
* | `(' [Expr] `)'
* | BlockExpr
+ * | new Template
* | SimpleExpr `.' Id
* | SimpleExpr TypeArgs
* | SimpleExpr1 ArgumentExprs
@@ -1076,28 +1031,9 @@ trait Parsers requires SyntaxAnalyzer {
t = path(true, false)
case LPAREN =>
val pos = in.skipToken()
- if (in.token == RPAREN) {
- in.nextToken()
- t = Literal(()).setPos(pos)
- } else {
- t = localExpr()
- if (in.token == COMMA) {
- val commapos = in.skipToken()
- val ts = new ListBuffer[Tree] + t ++ argExprs()
- accept(RPAREN)
- if (in.token == ARROW) {
- t = atPos(pos) {
- Function(ts.toList map convertToParam, TypeTree())
- }
- } else if(in.token == EOF) {
- incompleteInputError("`=>' expected")
- } else {
- syntaxError(commapos, "`)' expected", false)
- }
- } else {
- accept(RPAREN)
- }
- }
+ val ts = if (in.token == RPAREN) List() else exprs()
+ accept(RPAREN)
+ t = Parens(ts)
case LBRACE =>
t = blockExpr()
case NEW =>
@@ -1130,7 +1066,7 @@ trait Parsers requires SyntaxAnalyzer {
def simpleExprRest(t: Tree, isNew: boolean): Tree = in.token match {
case DOT =>
- simpleExprRest(atPos(in.skipToken()) { selector(t) }, false)
+ simpleExprRest(atPos(in.skipToken()) { selector(stripParens(t)) }, false)
case LBRACKET =>
t match {
case Ident(_) | Select(_, _) =>
@@ -1139,7 +1075,7 @@ trait Parsers requires SyntaxAnalyzer {
t
}
case LPAREN | LBRACE if (!isNew) =>
- simpleExprRest(atPos(in.currentPos) { Apply(t, argumentExprs()) }, false)
+ simpleExprRest(atPos(in.currentPos) { Apply(stripParens(t), argumentExprs()) }, false)
case _ =>
t
}
@@ -1152,7 +1088,7 @@ trait Parsers requires SyntaxAnalyzer {
List(blockExpr())
} else {
accept(LPAREN)
- val ts = if (in.token == RPAREN) List() else argExprs()
+ val ts = if (in.token == RPAREN) List() else exprs()
accept(RPAREN)
ts
}
@@ -1163,18 +1099,16 @@ trait Parsers requires SyntaxAnalyzer {
def blockExpr(): Tree = {
val res = atPos(accept(LBRACE)) {
if (in.token == CASE) makeVisitor(caseClauses(), true)
- else blockOrTuple(true)
+ else block()
}
accept(RBRACE)
res
}
/** Block ::= BlockStatSeq
- * Tuple ::= [Expr1 `,' {Expr1 `,'} [Expr1]]
*/
- def block(): Tree = blockOrTuple(false)
- def blockOrTuple(tupleOK: boolean): Tree =
- makeBlock(blockStatSeqOrTuple(tupleOK, new ListBuffer[Tree]))
+ def block(): Tree =
+ makeBlock(blockStatSeq(new ListBuffer[Tree]))
/** CaseClauses ::= CaseClause {CaseClause}
*/
@@ -1191,7 +1125,7 @@ trait Parsers requires SyntaxAnalyzer {
atPos(accept(CASE)) {
val pat = pattern()
val guard =
- if (in.token == IF) { in.nextToken(); noLifting(postfixExpr()) }
+ if (in.token == IF) { in.nextToken(); stripParens(postfixExpr()) }
else EmptyTree
makeCaseDef(pat, guard, atPos(accept(ARROW))(block()))
}
@@ -1225,12 +1159,12 @@ trait Parsers requires SyntaxAnalyzer {
/** Patterns ::= Pattern { `,' Pattern } */
/** SeqPatterns ::= SeqPattern { `,' SeqPattern } */
- def patterns(seqOK: boolean, trailingComma: boolean): List[Tree] = {
- val ts = new ListBuffer[Tree]
- ts += pattern(seqOK)
+ def patterns(seqOK: boolean): List[Tree] = {
+ val ts = new ListBuffer[Tree] + pattern(seqOK)
while (in.token == COMMA) {
in.nextToken();
- if (!trailingComma || in.token != RBRACE) ts += pattern(seqOK)
+ if (in.token == RPAREN) return List(makeTupleTerm(ts.toList, false))
+ ts += pattern(seqOK)
}
ts.toList
}
@@ -1319,22 +1253,11 @@ trait Parsers requires SyntaxAnalyzer {
val op = in.name
opstack = OpInfo(top, op, in.currentPos) :: opstack
ident()
- top = secondInfixOperandPattern(op, seqOK)
+ top = simplePattern(seqOK)
}
- reduceStack(false, base, top, 0, true)
+ stripParens(reduceStack(false, base, top, 0, true))
}
- def secondInfixOperandPattern(op: Name, seqOK: boolean): Tree =
- if (in.token == LPAREN && treeInfo.isLeftAssoc(op)) {
- val pos = in.currentPos
- val args = argumentPatterns()
- if (args.isEmpty) Literal(()) setPos pos
- else if (args.tail.isEmpty) args.head
- else ArgumentExprs(args)
- } else {
- simplePattern(seqOK)
- }
-
/** SimplePattern ::= varid
* | `_'
* | literal
@@ -1373,9 +1296,7 @@ trait Parsers requires SyntaxAnalyzer {
}
else */
if (in.token == LPAREN) {
- atPos(in.currentPos) { Apply(/*convertToTypeId*/(t), argumentPatterns()) }
- } else if (in.token == LBRACE) {
- atPos(in.currentPos) { Apply(/*convertToTypeId*/(t), List(tuplePattern())) }
+ atPos(in.currentPos) { Apply(t, argumentPatterns()) }
} else t
case USCORE =>
atPos(in.skipToken()) { Ident(nme.WILDCARD) }
@@ -1383,15 +1304,9 @@ trait Parsers requires SyntaxAnalyzer {
literal(true, false)
case LPAREN =>
val pos = in.skipToken()
- val p =
- //if (false /*disabled, no regexp matching*/ && seqOK) atPos(pos) { makeSequence(patterns(true, false)) }
- //else
- if (in.token != RPAREN) pattern(false)
- else Literal(()).setPos(pos)
+ val ps = if (in.token == RPAREN) List() else patterns(false)
accept(RPAREN)
- p
- case LBRACE =>
- tuplePattern()
+ Parens(ps)
case XMLSTART =>
xmlp.xLiteralPattern
case _ =>
@@ -1404,24 +1319,11 @@ trait Parsers requires SyntaxAnalyzer {
def argumentPatterns(): List[Tree] = {
accept(LPAREN)
- val ps = if (in.token == RPAREN) List() else patterns(true, false)
+ val ps = if (in.token == RPAREN) List() else patterns(true)
accept(RPAREN)
ps
}
- def tuplePattern(): Tree = {
- in.nextToken()
- val ts = if (in.token == RBRACE) List()
- else {
- val p1 = pattern()
- accept(COMMA)
- p1 :: (if (in.token == RBRACE) List() else patterns(false, true))
- }
- checkSize("tuple elements", ts.length, definitions.MaxTupleArity)
- accept(RBRACE)
- makeTuplePattern(ts)
- }
-
////////// MODIFIERS ////////////////////////////////////////////////////////////
private def normalize(mods: Modifiers): Modifiers =
@@ -1706,7 +1608,7 @@ trait Parsers requires SyntaxAnalyzer {
def loop: Tree =
if (in.token == USCORE) {
in.nextToken()
- Import(t, List({nme.WILDCARD, null}))
+ Import(t, List(Pair(nme.WILDCARD, null)))
} else if (in.token == LBRACE) {
Import(t, importSelectors())
} else {
@@ -1716,7 +1618,7 @@ trait Parsers requires SyntaxAnalyzer {
pos = accept(DOT)
loop
} else {
- Import(t, List({name, name}))
+ Import(t, List(Pair(name, name)))
}
}
loop
@@ -1724,8 +1626,8 @@ trait Parsers requires SyntaxAnalyzer {
/** ImportSelectors ::= `{' {ImportSelector `,'} (ImportSelector | `_') `}'
*/
- def importSelectors(): List[{Name, Name}] = {
- val names = new ListBuffer[{Name, Name}]
+ def importSelectors(): List[Pair[Name, Name]] = {
+ val names = new ListBuffer[Pair[Name, Name]]
accept(LBRACE)
var isLast = importSelector(names)
while (!isLast && in.token == COMMA) {
@@ -1738,19 +1640,19 @@ trait Parsers requires SyntaxAnalyzer {
/** ImportSelector ::= Id [`=>' Id | `=>' `_']
*/
- def importSelector(names: ListBuffer[{Name, Name}]): boolean =
+ def importSelector(names: ListBuffer[Pair[Name, Name]]): boolean =
if (in.token == USCORE) {
- in.nextToken(); names += {nme.WILDCARD, null}; true
+ in.nextToken(); names += Pair(nme.WILDCARD, null); true
} else {
val name = ident()
- names += {
+ names += Pair(
name,
if (in.token == ARROW) {
in.nextToken()
if (in.token == USCORE) { in.nextToken(); nme.WILDCARD } else ident()
} else {
name
- }}
+ })
false
}
@@ -1788,7 +1690,7 @@ trait Parsers requires SyntaxAnalyzer {
var lhs = new ListBuffer[Tree]
do {
in.nextToken()
- lhs += pattern2(false)
+ lhs += stripParens(pattern2(false))
} while (in.token == COMMA)
val tp = typedOpt()
val rhs =
@@ -1823,9 +1725,9 @@ trait Parsers requires SyntaxAnalyzer {
*/
def varDefOrDcl(mods: Modifiers): List[Tree] = {
var newmods = mods | Flags.MUTABLE
- val lhs = new ListBuffer[{Int, Name}]
+ val lhs = new ListBuffer[Pair[Int, Name]]
do {
- lhs += {in.skipToken(), ident()}
+ lhs += Pair(in.skipToken(), ident())
} while (in.token == COMMA)
val tp = typedOpt()
val rhs = if (tp.isEmpty || in.token == EQUALS) {
@@ -1840,7 +1742,7 @@ trait Parsers requires SyntaxAnalyzer {
newmods = newmods | Flags.DEFERRED
EmptyTree
}
- for (val {pos, name} <- lhs.toList) yield
+ for (val Pair(pos, name) <- lhs.toList) yield
atPos(pos) { ValDef(newmods, name, tp.duplicate, rhs.duplicate) }
}
@@ -1963,10 +1865,10 @@ trait Parsers requires SyntaxAnalyzer {
implicitClassViews = implicitViewBuf.toList
//if (mods.hasFlag(Flags.CASE) && in.token != LPAREN) accept(LPAREN)
val constrAnnots = annotations()
- val {constrMods, vparamss} =
- if (mods.hasFlag(Flags.TRAIT)) {NoMods, List()}
- else {accessModifierOpt(),
- paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE))}
+ val Pair(constrMods, vparamss) =
+ if (mods.hasFlag(Flags.TRAIT)) Pair(NoMods, List())
+ else Pair(accessModifierOpt(),
+ paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE)))
val thistpe = requiresTypeOpt()
val template = classTemplate(mods, name, constrMods withAnnotations constrAnnots, vparamss)
val mods1 = if (mods.hasFlag(Flags.TRAIT) &&
@@ -2162,7 +2064,7 @@ trait Parsers requires SyntaxAnalyzer {
if (settings.Xplugtypes.value) {
while(in.token == LBRACKET) {
accept(LBRACKET)
- exps ++= argExprs
+ exps ++= exprs()
accept(RBRACKET)
}
}
@@ -2177,7 +2079,7 @@ trait Parsers requires SyntaxAnalyzer {
var pos = in.currentPos
val aname = atPos(pos) { Ident(ident()) }
accept(EQUALS)
- atPos(pos) { Assign(aname, liftingScope(prefixExpr())) }
+ atPos(pos) { Assign(aname, stripParens(prefixExpr())) }
}
val pos = in.currentPos
var t: Tree = convertToTypeId(stableId())
@@ -2222,11 +2124,8 @@ trait Parsers requires SyntaxAnalyzer {
* | LocalModifiers TmplDef
* | Expr1
* |
- * Tuple ::= [Expr1 `,' {Expr1 `,'} [Expr1]]
*/
- def blockStatSeq(stats: ListBuffer[Tree]): List[Tree] =
- blockStatSeqOrTuple(false, stats)
- def blockStatSeqOrTuple(tupleOK: boolean, stats: ListBuffer[Tree]): List[Tree] = {
+ def blockStatSeq(stats: ListBuffer[Tree]): List[Tree] = {
def localDef(mods: Modifiers) = {
if (!(mods hasFlag ~Flags.IMPLICIT)) stats ++= defOrDcl(mods)
else stats += tmplDef(mods)
@@ -2243,23 +2142,7 @@ trait Parsers requires SyntaxAnalyzer {
stats ++= importClause()
acceptStatSep()
} else if (isExprIntro) {
- val expr = blockStatExpr()
- if (in.token == COMMA) {
- val exprbuf = new ListBuffer[Tree] + expr
- while (in.token == COMMA) {
- in.nextToken()
- if (in.token != RBRACE) exprbuf += expr1()
- }
- val exprs = exprbuf.toList
- if (in.token == ARROW) {
- val vdefs = exprs flatMap convertToParams
- checkSize("function arguments", vdefs.length, definitions.MaxFunctionArity)
- stats += atPos(in.skipToken()) { Function(vdefs, block()) }
- } else {
- checkSize("tuple elements:", exprs.length, definitions.MaxTupleArity)
- stats += makeTupleTerm(exprs, false)
- }
- } else stats += expr
+ stats += blockStatExpr()
if (in.token != RBRACE && in.token != CASE) acceptStatSep()
} else if (isDefIntro) {
localDef(NoMods)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index e09b18dfd8..b197940207 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[{Name, Tree}]
+ val buf = new ListBuffer[Pair[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 += {name, tpt}
+ buf += Pair(name, tpt)
traverse(tree1)
case Bind(name, tree1) =>
if ((name != nme.WILDCARD) && (buf.elements forall (name !=)))
- buf += {name, TypeTree()}
+ buf += Pair(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[{Name, Tree}] = {
+ private def getVariables(tree: Tree): List[Pair[Name, Tree]] = {
getvarTraverser.init.traverse(tree)
getvarTraverser.buf.toList
}
@@ -92,48 +92,48 @@ abstract class TreeBuilder {
case _ => makeTuple(trees, false)
}
- def makeTuplePattern(trees: List[Tree]): Tree = trees match {
- case List() => Literal(())
- case _ => makeTuple(trees, false)
- }
-
def makeTupleType(trees: List[Tree], flattenUnary: boolean): Tree = trees match {
case List() => scalaUnitConstr
case List(tree) if flattenUnary => tree
case _ => AppliedTypeTree(scalaDot(newTypeName("Tuple" + trees.length)), trees)
}
+ def stripParens(t: Tree) = t match {
+ case Parens(ts) => atPos(t.pos) { makeTupleTerm(ts, true) }
+ case _ => t
+ }
+
def makeAnnotated(t: Tree, attr: Tree): Tree = attr match {
case Annotation(constr, elements) => Annotated(constr, elements, t) setPos attr.pos
}
/** If tree is a variable pattern, return Some("its name and type").
* Otherwise return none */
- 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}
+ 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))
case _ => None
}
/** Create tree representing (unencoded) binary operation expression or pattern. */
def makeBinop(isExpr: boolean, left: Tree, op: Name, right: Tree): Tree = {
val arguments = right match {
- case ArgumentExprs(args) => args
+ case Parens(args) => args
case _ => List(right)
}
if (isExpr) {
if (treeInfo.isLeftAssoc(op)) {
- Apply(Select(left, op.encode), arguments)
+ Apply(Select(stripParens(left), op.encode), arguments)
} else {
val x = freshName();
Block(
- List(ValDef(Modifiers(SYNTHETIC), x, TypeTree(), left)),
- Apply(Select(right, op.encode), List(Ident(x))))
+ List(ValDef(Modifiers(SYNTHETIC), x, TypeTree(), stripParens(left))),
+ Apply(Select(stripParens(right), op.encode), List(Ident(x))))
}
} else {
- Apply(Ident(op.encode), left :: arguments)
+ Apply(Ident(op.encode), stripParens(left) :: arguments)
}
}
@@ -259,7 +259,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{name, tpt} =>
+ case Some(Pair(name, tpt)) =>
Function(List(ValDef(Modifiers(PARAM), name, tpt, EmptyTree)), body)
case None =>
makeVisitor(List(CaseDef(pat, EmptyTree, body)), false)
@@ -385,7 +385,7 @@ abstract class TreeBuilder {
/** Create tree for pattern definition &lt;mods val pat0 = rhs&gt; */
def makePatDef(mods: Modifiers, pat: Tree, rhs: Tree): List[Tree] = matchVarPattern(pat) match {
- case Some{name, tpt} =>
+ case Some(Pair(name, tpt)) =>
List(ValDef(mods, name, tpt, rhs))
case None =>
@@ -410,13 +410,13 @@ abstract class TreeBuilder {
vars match {
case List() =>
List(matchExpr)
- case List{vname, tpt} =>
+ case List(Pair(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 {vname, tpt} <- vars) yield {
+ val restDefs = for (val Pair(vname, tpt) <- vars) yield {
cnt = cnt + 1
ValDef(mods, vname, tpt, Select(Ident(tmp), newTermName("_" + cnt)))
}
@@ -448,5 +448,5 @@ abstract class TreeBuilder {
makePackaging(qual, List(PackageDef(name, stats)))
}
- case class ArgumentExprs(args: List[Tree]) extends Tree
+ case class Parens(args: List[Tree]) extends Tree
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 2622be079a..0219442b8a 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -484,34 +484,34 @@ 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) => {tpt.tpe.symbol, kind, {
+ case Typed(Ident(nme.WILDCARD), tpt) => Triple(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) => {definitions.ThrowableClass, kind, {
+ case Ident(nme.WILDCARD) => Triple(definitions.ThrowableClass, kind, {
ctx: Context =>
ctx.bb.emit(DROP(REFERENCE(definitions.ThrowableClass)))
val ctx1 = genLoad(body, ctx, kind)
genLoad(finalizer, ctx1, UNIT)
- }}
+ })
case Bind(name, _) =>
val exception = new Local(pat.symbol, toTypeKind(pat.symbol.tpe), false)
ctx.method.addLocal(exception);
- {pat.symbol.tpe.symbol, kind, {
+ Triple(pat.symbol.tpe.symbol, kind, {
ctx: Context =>
ctx.bb.emit(STORE_LOCAL(exception), pat.pos);
val ctx1 = genLoad(body, ctx, kind);
genLoad(finalizer, ctx1, UNIT);
- }}
+ })
}
if (finalizer != EmptyTree)
- handlers = { NoSymbol, kind, {
+ handlers = Triple(NoSymbol, kind, {
ctx: Context =>
val exception = new Local(ctx.method.symbol
.newVariable(finalizer.pos, unit.fresh.newName("exc"))
@@ -525,7 +525,7 @@ abstract class GenICode extends SubComponent {
ctx1.bb.emit(THROW());
ctx1.bb.enterIgnoreMode;
ctx1
- }} :: handlers;
+ }) :: handlers;
ctx.Try(
bodyCtx => {
@@ -1273,9 +1273,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 = {l, r} match {
- case {Literal(Constant(null)), expr} => expr
- case {expr, Literal(Constant(null))} => expr
+ val expr: Tree = Pair(l, r) match {
+ case Pair(Literal(Constant(null)), expr) => expr
+ case Pair(expr, Literal(Constant(null))) => expr
case _ => null
}
if (expr ne null) {
@@ -1393,15 +1393,15 @@ abstract class GenICode extends SubComponent {
local
}
- {l, r} match {
+ Pair(l, r) match {
// null == expr -> expr eq null
- case {Literal(Constant(null)), expr} =>
+ case Pair(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 {expr, Literal(Constant(null))} =>
+ case Pair(expr, Literal(Constant(null))) =>
val eqEqTempLocal = getTempLocal
var ctx1 = genLoad(expr, ctx, ANY_REF_CLASS)
ctx1.bb.emit(DUP(ANY_REF_CLASS))
@@ -1808,7 +1808,7 @@ abstract class GenICode extends SubComponent {
* } ))</code>
*/
def Try(body: Context => Context,
- handlers: List[{Symbol, TypeKind, (Context => Context)}],
+ handlers: List[Triple[Symbol, TypeKind, (Context => Context)]],
finalizer: Tree) = {
val outerCtx = this.dup
val afterCtx = outerCtx.newBlock
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
index 6116b73d1e..0f8d1091a1 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
@@ -229,7 +229,7 @@ trait Members requires ICodes {
var end: Int = _
/** PC-based ranges for this local variable's visibility range */
- var ranges: List[{Int, Int}] = Nil
+ var ranges: List[Pair[Int, Int]] = Nil
override def equals(other: Any): Boolean = (
other.isInstanceOf[Local] &&
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index d412a4315e..0a4de0e814 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 {excs, others} = sym.attributes.partition((a => a match {
+ val Pair(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 {name, value} <- nvPairs) {
+ for (val Pair(name, value) <- nvPairs) {
buf.putShort(cpool.addUtf8(name.toString()).toShort)
emitElement(value)
}
@@ -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 = {start, end} :: ranges
+ ranges = Pair(start, end) :: ranges
start = -1
}
} else {
@@ -612,7 +612,7 @@ abstract class GenJVM extends SubComponent {
* code!
*/
if (start >= 0) {
- ranges = {start, jcode.getPC()} :: ranges;
+ ranges = Pair(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 = {lv.start, jcode.getPC()} :: lv.ranges
+ lv.ranges = Pair(lv.start, jcode.getPC()) :: lv.ranges
varsInBlock -= lv
} else if (b.varsInScope contains lv) {
- lv.ranges = {labels(b).getAnchor(), jcode.getPC()} :: lv.ranges
+ lv.ranges = Pair(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 = {lv.start, jcode.getPC()} :: lv.ranges
+ lv.ranges = Pair(lv.start, jcode.getPC()) :: lv.ranges
}
for (val lv <- b.varsInScope) {
- lv.ranges = {labels(b).getAnchor(), jcode.getPC()} :: lv.ranges
+ lv.ranges = Pair(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) => {op, kind} match {
- case {AND, LONG} =>
+ case Logical(op, kind) => Pair(op, kind) match {
+ case Pair(AND, LONG) =>
jcode.emitLAND()
- case {AND, INT} =>
+ case Pair(AND, INT) =>
jcode.emitIAND()
- case {AND, _} =>
+ case Pair(AND, _) =>
jcode.emitIAND()
if (kind != BOOL)
jcode.emitT2T(javaType(INT), javaType(kind));
- case {OR, LONG} =>
+ case Pair(OR, LONG) =>
jcode.emitLOR()
- case {OR, INT} =>
+ case Pair(OR, INT) =>
jcode.emitIOR()
- case {OR, _} =>
+ case Pair(OR, _) =>
jcode.emitIOR()
if (kind != BOOL)
jcode.emitT2T(javaType(INT), javaType(kind));
- case {XOR, LONG} =>
+ case Pair(XOR, LONG) =>
jcode.emitLXOR()
- case {XOR, INT} =>
+ case Pair(XOR, INT) =>
jcode.emitIXOR()
- case {XOR, _} =>
+ case Pair(XOR, _) =>
jcode.emitIXOR()
if (kind != BOOL)
jcode.emitT2T(javaType(INT), javaType(kind));
}
- case Shift(op, kind) => {op, kind} match {
- case {LSL, LONG} =>
+ case Shift(op, kind) => Pair(op, kind) match {
+ case Pair(LSL, LONG) =>
jcode.emitLSHL()
- case {LSL, INT} =>
+ case Pair(LSL, INT) =>
jcode.emitISHL()
- case {LSL, _} =>
+ case Pair(LSL, _) =>
jcode.emitISHL()
jcode.emitT2T(javaType(INT), javaType(kind))
- case {ASR, LONG} =>
+ case Pair(ASR, LONG) =>
jcode.emitLSHR()
- case {ASR, INT} =>
+ case Pair(ASR, INT) =>
jcode.emitISHR()
- case {ASR, _} =>
+ case Pair(ASR, _) =>
jcode.emitISHR()
jcode.emitT2T(javaType(INT), javaType(kind))
- case {LSR, LONG} =>
+ case Pair(LSR, LONG) =>
jcode.emitLUSHR()
- case {LSR, INT} =>
+ case Pair(LSR, INT) =>
jcode.emitIUSHR()
- case {LSR, _} =>
+ case Pair(LSR, _) =>
jcode.emitIUSHR()
jcode.emitT2T(javaType(INT), javaType(kind))
}
- 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 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 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 {start, end} <- lv.ranges) {
+ for (val Pair(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[{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
+ 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
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 2d16388b37..3623d125ea 100644
--- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
+++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
@@ -889,7 +889,7 @@ abstract class GenMSIL extends SubComponent {
def leavingBlocks(blocks: List[BasicBlock]): List[Pair[BasicBlock, List[BasicBlock]]] = {
for {val b <- blocks
val t = outsideTargets(b, blocks)
- t.length != 0 } yield {b, t}
+ t.length != 0 } yield Pair(b, t)
}
def replaceOutJumps(blocks: List[BasicBlock], leaving: List[Pair[BasicBlock, List[BasicBlock]]], exh: ExceptionHandler):Pair[List[BasicBlock], Option[BasicBlock]] = {
@@ -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)
})
- {blocks ::: List(jumpOutBlock), Some(jumpOutBlock)}
+ Pair(blocks ::: List(jumpOutBlock), Some(jumpOutBlock))
}
val leaving = leavingBlocks(blocks)
if (leaving.length == 0)
- {blocks, None}
+ Pair(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
- {blocks.diff(List(last)) ::: List(last), None}
+ Pair(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 {adaptedBlocks, newBlock} = adaptBlocks(blocksToPut.intersect(h1.blocks), singleAffectedHandler)
+ val Pair(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 {tryBlocks, newBlock} = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.covered), singleAffectedHandler)
+ val Pair(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 {blocks0, newBlock} = adaptBlocks(blocksToPut.intersect(singleAffectedHandler.finalizer.blocks), singleAffectedHandler)
+ val Pair(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 {isDelegateView, paramType, resType} = atPhase(currentRun.typerPhase){
+ val Triple(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))
- {isDel, parameterTypes(0), resultType}
- case _ => {false, null, null}
+ Triple(isDel, parameterTypes(0), resultType)
+ case _ => Triple(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 {paramTypes, returnType} = delegateType.member(nme.apply).tpe match {
- case MethodType(delParams, delReturn) => {delParams, delReturn}
+ val Pair(paramTypes, returnType) = delegateType.member(nme.apply).tpe match {
+ case MethodType(delParams, delReturn) => Pair(delParams, delReturn)
case _ => abort("not a delegate type: " + delegateType)
}
val caller: MethodBuilder = delegateCallers.DefineMethod(
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
index c66c3e1ff8..75ab5623fd 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 {doOptimize, coveredCases, remainingCases} = _h.optimize1()
+ val Triple(doOptimize, coveredCases, remainingCases) = _h.optimize1()
if(!remainingCases.isEmpty && doCheckExhaustive) {
carryCovered = carryCovered ++ coveredCases // ??
if(next != null && next.or.and.isUnguardedBody) {
@@ -1301,7 +1301,7 @@ print()
true
case _ =>
if(settings.XprintOuterMatches.value)
- cunit.warning(node.pos, "can't be sure statically that these outers are equal:"+{left,right}.toString)
+ cunit.warning(node.pos, "can't be sure statically that these outers are equal:"+Pair(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 cd0d5da3d8..b436dccefb 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(): { Boolean, SymSet, SymSet } = {
+ def optimize1(): Triple[Boolean, SymSet, SymSet] = {
import symtab.Flags
val selType = this.getTpe
if (!isSubType(selType, definitions.ScalaObjectClass.tpe))
- return {false, null, emptySymbolSet};
+ return Triple(false, null, emptySymbolSet)
if(this.or eq null)
- return {false, null, emptySymbolSet} // only case _
+ return Triple(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 {res && (cases > 2), coveredCases, remainingCases};
+ return Triple(res && (cases > 2), coveredCases, remainingCases)
} // def optimize
}
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index 178c6155fa..8fe03975f3 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 {name, file} <- classes.elements) {
+ for (val Pair(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 {name, file} <- packages.elements)
+ for (val Pair(name, file) <- packages.elements)
enterPackage(name, newPackageLoader(file))
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index fad85cfc4a..2db48eaa41 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1306,7 +1306,7 @@ trait Symbols requires SymbolTable {
def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error()
}
- case class AttrInfo(atp: Type, args: List[Constant], assocs: List[{Name, Constant}]) {
+ case class AttrInfo(atp: Type, args: List[Constant], assocs: List[Pair[Name, Constant]]) {
override def toString: String =
atp +
(if (args.isEmpty) "" else args.mkString("(", ", ", ")")) +
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 348f9c2f77..27bc11ff67 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 {tparam1, arg} <- sym.info.typeParams zip args)
+ for (val Pair(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 {from, targets} <- refs(NonExpansive).elements)
+ for (val Pair(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 {from, targets} <- refs(Expansive).elements)
+ for (val Pair(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 = {
- {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)}
+ 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))
if (sym1 == sym2) =>
true
- case {SingleType(pre1, sym1), SingleType(pre2, sym2)}
+ case Pair(SingleType(pre1, sym1), SingleType(pre2, sym2))
if ((sym1 == sym2) && (pre1 =:= pre2)) =>
true
/*
- case {SingleType(pre1, sym1), ThisType(sym2)}
+ case Pair(SingleType(pre1, sym1), ThisType(sym2))
if (sym1.isModule &&
sym1.moduleClass == sym2 &&
pre1 =:= sym2.owner.thisType) =>
true
- case {ThisType(sym1), SingleType(pre2, sym2)}
+ case Pair(ThisType(sym1), SingleType(pre2, sym2))
if (sym2.isModule &&
sym2.moduleClass == sym1 &&
pre2 =:= sym1.owner.thisType) =>
true
*/
- case {ConstantType(value1), ConstantType(value2)} =>
+ case Pair(ConstantType(value1), ConstantType(value2)) =>
value1 == value2
- case {TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)} =>
+ case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) =>
sym1 == sym2 && (phase.erasedTypes || pre1 =:= pre2) && isSameTypes(args1, args2)
- case {RefinedType(parents1, ref1), RefinedType(parents2, ref2)} =>
+ case Pair(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 {MethodType(pts1, res1), MethodType(pts2, res2)} =>
+ case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) =>
(pts1.length == pts2.length &&
isSameTypes(pts1, pts2) &&
res1 =:= res2 &&
tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType])
- case {PolyType(tparams1, res1), PolyType(tparams2, res2)} =>
+ case Pair(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 {TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)} =>
+ case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) =>
lo1 =:= lo2 && hi1 =:= hi2
- case {BoundedWildcardType(bounds), _} =>
+ case Pair(BoundedWildcardType(bounds), _) =>
bounds containsType tp2
- case {_, BoundedWildcardType(bounds)} =>
+ case Pair(_, BoundedWildcardType(bounds)) =>
bounds containsType tp1
- case {TypeVar(_, constr1), _} =>
+ case Pair(TypeVar(_, constr1), _) =>
if (constr1.inst != NoType) constr1.inst =:= tp2
else constr1 instantiate (wildcardToTypeVarMap(tp2))
- case {_, TypeVar(_, constr2)} =>
+ case Pair(_, TypeVar(_, constr2)) =>
if (constr2.inst != NoType) tp1 =:= constr2.inst
else constr2 instantiate (wildcardToTypeVarMap(tp1))
- case {AttributedType(_,atp), _} =>
+ case Pair(AttributedType(_,atp), _) =>
isSameType(atp, tp2)
- case {_, AttributedType(_,atp)} =>
+ case Pair(_, 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 = {
- {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)} =>
+ 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)) =>
//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 {MethodType(pts1, res1), MethodType(pts2, res2)} =>
+ case Pair(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 {PolyType(tparams1, res1), PolyType(tparams2, res2)} =>
+ case Pair(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 {TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)} =>
+ case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) =>
lo2 <:< lo1 && hi1 <:< hi2
- case {BoundedWildcardType(bounds), _} =>
+ case Pair(BoundedWildcardType(bounds), _) =>
bounds.lo <:< tp2
- case {_, BoundedWildcardType(bounds)} =>
+ case Pair(_, BoundedWildcardType(bounds)) =>
tp1 <:< bounds.hi
- case {_, TypeVar(_, constr2)} =>
+ case Pair(_, TypeVar(_, constr2)) =>
if (constr2.inst != NoType) tp1 <:< constr2.inst
else { constr2.lobounds = tp1 :: constr2.lobounds; true }
- case {TypeVar(_, constr1), _} =>
+ case Pair(TypeVar(_, constr1), _) =>
if (constr1.inst != NoType) constr1.inst <:< tp2
else { constr1.hibounds = tp2 :: constr1.hibounds; true }
- case {AttributedType(_,atp1), _} =>
+ case Pair(AttributedType(_,atp1), _) =>
atp1 <:< tp2
- case {_, AttributedType(_,atp2)} =>
+ case Pair(_, AttributedType(_,atp2)) =>
tp1 <:< atp2
- case {_, TypeRef(pre2, sym2, args2)}
+ case Pair(_, TypeRef(pre2, sym2, args2))
if sym2.isAbstractType && !(tp2 =:= tp2.bounds.lo) && (tp1 <:< tp2.bounds.lo) =>
true
- case {_, RefinedType(parents2, ref2)} =>
+ case Pair(_, RefinedType(parents2, ref2)) =>
(parents2 forall tp1.<:<) && (ref2.toList forall tp1.specializes) &&
(!parents2.exists(.symbol.isAbstractType) || tp1.symbol != AllRefClass)
- case {RefinedType(parents1, ref1), _} =>
+ case Pair(RefinedType(parents1, ref1), _) =>
parents1 exists (.<:<(tp2))
/* todo: replace following with
- case {ThisType(_), _}
+ case Pair(ThisType(_), _)
| {SingleType(_, _), _}
| {ConstantType(_), _} =>
once patern matching bug is fixed */
- case {ThisType(_), _} => tp1.singleDeref <:< tp2
- case {SingleType(_, _), _} => tp1.singleDeref <:< tp2
- case {ConstantType(_), _} => tp1.singleDeref <:< tp2
+ case Pair(ThisType(_), _) => tp1.singleDeref <:< tp2
+ case Pair(SingleType(_, _), _) => tp1.singleDeref <:< tp2
+ case Pair(ConstantType(_), _) => tp1.singleDeref <:< tp2
- case {TypeRef(pre1, sym1, args1), _} =>
+ case Pair(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 = {tp1, tp2} match {
- case {MethodType(pts1, res1), MethodType(pts2, res2)} =>
+ private def matchesType(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match {
+ case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) =>
(matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && (res1 matches res2) &&
tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType])
- case {PolyType(tparams1, res1), PolyType(tparams2, res2)} =>
+ case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) =>
(tparams1.length == tparams2.length &&
(res1 matches res2.substSym(tparams2, tparams1)))
- 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 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 _ =>
!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 8c0833e3bf..cf53db37a2 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 {name, tpe} = getNameAndType(in.getChar(start + 3), ownerTpe)
+ val Pair(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))
@@ -232,7 +232,7 @@ abstract class ClassfileParser {
tpe = MethodType(formals, ownerTpe)
}
- p = {name, tpe}
+ p = Pair(name, tpe)
}
p
}
@@ -700,7 +700,7 @@ abstract class ClassfileParser {
val nvpairs = new ListBuffer[Pair[Name,Constant]]
for (val i <- 0 until nargs) {
val name = pool.getName(in.nextChar)
- nvpairs += {name, parseTaggedConstant()}
+ nvpairs += Pair(name, parseTaggedConstant())
}
sym.attributes = AttrInfo(attrType, List(), nvpairs.toList) :: sym.attributes
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 68c504eb30..ebe7c6d763 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: Set[Symbol]): unit = {
- assert(putEntry{sym, children})
+ assert(putEntry(Pair(sym, children)))
children foreach putSymbol
}
private def putAnnotation(sym: Symbol, attr: AttrInfo): unit = {
- assert(putEntry{sym, attr})
+ assert(putEntry(Pair(sym, attr)))
putType(attr.atp)
for (val c <- attr.args) putConstant(c)
- for (val {name, c} <- attr.assocs) { putEntry(name); putConstant(c) }
+ for (val Pair(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 {target: Symbol, attr @ AttrInfo(atp, args, assocs)} =>
+ case Pair(target: Symbol, attr @ AttrInfo(atp, args, assocs)) =>
writeRef(target)
writeRef(atp)
for (val c <- args) writeRef(c)
- for (val {name, c} <- assocs) { writeRef(name); writeRef(c) }
+ for (val Pair(name, c) <- assocs) { writeRef(name); writeRef(c) }
ATTRIBUTE
- case {target: Symbol, children: Set[_]} =>
+ case Pair(target: Symbol, children: Set[_]) =>
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 e28ed90b69..ac1d10e9be 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[{Name, Constant}]
+ val assocs = new ListBuffer[Pair[Name, Constant]]
while (readIndex != end) {
val argref = readNat()
- if (isNameEntry(argref)) assocs += {at(argref, readName), readConstantRef()}
+ if (isNameEntry(argref)) assocs += Pair(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/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala
index 1610d237e0..7323b17fa3 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 = {op, x.tag} match {
- case {nme.ZNOT, BooleanTag} => Constant(!x.booleanValue)
+ private def foldUnop(op: Name, x: Constant): Constant = Pair(op, x.tag) match {
+ case Pair(nme.ZNOT, BooleanTag) => Constant(!x.booleanValue)
- case {nme.NOT , IntTag } => Constant(~x.intValue)
- case {nme.NOT , LongTag } => Constant(~x.longValue)
+ case Pair(nme.NOT , IntTag ) => Constant(~x.intValue)
+ case Pair(nme.NOT , LongTag ) => Constant(~x.longValue)
- case {nme.ADD , IntTag } => Constant(+x.intValue)
- case {nme.ADD , LongTag } => Constant(+x.longValue)
- case {nme.ADD , FloatTag } => Constant(+x.floatValue)
- case {nme.ADD , DoubleTag } => Constant(+x.doubleValue)
+ case Pair(nme.ADD , IntTag ) => Constant(+x.intValue)
+ case Pair(nme.ADD , LongTag ) => Constant(+x.longValue)
+ case Pair(nme.ADD , FloatTag ) => Constant(+x.floatValue)
+ case Pair(nme.ADD , DoubleTag ) => Constant(+x.doubleValue)
- case {nme.SUB , IntTag } => Constant(-x.intValue)
- case {nme.SUB , LongTag } => Constant(-x.longValue)
- case {nme.SUB , FloatTag } => Constant(-x.floatValue)
- case {nme.SUB , DoubleTag } => Constant(-x.doubleValue)
+ case Pair(nme.SUB , IntTag ) => Constant(-x.intValue)
+ case Pair(nme.SUB , LongTag ) => Constant(-x.longValue)
+ case Pair(nme.SUB , FloatTag ) => Constant(-x.floatValue)
+ case Pair(nme.SUB , 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 72f8d8540e..0fb3d02cc5 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({nme.WILDCARD, null}))
+ Import(qual, List(Pair(nme.WILDCARD, null)))
.setSymbol(NoSymbol.newImport(NoPos).setFlag(SYNTHETIC).setInfo(ImportType(qual)))
.setType(NoType))
sc.depth = sc.depth + 1
@@ -364,12 +364,12 @@ trait Contexts requires Analyzer {
}
def pushTypeBounds(sym: Symbol): unit = {
- savedTypeBounds = {sym, sym.info} :: savedTypeBounds
+ savedTypeBounds = Pair(sym, sym.info) :: savedTypeBounds
}
def restoreTypeBounds(tp: Type): Type = {
var current = tp
- for (val {sym, info} <- savedTypeBounds) {
+ for (val Pair(sym, info) <- savedTypeBounds) {
if (settings.debug.value) log("resetting " + sym + " to " + info);
sym.info match {
case TypeBounds(lo, hi) if (hi <:< lo && lo <:< hi) =>
@@ -393,8 +393,8 @@ trait Contexts requires Analyzer {
val pre = imp.qual.tpe
def collect(sels: List[Pair[Name, Name]]): List[ImplicitInfo] = sels match {
case List() => List()
- case List{nme.WILDCARD, _} => collectImplicits(pre.implicitMembers, pre)
- case {from, to} :: sels1 =>
+ case List(Pair(nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre)
+ case Pair(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 3e63401356..91ff898450 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -50,6 +50,14 @@ trait Infer requires Analyzer {
} else formals1
}
+ def actualTypes(actuals: List[Type], nformals: int): List[Type] =
+ if (nformals == 1 && actuals.length != 1)
+ List(if (actuals.length == 0) UnitClass.tpe else tupleType(actuals))
+ else actuals
+
+ def actualArgs(pos: PositionType, actuals: List[Tree], nformals: int): List[Tree] =
+ if (nformals == 1 && actuals.length != 1) List(gen.mkTuple(actuals) setPos pos) else actuals
+
/** A fresh type varable with given type parameter as origin.
*
* @param tparam ...
@@ -134,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 {tvar2, {tparam2, variance2}} <- config) {
+ for (val Pair(tvar2, Pair(tparam2, variance2)) <- config) {
if (tparam2 != tparam &&
((bound contains tparam2) ||
up && (tparam2.info.bounds.lo =:= tparam.tpe) ||
@@ -170,7 +178,7 @@ trait Infer requires Analyzer {
assertNonCyclic(tvar)//debug
}
}
- for (val {tvar, {tparam, variance}} <- config)
+ for (val Pair(tvar, Pair(tparam, variance)) <- config)
solveOne(tvar, tparam, variance)
tvars map instantiate
}
@@ -227,11 +235,11 @@ trait Infer requires Analyzer {
"expression of type " + tree.tpe
else if (tree.symbol.hasFlag(OVERLOADED))
"overloaded method " + tree.symbol + " with alternatives " + tree.tpe
- else (
+ else
tree.symbol.toString() +
(if (tree.tpe.paramSectionCount > 0) ": " else " of type ") +
- tree.tpe
- )
+ tree.tpe +
+ (if (tree.symbol.name == nme.apply) tree.symbol.locationString else "")
def applyErrorMsg(tree: Tree, msg: String, argtpes: List[Type], pt: Type) = (
treeSymTypeMsg(tree) + msg + argtpes.mkString("(", ",", ")") +
@@ -295,13 +303,13 @@ trait Infer requires Analyzer {
explainName(sym1)
explainName(sym2)
if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name)
- {sym1, sym2, name}
+ Triple(sym1, sym2, name)
}
}
val result = op
- for (val {sym1, sym2, name} <- patches) {
+ for (val Triple(sym1, sym2, name) <- patches) {
sym1.name = name
sym2.name = name
}
@@ -519,10 +527,11 @@ trait Infer requires Analyzer {
* @return ...
*/
def isApplicable(undetparams: List[Symbol], ftpe: Type,
- argtpes: List[Type], pt: Type): boolean =
+ argtpes0: List[Type], pt: Type): boolean =
ftpe match {
case MethodType(formals0, restpe) =>
- val formals = formalTypes(formals0, argtpes.length)
+ val formals = formalTypes(formals0, argtpes0.length)
+ val argtpes = actualTypes(argtpes0, formals.length)
if (undetparams.isEmpty) {
(formals.length == argtpes.length &&
isCompatible(argtpes, formals) &&
@@ -539,7 +548,7 @@ trait Infer requires Analyzer {
}
case PolyType(tparams, restpe) =>
val tparams1 = cloneSymbols(tparams)
- isApplicable(tparams1 ::: undetparams, restpe.substSym(tparams, tparams1), argtpes, pt)
+ isApplicable(tparams1 ::: undetparams, restpe.substSym(tparams, tparams1), argtpes0, pt)
case ErrorType =>
true
case _ =>
@@ -650,13 +659,12 @@ trait Infer requires Analyzer {
*/
def inferMethodInstance(fn: Tree, undetparams: List[Symbol],
args: List[Tree], pt: Type): List[Symbol] = fn.tpe match {
- case MethodType(formals, restpe) =>
+ case MethodType(formals0, restpe) =>
try {
- val argtpes = args map (.tpe.deconst)
+ val formals = formalTypes(formals0, args.length)
+ val argtpes = actualTypes(args map (.tpe.deconst), formals.length)
val uninstantiated = new ListBuffer[Symbol]
- val targs = methTypeArgs(
- undetparams, formalTypes(formals, argtpes.length),
- restpe, argtpes, pt, uninstantiated)
+ val targs = methTypeArgs(undetparams, formals, restpe, argtpes, pt, uninstantiated)
checkBounds(fn.pos, NoPrefix, NoSymbol, undetparams, targs, "inferred ")
//Console.println("UNAPPLY subst type "+undetparams+" to "+targs+" in "+fn+" ( "+args+ ")")
val treeSubst = new TreeTypeSubstituter(undetparams, targs)
@@ -685,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 = {tp1, tp2} match {
- case {TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)} =>
+ def isConsistent(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match {
+ case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) =>
assert(sym1 == sym2)
pre1 =:= pre2 &&
!(List.map3(args1, args2, sym1.typeParams) {
@@ -773,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 {loBounds, hiBounds} =
- if (instType != NoType && isFullyDefined(instType)) {List(instType), List(instType)}
- else {tvar.constr.lobounds, tvar.constr.hibounds}
+ val Pair(loBounds, hiBounds) =
+ if (instType != NoType && isFullyDefined(instType)) Pair(List(instType), List(instType))
+ else Pair(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 162bc87d43..d7025f3dc1 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 {tparam, tskolem} <- tparams zip tskolems) tparam.symbol = tskolem
+ for (val Pair(tparam, tskolem) <- tparams zip tskolems) tparam.symbol = tskolem
}
def applicableTypeParams(owner: Symbol): List[Symbol] =
@@ -625,8 +625,8 @@ trait Namers requires Analyzer {
}
true
}
- def checkSelectors(selectors: List[{Name, Name}]): unit = selectors match {
- case {from, to} :: rest =>
+ def checkSelectors(selectors: List[Pair[Name, Name]]): unit = selectors match {
+ case Pair(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);
@@ -687,12 +687,12 @@ trait Namers requires Analyzer {
error(ntree.pos, "duplicate value for element " + name)
} else {
names -= sym
- {sym.name, getConstant(typer.typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType))}
+ Pair(sym.name, getConstant(typer.typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType)))
}
}
}
for (val name <- names) {
- if (!name.attributes.contains{AnnotationDefaultAttr.tpe, List(), List()}) {
+ if (!name.attributes.contains(Triple(AnnotationDefaultAttr.tpe, List(), List()))) {
error(t.pos, "attribute " + tpt.tpe.symbol.fullNameString + " is missing element " + name.name)
}
}
@@ -784,8 +784,8 @@ trait Namers requires Analyzer {
else if (isFunctionType(tp) &&
(!isFunctionType(elemtp) || tp.typeArgs.length > elemtp.typeArgs.length))
result = true
- else {tp, elemtp} match {
- case {TypeRef(pre, sym, args), TypeRef(elempre, elemsym, elemargs)} =>
+ else Pair(tp, elemtp) match {
+ case Pair(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 0c1df47925..2afb6dd493 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 = {tp1, tp2} match {
- case {MethodType(List(), rtp1), PolyType(List(), rtp2)} =>
+ def overridesType(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match {
+ case Pair(MethodType(List(), rtp1), PolyType(List(), rtp2)) =>
rtp1 <:< rtp2
- case {PolyType(List(), rtp1), MethodType(List(), rtp2)} =>
+ case Pair(PolyType(List(), rtp1), MethodType(List(), rtp2)) =>
rtp1 <:< rtp2
- case {TypeRef(_, sym, _), _} if (sym.isModuleClass) =>
+ case Pair(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 {tp, tparam} => validateVariance(tp, variance * tparam.variance)
+ case Pair(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 84eb0cc9bf..51ed171076 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[{Symbol, ListBuffer[Tree]}] = List()
+ private var accDefs: List[Pair[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 = {currentOwner, ownAccDefs} :: accDefs;
+ accDefs = Pair(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 f5999b3582..bd534813c2 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 {sym,i} <- accs.zipWithIndex) yield {
+ (for(val Pair(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 b546d4b8d6..1e645f3baa 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -974,21 +974,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): {Tree, List[Tree]} = call match {
+ def decompose(call: Tree): Pair[Tree, List[Tree]] = call match {
case Apply(fn, args) =>
- val {superConstr, args1} = decompose(fn)
+ val Pair(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
- {superConstr, args1 ::: args2}
+ Pair(superConstr, args1 ::: args2)
case Block(stats, expr) =>
decompose(stats.head)
case _ =>
- {call, List()}
+ Pair(call, List())
}
- val {superConstr, superArgs} = decompose(rhs)
+ val Pair(superConstr, superArgs) = decompose(rhs)
assert(superConstr.symbol ne null)//debug
if (superConstr.symbol.isPrimaryConstructor) {
val superClazz = superConstr.symbol.owner
@@ -1221,16 +1221,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): {Symbol, List[Type], Type} =
+ def decompose(pt: Type): Triple[Symbol, List[Type], Type] =
if (isFunctionType(pt)
||
pt.symbol == PartialFunctionClass &&
fun.vparams.length == 1 && fun.body.isInstanceOf[Match])
- {pt.symbol, pt.typeArgs.init, pt.typeArgs.last}
+ Triple(pt.symbol, pt.typeArgs.init, pt.typeArgs.last)
else
- {FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType}
+ Triple(FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType)
- val {clazz, argpts, respt} = decompose(if (codeExpected) pt.typeArgs.head else pt)
+ val Triple(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)
@@ -1381,14 +1381,15 @@ trait Typers requires Analyzer {
typedApply(tree, adapt(fun, funMode(mode), WildcardType), args1, mode, pt)
case MethodType(formals0, restpe) =>
val formals = formalTypes(formals0, args.length)
- if (formals.length != args.length) {
- //Console.println(formals.length+" "+args.length);//DEBUG
+ var args1 = actualArgs(tree.pos, args, formals.length)
+ if (formals.length != args1.length) {
+ Console.println(formals+" "+args1);//DEBUG
errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun))
} else {
val tparams = context.undetparams
context.undetparams = List()
if (tparams.isEmpty) {
- val args1 = typedArgs(args, mode, formals0, formals)
+ val args2 = typedArgs(args1, mode, formals0, formals)
def ifPatternSkipFormals(tp: Type) = tp match {
case MethodType(_, rtp) if ((mode & PATTERNmode) != 0) => rtp
case _ => tp
@@ -1408,7 +1409,7 @@ trait Typers requires Analyzer {
// the compiler thinks, the PLUS method takes only one argument,
// but he thinks it's an instance method -> still two ref's on the stack
// -> translated by backend
- val rhs = copy.Apply(tree, f, args)
+ val rhs = copy.Apply(tree, f, args1)
return typed(Assign(qual, rhs))
}
case _ => ()
@@ -1418,9 +1419,9 @@ trait Typers requires Analyzer {
if (fun.symbol == List_apply && args.isEmpty) {
atPos(tree.pos) { gen.mkNil setType restpe }
} else if ((mode & CONSTmode) != 0 && fun.symbol.owner == PredefModule.tpe.symbol && fun.symbol.name == nme.Array) {
- val elems = new Array[Constant](args1.length)
+ val elems = new Array[Constant](args2.length)
var i = 0;
- for (val arg <- args1) arg match {
+ for (val arg <- args2) arg match {
case Literal(value) =>
elems(i) = value
i = i + 1
@@ -1430,7 +1431,7 @@ trait Typers requires Analyzer {
Literal(arrayConst) setType mkConstantType(arrayConst)
}
else
- constfold(copy.Apply(tree, fun, args1).setType(ifPatternSkipFormals(restpe)))
+ constfold(copy.Apply(tree, fun, args2).setType(ifPatternSkipFormals(restpe)))
} else {
assert((mode & PATTERNmode) == 0); // this case cannot arise for patterns
val lenientTargs = protoTypeArgs(tparams, formals, restpe, pt)
@@ -1447,12 +1448,12 @@ trait Typers requires Analyzer {
}
arg1
}
- val args1 = List.map2(args, formals)(typedArgToPoly)
- if (args1 exists (.tpe.isError)) setError(tree)
+ val args2 = List.map2(args1, formals)(typedArgToPoly)
+ if (args2 exists (.tpe.isError)) setError(tree)
else {
- if (settings.debug.value) log("infer method inst "+fun+", tparams = "+tparams+", args = "+args1.map(.tpe)+", pt = "+pt+", lobounds = "+tparams.map(.tpe.bounds.lo)+", parambounds = "+tparams.map(.info));//debug
- val undetparams = inferMethodInstance(fun, tparams, args1, pt)
- val result = typedApply(tree, fun, args1, mode, pt)
+ if (settings.debug.value) log("infer method inst "+fun+", tparams = "+tparams+", args = "+args2.map(.tpe)+", pt = "+pt+", lobounds = "+tparams.map(.tpe.bounds.lo)+", parambounds = "+tparams.map(.info));//debug
+ val undetparams = inferMethodInstance(fun, tparams, args2, pt)
+ val result = typedApply(tree, fun, args2, mode, pt)
context.undetparams = undetparams
result
}
@@ -1499,14 +1500,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): {Type, List[Symbol]} = tp match {
+ def freshArgType(tp: Type): Pair[Type, List[Symbol]] = tp match {
case MethodType(formals, restpe) =>
- {formals(0), List()}
+ Pair(formals(0), List())
case PolyType(tparams, restype) =>
val tparams1 = cloneSymbols(tparams)
- {freshArgType(restype)._1.substSym(tparams, tparams1), tparams1}
+ Pair(freshArgType(restype)._1.substSym(tparams, tparams1), tparams1)
}
- val {unappFormal, freeVars} = freshArgType(unappType)
+ val Pair(unappFormal, freeVars) = freshArgType(unappType)
val context1 = context.makeNewScope(context.tree, context.owner)
freeVars foreach context1.scope.enter
val typer1 = new Typer(context1)
@@ -1567,12 +1568,12 @@ trait Typers requires Analyzer {
error(ntree.pos, "duplicate value for element " + name)
} else {
names -= sym
- {sym.name, getConstant(typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType))}
+ Pair(sym.name, getConstant(typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType)))
}
}
}
for (val name <- names) {
- if (!name.attributes.contains{AnnotationDefaultAttr.tpe, List(), List()}) {
+ if (!name.attributes.contains(Triple(AnnotationDefaultAttr.tpe, List(), List()))) {
error(constr.pos, "attribute " + tpt.tpe.symbol.fullNameString + " is missing element " + name.name)
}
}
@@ -2151,6 +2152,7 @@ trait Typers requires Analyzer {
}
case Typed(expr, tpt @ Ident(name)) if (name == nme.WILDCARD_STAR.toTypeName) =>
+ //todo: do this: errorTree(tree, "`: _*' annotation only legal for method arguments")
val expr1 = typed(expr, mode & stickyModes, seqType(pt))
expr1.tpe.baseType(SeqClass) match {
case TypeRef(_, _, List(elemtp)) =>
@@ -2198,12 +2200,12 @@ trait Typers requires Analyzer {
}
case Super(qual, mix) =>
- val {clazz, selftype} =
+ val Pair(clazz, selftype) =
if (tree.symbol != NoSymbol) {
- {tree.symbol, tree.symbol.thisType}
+ Pair(tree.symbol, tree.symbol.thisType)
} else {
val clazzContext = qualifyingClassContext(tree, qual)
- {clazzContext.owner, clazzContext.prefix}
+ Pair(clazzContext.owner, clazzContext.prefix)
}
if (clazz == NoSymbol) setError(tree)
else {
@@ -2229,12 +2231,12 @@ trait Typers requires Analyzer {
}
case This(qual) =>
- val {clazz, selftype} =
+ val Pair(clazz, selftype) =
if (tree.symbol != NoSymbol) {
- {tree.symbol, tree.symbol.thisType}
+ Pair(tree.symbol, tree.symbol.thisType)
} else {
val clazzContext = qualifyingClassContext(tree, qual)
- {clazzContext.owner, clazzContext.prefix}
+ Pair(clazzContext.owner, clazzContext.prefix)
}
if (clazz == NoSymbol) setError(tree)
else {
diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala
index 4fcbfd82ce..9be8a45dbd 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): {BigInt, BigInt} = {
+ def /% (that: BigInt): Pair[BigInt, BigInt] = {
val dr = this.bigInteger.divideAndRemainder(that.bigInteger)
- {new BigInt(dr(0)), new BigInt(dr(1))}
+ Pair(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 488e091390..ea2968fc03 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): {Any, Any} = {
+ def readf2(format: String): Pair[Any, Any] = {
val res = readf(format)
- {res.head, res.tail.head}
+ Pair(res.head, res.tail.head)
}
/** Read in some structured input, specified by a format specifier.
@@ -287,7 +287,7 @@ object Console {
*/
def readf3(format: String): Triple[Any, Any, Any] = {
val res = readf(format)
- {res.head, res.tail.head, res.tail.tail.head}
+ Triple(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 528fd68635..00e40ab5b9 100644
--- a/src/library/scala/Iterator.scala
+++ b/src/library/scala/Iterator.scala
@@ -348,9 +348,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[{A, B}] {
+ def zip[B](that: Iterator[B]) = new Iterator[Pair[A, B]] {
def hasNext = Iterator.this.hasNext && that.hasNext
- def next = {Iterator.this.next, that.next}
+ def next = Pair(Iterator.this.next, that.next)
}
/** Return an iterator that pairs each element of this iterator
@@ -361,11 +361,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[{A, int}] {
+ def zipWithIndex = new Iterator[Pair[A, int]] {
var idx = 0
def hasNext = Iterator.this.hasNext
def next = {
- val ret = {Iterator.this.next, idx}
+ val ret = Pair(Iterator.this.next, idx)
idx = idx + 1
ret
}
@@ -541,7 +541,7 @@ trait Iterator[+A] {
*
* @return a pair of iterators
*/
- def duplicate: {Iterator[A], Iterator[A]} = {
+ def duplicate: Pair[Iterator[A], Iterator[A]] = {
var xs: List[A] = Nil
var ahead: Iterator[A] = null
class Partner extends Iterator[A] {
@@ -571,7 +571,7 @@ trait Iterator[+A] {
}
}
ahead = new Partner
- {ahead, new Partner}
+ Pair(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 25b7032ca9..4e01ee2107 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[{a,b}]): {List[a], List[b]} = {
+ def unzip[a,b](xs: List[Pair[a,b]]): Pair[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
}
- {b1.toList, b2.toList}
+ Pair(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): {List[a], List[a]} = {
+ def splitAt(n: Int): Pair[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
}
- {b.toList, these}
+ Pair(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): {List[a], List[a]} = {
+ def span(p: a => Boolean): Pair[List[a], List[a]] = {
val b = new ListBuffer[a]
var these = this
while (!these.isEmpty && p(these.head)) {
b += these.head
these = these.tail
}
- {b.toList, these}
+ Pair(b.toList, these)
}
/** Like <code>span</code> but with the predicate inverted.
*/
- def break(p: a => Boolean): {List[a], List[a]} = span { x => !p(x) }
+ def break(p: a => Boolean): Pair[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): {List[a], List[a]} = {
+ def partition(p: a => Boolean): Pair[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
}
- {btrue.toList, bfalse.toList}
+ Pair(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 {small, large} = tail.partition((e2) => lt(e2, y))
+ val Pair(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 {small,large} = tail.partition((e2) => lt(e2, y))
+ val Pair(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[{a,b}] = {
- val b = new ListBuffer[{a, b}]
+ def zip[b](that: List[b]): List[Pair[a,b]] = {
+ val b = new ListBuffer[Pair[a, b]]
var these = this
var those = that
while (!these.isEmpty && !those.isEmpty) {
- b += {these.head, those.head}
+ b += Pair(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[{a,int}]
+ val b = new ListBuffer[Pair[a,int]]
var these = this
var idx = 0
while(!these.isEmpty) {
- b += {these.head, idx}
+ b += Pair(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 &gt; n</code>.
*/
- def zipAll[b, c >: a, d >: b](that: List[b], thisElem: c, thatElem: d): List[{c,d}] = {
- val b = new ListBuffer[{c, d}]
+ 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]]
var these = this
var those = that
while (!these.isEmpty && !those.isEmpty) {
- b += {these.head, those.head}
+ b += Pair(these.head, those.head)
these = these.tail
those = those.tail
}
while (!these.isEmpty) {
- b += {these.head, thatElem}
+ b += Pair(these.head, thatElem)
these = these.tail
}
while (!those.isEmpty) {
- b += {thisElem, those.head}
+ Pair(thisElem, those.head)
those = those.tail
}
b.toList
diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala
index db02cd89d8..fe140f2598 100644
--- a/src/library/scala/Stream.scala
+++ b/src/library/scala/Stream.scala
@@ -13,7 +13,7 @@ package scala
import compat.StringBuilder
-import Predef.{NoSuchElementException, UnsupportedOperationException}
+import Predef.{NoSuchElementException, UnsupportedOperationException,Pair}
/**
* The object <code>Stream</code> provides helper functions
@@ -53,11 +53,11 @@ object Stream {
}
}
- def unapply[a](str: Stream[a]): Option[{a,Stream[a]}] =
+ def unapply[a](str: Stream[a]): Option[Pair[a,Stream[a]]] =
if(str.isEmpty)
None
else
- Some{str.head, str.tail}
+ Some(Pair(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 45f45a110b..c02c195086 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[{A, B}] {
+trait Map[A, +B] extends PartialFunction[A, B] with Iterable[Pair[A, B]] {
/** Compute the number of key-to-value mappings.
*
@@ -125,7 +125,7 @@ trait Map[A, +B] extends PartialFunction[A, B] with Iterable[{A, B}] {
override def equals(that: Any): Boolean = that match {
case other: Map[a, b] =>
this.size == other.size && this.elements.forall {
- case {key, value} => other.get(key.asInstanceOf[a]) match {
+ case Pair(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 142d2c5ba0..2585f24c7d 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[{A, B}] {
+trait MapProxy[A, +B] extends Map[A, B] with IterableProxy[Pair[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 fbf8c10c1a..127781f2d5 100755
--- a/src/library/scala/collection/immutable/EmptyMap.scala
+++ b/src/library/scala/collection/immutable/EmptyMap.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import Predef.Pair
+
/** This class implements empty immutable maps
* @author Martin Oderskty
* @version 1.0, 019/01/2007
@@ -23,7 +25,7 @@ class EmptyMap[A, +B] extends Map[A, B] {
def get(key: A): Option[B] = None
- def elements: Iterator[{A, B}] = Iterator.empty
+ def elements: Iterator[Pair[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 3cda6cf08b..57fc4b8ed9 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: {A, B}*) = empty[A, B] ++ elems
+ def apply[A, B](elems: Pair[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 => {e.key, getValue(e)}}
+ entries map {e => Pair(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 4ce9c4cc39..c3fdfe1a80 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -24,7 +24,7 @@ object ListMap {
/** The canonical factory for this type
*/
- def apply[A, B](elems: {A, B}*) = empty[A, B] ++ elems
+ def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems
}
/** This class implements immutable maps using a list-based data
@@ -79,13 +79,13 @@ class ListMap[A, +B] extends Map[A, B] {
/** Returns an iterator over key-value pairs.
*/
- def elements: Iterator[{A,B}] =
- new Iterator[{A,B}] {
+ def elements: Iterator[Pair[A,B]] =
+ new Iterator[Pair[A,B]] {
var self: ListMap[A,B] = ListMap.this
def hasNext = !self.isEmpty
- def next: {A,B} =
+ def next: Pair[A,B] =
if (!hasNext) throw new NoSuchElementException("next on empty iterator")
- else { val res = {self.key, self.value}; self = self.next; res }
+ else { val res = Pair(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 5cc326c031..108cb07f44 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: {A, B}*) = empty[A, B] ++ elems
+ def apply[A, B](elems: Pair[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: {A, B1}): Map[A, B1] = update(kv._1, kv._2)
+ def + [B1 >: B] (kv: Pair[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: {A, B1}, kv2: {A, B1}, kvs: {A, B1}*): Map[A, B1] =
+ def + [B1 >: B] (kv1: Pair[A, B1], kv2: Pair[A, B1], kvs: Pair[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[{A, B1}]): Map[A, B1] =
+ def ++ [B1 >: B] (kvs: Iterable[Pair[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[{A, B1}]): Map[A, B1] =
+ def ++ [B1 >: B] (kvs: Iterator[Pair[A, B1]]): Map[A, B1] =
((this: Map[A, B1]) /: kvs) ((m, kv) => m + kv)
/** Remove a key from this map
@@ -140,7 +140,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 {key, value} => res = res.update(key, f(key, value)) }
+ foreach { case Pair(key, value) => res = res.update(key, f(key, value)) }
res
}
@@ -150,10 +150,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: {A, B} => Boolean): Map[A, B] = {
+ override def filter(p: Pair[A, B] => Boolean): Map[A, B] = {
var res = this
foreach {
- case kv @ {key, _} => if (!p(kv)) { res = res - key }
+ case kv @ Pair(key, _) => if (!p(kv)) { res = res - key }
}
res
}
@@ -178,7 +178,7 @@ trait Map[A, +B] extends collection.Map[A, B] {
* @return ...
* @deprecated use <code>+</code> instead
*/
- [deprecated] def incl[B1 >: B](mappings: {A, B1}*): Map[A, B1] = incl(mappings)
+ [deprecated] def incl[B1 >: B](mappings: Pair[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
@@ -187,11 +187,11 @@ trait Map[A, +B] extends collection.Map[A, B] {
*
* @deprecated use <code>++</code> instead
*/
- [deprecated] def incl[B1 >: B](map: Iterable[{A, B1}]): Map[A, B1] = {
+ [deprecated] def incl[B1 >: B](map: Iterable[Pair[A, B1]]): Map[A, B1] = {
val iter = map.elements
var res: Map[A, B1] = this
while (iter.hasNext) {
- val {key, value} = iter.next
+ val Pair(key, value) = iter.next
res = res.update(key, value)
}
res
@@ -227,7 +227,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: {A, B1}) = p._1.toString() + " -> " + p._2
+ [deprecated] def mappingToString[B1 >: B](p: Pair[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 22a2e05b09..edd8dc11fc 100755
--- a/src/library/scala/collection/immutable/Map1.scala
+++ b/src/library/scala/collection/immutable/Map1.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import Predef.Pair
+
/** This class implements empty immutable maps
* @author Martin Oderskty
* @version 1.0, 019/01/2007
@@ -24,7 +26,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({key1, value1})
+ def elements = Iterator.single(Pair(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 fbadfaa68d..02d4651d03 100755
--- a/src/library/scala/collection/immutable/Map2.scala
+++ b/src/library/scala/collection/immutable/Map2.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import Predef.Pair
+
/** This class implements empty immutable maps
* @author Martin Oderskty
* @version 1.0, 019/01/2007
@@ -27,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(
- {key1, value1}, {key2, value2})
+ Pair(key1, value1), Pair(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 38198bbc71..b7c4a506f8 100755
--- a/src/library/scala/collection/immutable/Map3.scala
+++ b/src/library/scala/collection/immutable/Map3.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import Predef.Pair
+
/** This class implements empty immutable maps
* @author Martin Oderskty
* @version 1.0, 019/01/2007
@@ -28,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(
- {key1, value1}, {key2, value2}, {key3, value3})
+ Pair(key1, value1), Pair(key2, value2), Pair(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 3596008109..1582123c18 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(
- {key1, value1}, {key2, value2}, {key3, value3}, {key4, value4})
+ Pair(key1, value1), Pair(key2, value2), Pair(key3, value3), Pair(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 c88bbbdb27..c40777b417 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: {A, Queue[A]} = {
- val {newOut, newIn} =
- if (out.isEmpty) {in.reverse, Nil}
- else {out, in};
+ def dequeue: Pair[A, Queue[A]] = {
+ val Pair(newOut, newIn) =
+ if (out.isEmpty) Pair(in.reverse, Nil)
+ else Pair(out, in)
if (newOut.isEmpty) throw new NoSuchElementException("queue empty")
- else {newOut.head, mkQueue(newIn, newOut.tail)}
+ else Pair(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: {A,Queue[A]} = dequeue;
+ val q: Pair[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 cd0fd432f9..dd3c7ebc94 100755
--- a/src/library/scala/collection/immutable/RedBlack.scala
+++ b/src/library/scala/collection/immutable/RedBlack.scala
@@ -19,7 +19,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[{A, B}]
+ def elements: Iterator[Pair[A, B]]
def upd[B1 >: B](k: A, v: B1): Tree[B1]
def del(k: A): Tree[B]
def smallest: NonEmpty[B]
@@ -67,8 +67,8 @@ abstract class RedBlack[A] {
}
}
def smallest: NonEmpty[B] = if (left.isEmpty) this else left.smallest
- def elements: Iterator[{A, B}] =
- left.elements append Iterator.single({key, value}) append right.elements
+ def elements: Iterator[Pair[A, B]] =
+ left.elements append Iterator.single(Pair(key, value)) append right.elements
}
[serializable]
case object Empty extends Tree[Nothing] {
@@ -78,7 +78,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[{A, Nothing}] = Iterator.empty
+ def elements: Iterator[Pair[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 bc69b7c4db..eef8842e39 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 {subHeight, subSize} = subtree.count
+ val Pair(subHeight, subSize) = subtree.count
val totalHeight = 2 * compat.Math.max(height, subHeight)
val totalSize = size + subSize + 1
val BalanceHeight = totalSize * totalSize
@@ -260,13 +260,13 @@ 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: {Int,Int}
+ def count: Pair[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[{A,B}]): List[{A,B}]
+ def toList(acc: List[Pair[A,B]]): List[Pair[A,B]]
def mk_iter(iter_tail: List[aNode]): List[aNode]
def delete(key: A): aNode
def merge(t: aNode): aNode
@@ -275,7 +275,7 @@ protected abstract class GBTree[A <% Ordered[A],B] extends AnyRef {
}
private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] {
- def count = {1, 0}
+ def count = Pair(1, 0)
def isDefinedAt(key: A) = false
def get(_key: A) = None
def apply(key: A) = throw new NoSuchElementException("key " + key + " not found")
@@ -286,7 +286,7 @@ private case class GBLeaf[A <% Ordered[A],B]() extends GBTree[A,B] {
else
ITree(GBNode(key, value, this, this))
}
- def toList(acc: List[{A,B}]): List[{A,B}] = acc
+ def toList(acc: List[Pair[A,B]]): List[Pair[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]] =
@@ -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: {Int,Int} = {
- val {sHeight, sSize} = smaller.count
- val {bHeight, bSize} = bigger.count
+ def count: Pair[Int,Int] = {
+ val Pair(sHeight, sSize) = smaller.count
+ val Pair(bHeight, bSize) = bigger.count
val mySize = sSize + bSize + 1
if (mySize == 1)
- {1, mySize}
+ Pair(1, mySize)
else
- {2 * compat.Math.max(sHeight, bHeight), mySize}
+ Pair(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[{A,B}]): List[{A,B}] =
- smaller.toList({key, value} :: bigger.toList(acc))
+ def toList(acc: List[Pair[A,B]]): List[Pair[A,B]] =
+ smaller.toList(Pair(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 {key1, value1, larger1} = larger.takeSmallest
+ val Triple(key1, value1, larger1) = larger.takeSmallest
GBNode(key1, value1, this, larger1)
}
def takeSmallest: Triple[A, B, aNode] = smaller match {
case GBLeaf() =>
- {key, value, bigger}
+ Triple(key, value, bigger)
case _ =>
- val {key1, value1, smaller1} = smaller.takeSmallest
- {key1, value1, GBNode(key, value, smaller1, bigger)}
+ val Triple(key1, value1, smaller1) = smaller.takeSmallest
+ Triple(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[{A,B}], s: int): GBTree[A,B] = {
+ protected def balance_list(list: List[Pair[A,B]], s: int): GBTree[A,B] = {
val empty = GBLeaf[A,B]();
- def bal(list: List[{A,B}], s: Int): {aNode, List[{A,B}]} = {
+ def bal(list: List[Pair[A,B]], s: Int): Pair[aNode, List[Pair[A,B]]] = {
if (s > 1) {
val sm = s - 1
val s2 = sm / 2
val s1 = sm - s2
- val {t1, {k, v} :: l1} = bal(list, s1)
- val {t2, l2} = bal(l1, s2)
+ val Pair(t1, Pair(k, v) :: l1) = bal(list, s1)
+ val Pair(t2, l2) = bal(l1, s2)
val t = GBNode(k, v, t1, t2)
- {t, l2}
+ Pair(t, l2)
} else if (s == 1) {
- val {k,v} :: rest = list
- {GBNode(k, v, empty, empty), rest}
+ val Pair(k,v) :: rest = list
+ Pair(GBNode(k, v, empty, empty), rest)
} else
- {empty, list}
+ Pair(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 22664f1e20..9e43f092df 100644
--- a/src/library/scala/collection/immutable/TreeMap.scala
+++ b/src/library/scala/collection/immutable/TreeMap.scala
@@ -25,7 +25,7 @@ object TreeMap {
/** The canonical factory for this type
*/
- def apply[A <% Ordered[A], B](elems: {A, B}*) = empty[A, B] ++ elems
+ def apply[A <% Ordered[A], B](elems: Pair[A, B]*) = empty[A, B] ++ elems
}
/** This class implements immutable maps using a tree.
@@ -104,7 +104,7 @@ extends RedBlack[A] with Map[A, B] {
*
* @return the new iterator
*/
- def elements: Iterator[{A, B}] = tree.elements
+ def elements: Iterator[Pair[A, B]] = tree.elements
}
diff --git a/src/library/scala/collection/immutable/UnbalancedTreeMap.scala b/src/library/scala/collection/immutable/UnbalancedTreeMap.scala
index dabc3a11cf..965c4729c6 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: {A, B}*) = empty[A, B] ++ elems
+ def apply[A<% Ordered[A], B](elems: Pair[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[{A, B}] = Iterator.empty
+ def elements: Iterator[Pair[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[{A, B}] =
- left.elements append Iterator.single({key, value}) append right.elements
+ override def elements: Iterator[Pair[A, B]] =
+ left.elements append Iterator.single(Pair(key, value)) append right.elements
}
}
diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala
index e506e95994..f840fc3a2a 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 {thiselem, thatelem} => thiselem == thatelem
+ case Pair(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 fac9603438..5d8f24393c 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[{Location, A}]]
+ with Scriptable[Message[Pair[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[{Location, A}]): Unit = cmd match {
- case Include({l, elem}) => l match {
+ def <<(cmd: Message[Pair[Location, A]]): Unit = cmd match {
+ case Include(Pair(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({l, elem}) => l match {
+ case Update(Pair(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({l, _}) => l match {
+ case Remove(Pair(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 adf7162954..5f1d60e333 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[{Location, A}]): Unit = self << cmd
+ override def <<(cmd: Message[Pair[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 9bf8b803b5..7148667849 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 => {e.key, e.value}}
+ def elements = entries map {e => Pair(e.key, e.value)}
}
diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala
index 59a8b8a860..863a535aef 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: {A, B}*) = empty[A, B] ++ elems
+ def apply[A, B](elems: Pair[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 dbafbf29dc..4143e6e9de 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[{B, A}] {
+class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[Pair[B, A]] {
- protected val log: Queue[{B, A}] = new Queue[{B, A}]
+ protected val log: Queue[Pair[B, A]] = new Queue[Pair[B, A]]
val maxHistory: Int = 1000
@@ -35,12 +35,12 @@ class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[{B, A}] {
if (log.length >= maxHistory) {
val old = log.dequeue;
}
- log.enqueue({pub, event})
+ log.enqueue(Pair(pub, event))
}
- def elements: Iterator[{B, A}] = log.elements
+ def elements: Iterator[Pair[B, A]] = log.elements
- def events: Iterator[A] = log.elements.map { case {_, e} => e }
+ def events: Iterator[A] = log.elements.map { case Pair(_, 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 9328f19629..37bbb9dce4 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[{A, B}] = imap.elements
+ def elements: Iterator[Pair[A, B]] = imap.elements
- override def toList: List[{A, B}] = imap.toList
+ override def toList: List[Pair[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 825758b64b..9b918836da 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[{A, B}] = new Iterator[{A, B}] {
+ def elements: Iterator[Pair[A, B]] = new Iterator[Pair[A, B]] {
val iter = jmap.keySet().iterator()
def hasNext = iter.hasNext()
def next = {
val key = iter.next().asInstanceOf[A]
- {key, apply(key)}
+ Pair(key, apply(key))
}
}
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 2f4b95f55f..55bd75d3fd 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 {thiselem, thatelem} => thiselem == thatelem
+ case Pair(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 8b0342e5d6..85b178fa82 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: {A, B}*) = empty[A, B] ++ elems
+ def apply[A, B](elems: Pair[A, B]*) = empty[A, B] ++ elems
}
[cloneable]
trait Map[A, B] extends AnyRef
with collection.Map[A, B]
- with Scriptable[Message[{A, B}]]
+ with Scriptable[Message[Pair[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,30 +53,30 @@ trait Map[A, B] extends AnyRef
/** Add a key/value pair to this map.
* @param kv the key/value pair.
*/
- def += (kv: {A, B}) { update(kv._1, kv._2) }
+ def += (kv: Pair[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: {A, B}, kv2: {A, B}, kvs: {A, B}*) { this += kv1; this += kv2; this ++= kvs }
+ def += (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[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[{A, B}]) { this ++= kvs.elements }
+ def ++= (kvs: Iterable[Pair[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[{A, B}]) { kvs foreach += }
+ def ++= (kvs: Iterator[Pair[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: {A, B}): Map[A, B] = { this += kv; this }
+ def + (kv: Pair[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.
@@ -84,7 +84,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: {A, B}, kv2: {A, B}, kvs: {A, B}*): Map[A, B] = {
+ def + (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*): Map[A, B] = {
this.+=(kv1, kv2, kvs: _*); this
}
@@ -92,13 +92,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[{A, B}]): Map[A, B] = { this ++= kvs; this }
+ def ++ (kvs: Iterable[Pair[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[{A, B}]): Map[A, B] = { this ++= kvs; this }
+ def ++ (kvs: Iterator[Pair[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
@@ -161,7 +161,7 @@ trait Map[A, B] extends AnyRef
*/
def transform(f: (A, B) => B) {
elements foreach {
- case {key, value} => update(key, f(key, value))
+ case Pair(key, value) => update(key, f(key, value))
}
}
@@ -171,17 +171,17 @@ trait Map[A, B] extends AnyRef
* @param p The test predicate
*/
def retain(p: (A, B) => Boolean): Unit = toList foreach {
- case {key, value} => if (!p(key, value)) -=(key)
+ case Pair(key, value) => if (!p(key, value)) -=(key)
}
/** Send a message to this scriptable object.
*
* @param cmd the message to send.
*/
- 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
+ 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
case Reset() => clear
case s: Script[_] => s.elements foreach <<
case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
@@ -210,7 +210,7 @@ trait Map[A, B] extends AnyRef
* @param mappings
* @deprecated use <code>+=</code>
*/
- [deprecated] def incl(mappings: {A, B}*): Unit = this ++= mappings.elements
+ [deprecated] def incl(mappings: Pair[A, B]*): Unit = this ++= mappings.elements
/** This method will remove all the mappings for the given sequence
* of keys from the map.
@@ -226,9 +226,9 @@ trait Map[A, B] extends AnyRef
* @deprecated use retain instead
* @param p
*/
- [deprecated] override def filter(p: {A, B} => Boolean): Iterable[{A, B}] = {
+ [deprecated] override def filter(p: Pair[A, B] => Boolean): Iterable[Pair[A, B]] = {
toList foreach {
- case kv @ {key, _} => if (!p(kv)) -=(key)
+ case kv @ Pair(key, _) => if (!p(kv)) -=(key)
}
this
}
diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala
index deea498609..431a9d5273 100644
--- a/src/library/scala/collection/mutable/MapProxy.scala
+++ b/src/library/scala/collection/mutable/MapProxy.scala
@@ -30,14 +30,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: {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 += (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 -= (key: A) = self -= key
override def -= (key1: A, key2: A, keys: A*) = self.-=(key1, key2, keys: _*)
override def --= (keys: Iterable[A]) = self --= keys
@@ -49,8 +49,8 @@ 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[{A, B}]): Unit = self << cmd
+ override def <<(cmd: Message[Pair[A, B]]): Unit = self << cmd
override def clone(): Map[A, B] = self.clone()
- [deprecated] override def incl(mappings: {A, B}*): Unit = self.incl(mappings: _*)
+ [deprecated] override def incl(mappings: Pair[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 0aa15611a6..57f474f6e8 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[{Location, A}]
+ with Publisher[Message[Pair[Location, A]]
with Undoable, This]
{
abstract override def +(element: A): Buffer[A] = {
super.+(element)
- publish(new Include({End, element}) with Undoable {
+ publish(new Include(Pair(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({Start, element}) with Undoable {
+ publish(new Include(Pair(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({Index(i), it.next}) with Undoable {
+ publish(new Include(Pair(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({Index(n), newelement}) with Undoable {
+ publish(new Update(Pair(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({Index(n), oldelement}) with Undoable {
+ publish(new Remove(Pair(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 626129343c..988eaf67c6 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[{A, B}]
+ with Publisher[Message[Pair[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({key, value}) with Undoable {
+ publish(new Include(Pair(key, value)) with Undoable {
def undo = -=(key)
})
case Some(old) =>
super.update(key, value)
- publish(new Update({key, value}) with Undoable {
+ publish(new Update(Pair(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({key, old}) with Undoable {
+ publish(new Remove(Pair(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 64a5ea0ddc..4f67392381 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 {thiselem, thatelem} => thiselem == thatelem
+ case Pair(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 e2b4d8d913..7c34c1f2ae 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -167,7 +167,7 @@ class Queue[A] extends MutableList[A] {
that.isInstanceOf[Queue[A]] &&
{ val other = that.asInstanceOf[Queue[A]]
elements.zip(other.elements).forall {
- case {thiselem, thatelem} => thiselem == thatelem
+ case Pair(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 f9fcb635b6..9ad19dedc7 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 {sub, event} => event.undo }
+ old.foreach { case Pair(sub, event) => event.undo }
}
}
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index 1aee74148e..e3890d22df 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -109,7 +109,7 @@ class Stack[A] extends MutableList[A] {
that.isInstanceOf[Stack[A]] &&
{ val other = that.asInstanceOf[Stack[A]];
elements.zip(other.elements).forall {
- case {thiselem, thatelem} => thiselem == thatelem
+ case Pair(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 b86f7d401b..652c6d535b 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[{Location, A}]): Unit = synchronized {
+ override def <<(cmd: Message[Pair[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 da317123f0..785e061a4e 100644
--- a/src/library/scala/collection/mutable/SynchronizedMap.scala
+++ b/src/library/scala/collection/mutable/SynchronizedMap.scala
@@ -57,11 +57,11 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
super.values
}
- abstract override def elements: Iterator[{A, B}] = synchronized {
+ abstract override def elements: Iterator[Pair[A, B]] = synchronized {
super.elements
}
- override def toList: List[{A, B}] = synchronized {
+ override def toList: List[Pair[A, B]] = synchronized {
super.toList
}
@@ -69,7 +69,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
super.update(key, value)
}
- override def += (kv: {A, B}): Unit = synchronized {
+ override def += (kv: Pair[A, B]): Unit = synchronized {
super.+=(kv)
}
@@ -78,19 +78,19 @@ 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: {A, B}, kv2: {A, B}, kvs: {A, B}*): Unit = synchronized {
+ override def += (kv1: Pair[A, B], kv2: Pair[A, B], kvs: Pair[A, B]*): Unit = synchronized {
super.+=(kv1, kv2, kvs: _*)
}
- override def ++=(map: Iterable[{A, B}]): Unit = synchronized {
+ override def ++=(map: Iterable[Pair[A, B]]): Unit = synchronized {
super.++=(map)
}
- override def ++=(it: Iterator[{A, B}]): Unit = synchronized {
+ override def ++=(it: Iterator[Pair[A, B]]): Unit = synchronized {
super.++=(it)
}
- [deprecated] override def incl(mappings: {A, B}*): Unit = synchronized {
+ [deprecated] override def incl(mappings: Pair[A, B]*): Unit = synchronized {
super.incl(mappings: _*)
}
@@ -122,7 +122,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
super.transform(f)
}
- [deprecated] override def map[C](f: {A, B} => C) = synchronized {
+ [deprecated] override def map[C](f: Pair[A, B] => C) = synchronized {
super.map(f)
}
@@ -131,7 +131,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
}
/** @deprecated use retain instead */
- [deprecated] override def filter(p: {A, B} => Boolean) = synchronized {
+ [deprecated] override def filter(p: Pair[A, B] => Boolean) = synchronized {
super.filter(p)
}
@@ -147,7 +147,7 @@ trait SynchronizedMap[A, B] extends Map[A, B] {
super.hashCode()
}
- override def <<(cmd: Message[{A, B}]): Unit = synchronized {
+ override def <<(cmd: Message[Pair[A, B]]): Unit = synchronized {
super.<<(cmd)
}
diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala
index b6ba205fa2..e1399e9e58 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{msg, withoutMsg} => {
+ case Some(Pair(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{receiver, withoutReceiver} => {
+ case Some(Pair(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[{a, t}]
+ def extractFirst(l: t, p: a => boolean): Option[Pair[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[{a, t}] =
+ def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] =
l match {
case Nil => None
case head :: tail =>
if (p(head))
- Some{head, tail}
+ Some(Pair(head, tail))
else
extractFirst(tail, p) match {
case None => None
- case Some{x, without_x} => Some{x, head :: without_x}
+ case Some(Pair(x, without_x)) => Some(Pair(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 = {LinkedList[a], LinkedList[a]} // fst = the list, snd = last elem
+ type t = Pair[LinkedList[a], LinkedList[a]] // fst = the list, snd = last elem
def make: t = {
val l = new LinkedList[a](null, null)
- {l, l}
+ Pair(l, l)
}
def append(l: t, x: a): t = {
val atTail = new LinkedList(x, null)
l._2 append atTail;
- {l._1, atTail}
+ Pair(l._1, atTail)
}
- def extractFirst(l: t, p: a => boolean): Option[{a, t}] = {
+ def extractFirst(l: t, p: a => boolean): Option[Pair[a, t]] = {
var xs = l._1
var xs1 = xs.next
while ((xs1 ne null) && !p(xs1.elem)) {
@@ -166,7 +166,7 @@ trait LinkedListQueueCreator {
if (xs.next eq null)
Some(Pair(xs1.elem, Pair(l._1, xs)))
else
- Some{xs1.elem, l}
+ Some(Pair(xs1.elem, l))
}
else
None
diff --git a/src/library/scala/concurrent/Process.scala b/src/library/scala/concurrent/Process.scala
index 3e8589e7ef..6aa2e5ff53 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({'EXIT, this, s}) }
+ links.foreach { p: Process => p.send(Triple('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 afa23c0cb3..d26190da20 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[{Pattern, Rule}] = null
+ private var ruls: List[Pair[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: {Pattern, Rule}*) =
- ruls = rs.asInstanceOf[List[{Pattern, Rule}]]
+ def rules(rs: Pair[Pattern, Rule]*) =
+ ruls = rs.asInstanceOf[List[Pair[Pattern, Rule]]]
def tryMatch =
- (ruls find { case {p, _} => canMatch(p) }) match {
+ ruls find { case Pair(p, _) => canMatch(p) } match {
case None => () => ()
- case Some{p, r} => {
+ case Some(Pair(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 1c5b0e1713..73cfedc676 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): {a, b} = {
+ def par[a, b](xp: => a, yp: => b): Pair[a, b] = {
val y = new SyncVar[b]
spawn { y set yp }
- {xp, y.get}
+ Pair(xp, y.get)
}
/**
diff --git a/src/library/scala/concurrent/pilib.scala b/src/library/scala/concurrent/pilib.scala
index bc76821884..449eb4f0fc 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[{() => 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} =>
+ 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) =>
if (a1 == a2 && d1 == !d2)
- Some{(() => if (d1) a1.log(v2) else a1.log(v1)), (() => c1(v2)), (() => c2(v1))}
+ Some(Triple((() => 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{log, c1, c2} =>
+ case Some(Triple(log, c1, c2)) =>
log()
s1.set(c1)
s2.set(c2)
diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala
index 2f2b6c3832..e90d7015a3 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 => {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 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 _ =>
val x = value.asInstanceOf[JObject]
- {x, x.getClass()}
+ Pair(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 fb1acbc650..de5dc52479 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[{Type, Type}], resultType: Type) extends Type
+case class PolyType(typeParams: List[Symbol], typeBounds: List[Pair[Type, Type]], resultType: Type) extends Type
/** */
class ImplicitMethodType(formals: List[Type], restpe: Type)
diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala
index 4818c342fd..70e7bc8fc7 100644
--- a/src/library/scala/text/Document.scala
+++ b/src/library/scala/text/Document.scala
@@ -50,20 +50,20 @@ abstract class Document {
false
case List() =>
true
- case {_, _, DocNil} :: z =>
+ case Triple(_, _, DocNil) :: z =>
fits(w, z)
- case {i, b, DocCons(h, t)} :: z =>
- fits(w, {i,b,h} :: {i,b,t} :: z)
- case {_, _, DocText(t)} :: 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 =>
fits(w - t.length(), z)
- case {i, b, DocNest(ii, d)} :: z =>
- fits(w, {i + ii, b, d} :: z)
- case {_, false, DocBreak} :: z =>
+ case Triple(i, b, DocNest(ii, d)) :: z =>
+ fits(w, Triple(i + ii, b, d) :: z)
+ case Triple(_, false, DocBreak) :: z =>
fits(w - 1, z)
- case {_, true, DocBreak} :: z =>
+ case Triple(_, true, DocBreak) :: z =>
true
- case {i, _, DocGroup(d)} :: z =>
- fits(w, {i, false, d} :: z)
+ case Triple(i, _, DocGroup(d)) :: z =>
+ fits(w, Triple(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 {_, _, DocNil} :: z =>
+ case Triple(_, _, DocNil) :: z =>
fmt(k, z)
- case {i, b, DocCons(h, t)} :: z =>
- fmt(k, {i, b, h} :: {i, b, t} :: z)
- case {i, _, DocText(t)} :: 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 =>
writer write t
fmt(k + t.length(), z)
- case {i, b, DocNest(ii, d)} :: z =>
- fmt(k, {i + ii, b, d} :: z)
- case {i, true, DocBreak} :: z =>
+ case Triple(i, b, DocNest(ii, d)) :: z =>
+ fmt(k, Triple(i + ii, b, d) :: z)
+ case Triple(i, true, DocBreak) :: z =>
writer write "\n"
spaces(i);
fmt(i, z)
- case {i, false, DocBreak} :: z =>
+ case Triple(i, false, DocBreak) :: z =>
writer write " "
fmt(k + 1, z)
- case {i, b, DocGroup(d)} :: z =>
- val fitsFlat = fits(width - k, {i, false, d} :: z)
- fmt(k, {i, !fitsFlat, d} :: 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)
}
- fmt(0, {0, false, DocGroup(this)} :: Nil)
+ fmt(0, Triple(0, false, DocGroup(this)) :: Nil)
}
}