From 100951d18780675748fdc548a60fd5df629d8aba Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 3 Feb 2007 16:45:20 +0000 Subject: --- src/compiler/scala/tools/nsc/Global.scala | 4 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 4 +- .../scala/tools/nsc/ast/TreePrinters.scala | 8 +- src/compiler/scala/tools/nsc/ast/Trees.scala | 32 ++--- .../scala/tools/nsc/ast/parser/Parsers.scala | 31 ++--- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 14 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 2 +- .../scala/tools/nsc/matching/PatternMatchers.scala | 5 +- src/compiler/scala/tools/nsc/models/Models.scala | 2 +- src/compiler/scala/tools/nsc/symtab/Types.scala | 150 ++++++++++----------- .../nsc/symtab/classfile/ClassfileParser.scala | 12 +- .../tools/nsc/symtab/classfile/PickleFormat.scala | 3 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 17 ++- .../tools/nsc/symtab/classfile/UnPickler.scala | 34 +++-- .../scala/tools/nsc/transform/Erasure.scala | 4 +- .../scala/tools/nsc/transform/ExplicitOuter.scala | 2 +- .../scala/tools/nsc/transform/TailCalls.scala | 4 +- .../scala/tools/nsc/transform/UnCurry.scala | 7 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 2 +- .../tools/nsc/typechecker/SyntheticMethods.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 4 +- .../collection/mutable/ImmutableMapAdaptor.scala | 12 -- .../scala/collection/mutable/MapProxy.scala | 2 - test/files/jvm/serialization.check | 4 +- test/files/run/arrays.scala | 2 +- 25 files changed, 186 insertions(+), 177 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 9a3f66483e..e32544f12d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -503,7 +503,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable showDef(newTermName(settings.Xshowobj.value), true) if (reporter.hasErrors) { - for (val Pair(sym, file) <- symSource.elements) { + for (val {sym, file} <- symSource.elements) { sym.reset(new loaders.SourcefileLoader(file)) if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader) } @@ -516,7 +516,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable warning("there were unchecked warnings; re-run with -unchecked for details") } } - for (val Pair(sym, file) <- symSource.elements) resetPackageClass(sym.owner) + for (val {sym, file} <- symSource.elements) resetPackageClass(sym.owner) //units foreach (.clear()) informTime("total", startTime) } diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index ce17c7f1ee..b0e3fa4838 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -305,7 +305,7 @@ abstract class TreeBrowsers { case Bind(name, rhs) => Pair("Bind", name) - case Match(selector, cases) => + case Match(selector, cases, _) => Pair("Visitor", EMPTY) case Function(vparams, body) => @@ -449,7 +449,7 @@ abstract class TreeBrowsers { case Bind(name, rhs) => List(rhs) - case Match(selector, cases) => + case Match(selector, cases, _) => selector :: cases case Function(vparams, body) => diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index b94fecddd3..0e687d7bfc 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -113,7 +113,7 @@ abstract class TreePrinters { if (!args.isEmpty) str.append(args.map(.escapedStringValue).mkString("(", ",", ")")) if (!nvPairs.isEmpty) - for (val Pair(Pair(name, value), index) <- nvPairs.zipWithIndex) { + for (val {Pair(name, value), index} <- nvPairs.zipWithIndex) { if (index > 0) str.append(", ") str.append(name).append(" = ").append(value) @@ -187,7 +187,7 @@ abstract class TreePrinters { print(symName(tree, name)); printRow(params, "(", ",", ")"); printBlock(rhs) case Import(expr, selectors) => - def selectorToString(s: Pair[Name, Name]): String = + def selectorToString(s: {Name, Name}): String = if (s._1 == nme.WILDCARD || s._1 == s._2) s._1.toString() else s._1.toString() + "=>" + s._2.toString() print("import "); print(expr) @@ -211,8 +211,8 @@ abstract class TreePrinters { case Block(stats, expr) => printColumn(stats ::: List(expr), "{", ";", "}") - case Match(selector, cases) => - print(selector); printColumn(cases, " match {", "", "}") + case Match(selector, cases, check) => + print(selector); printColumn(cases, if (check) " match {" else "match! {", "", "}") case CaseDef(pat, guard, body) => print("case "); print(pat); printOpt(" if ", guard) diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 694383abe9..b575e2e1f6 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[Pair[Name, Name]]) + case class Import(expr: Tree, selectors: List[{Name, Name}]) extends SymTree /** Attribute application (constructor arguments + name-value pairs) */ @@ -537,7 +537,7 @@ trait Trees requires Global { * Ident(nme.WILDCARD) * */ - case class Match(selector: Tree, cases: List[CaseDef]) + case class Match(selector: Tree, cases: List[CaseDef], checkExhaustive: boolean) extends TermTree /** Return expression */ @@ -712,7 +712,7 @@ trait Trees requires Global { case Function(vparams, body) => (eliminated by lambdaLift) case Assign(lhs, rhs) => case If(cond, thenp, elsep) => - case Match(selector, cases) => + case Match(selector, cases, check) => case Return(expr) => case Try(block, catches, finalizer) => case Throw(expr) => @@ -743,7 +743,7 @@ trait Trees requires Global { def AbsTypeDef(tree: Tree, mods: Modifiers, name: Name, lo: Tree, hi: Tree): AbsTypeDef def AliasTypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[AbsTypeDef], rhs: Tree): AliasTypeDef def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]): Import + def Import(tree: Tree, expr: Tree, selectors: List[{Name, Name}]): Import def Attribute(tree: Tree, constr: Tree, elements: List[Tree]): Attribute def DocDef(tree: Tree, comment: String, definition: Tree): DocDef def Template(tree: Tree, parents: List[Tree], body: List[Tree]): Template @@ -758,7 +758,7 @@ trait Trees requires Global { def Function(tree: Tree, vparams: List[ValDef], body: Tree): Function def Assign(tree: Tree, lhs: Tree, rhs: Tree): Assign def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree): If - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]): Match + def Match(tree: Tree, selector: Tree, cases: List[CaseDef], check: boolean): Match def Return(tree: Tree, expr: Tree): Return def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree): Try def Throw(tree: Tree, expr: Tree): Throw @@ -797,7 +797,7 @@ trait Trees requires Global { new AliasTypeDef(mods, name, tparams, rhs).copyAttrs(tree) def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree) = new LabelDef(name, params, rhs).copyAttrs(tree) - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) = + def Import(tree: Tree, expr: Tree, selectors: List[{Name, Name}]) = new Import(expr, selectors).copyAttrs(tree) def Attribute(tree: Tree, constr: Tree, elements: List[Tree]) = new Attribute(constr, elements) @@ -827,8 +827,8 @@ trait Trees requires Global { new Assign(lhs, rhs).copyAttrs(tree) def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree) = new If(cond, thenp, elsep).copyAttrs(tree) - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]) = - new Match(selector, cases).copyAttrs(tree) + def Match(tree: Tree, selector: Tree, cases: List[CaseDef], check: boolean) = + new Match(selector, cases, check).copyAttrs(tree) def Return(tree: Tree, expr: Tree) = new Return(expr).copyAttrs(tree) def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree) = @@ -912,7 +912,7 @@ trait Trees requires Global { if (name0 == name) && (params0 == params) && (rhs0 == rhs) => t case _ => copy.LabelDef(tree, name, params, rhs) } - def Import(tree: Tree, expr: Tree, selectors: List[Pair[Name, Name]]) = tree match { + def Import(tree: Tree, expr: Tree, selectors: List[{Name, Name}]) = tree match { case t @ Import(expr0, selectors0) if (expr0 == expr) && (selectors0 == selectors) => t case _ => copy.Import(tree, expr, selectors) @@ -987,10 +987,10 @@ trait Trees requires Global { if (cond0 == cond) && (thenp0 == thenp) && (elsep0 == elsep) => t case _ => copy.If(tree, cond, thenp, elsep) } - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]) = tree match { - case t @ Match(selector0, cases0) - if (selector0 == selector) && (cases0 == cases) => t - case _ => copy.Match(tree, selector, cases) + def Match(tree: Tree, selector: Tree, cases: List[CaseDef], check: boolean) = tree match { + case t @ Match(selector0, cases0, check0) + if (selector0 == selector) && (cases0 == cases) && (check0 == check) => t + case _ => copy.Match(tree, selector, cases, check) } def Return(tree: Tree, expr: Tree) = tree match { case t @ Return(expr0) @@ -1161,8 +1161,8 @@ trait Trees requires Global { copy.Assign(tree, transform(lhs), transform(rhs)) case If(cond, thenp, elsep) => copy.If(tree, transform(cond), transform(thenp), transform(elsep)) - case Match(selector, cases) => - copy.Match(tree, transform(selector), transformCaseDefs(cases)) + case Match(selector, cases, check) => + copy.Match(tree, transform(selector), transformCaseDefs(cases), check) case Return(expr) => copy.Return(tree, transform(expr)) case Try(block, catches, finalizer) => @@ -1299,7 +1299,7 @@ trait Trees requires Global { traverse(lhs); traverse(rhs) case If(cond, thenp, elsep) => traverse(cond); traverse(thenp); traverse(elsep) - case Match(selector, cases) => + case Match(selector, cases, _) => traverse(selector); traverseTrees(cases) case Return(expr) => traverse(expr) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index e543e54bce..9a8810e330 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -823,7 +823,7 @@ trait Parsers requires SyntaxAnalyzer { * | SimpleExpr ArgumentExprs `=' Expr * | `.' SimpleExpr * | PostfixExpr [`:' CompoundType] - * | PostfixExpr match `{' CaseClauses `}' + * | PostfixExpr match [`!'] `{' CaseClauses `}' * | MethodClosure * Bindings ::= `(' [Binding {`,' Binding}] `)' * Binding ::= Id [`:' Type] @@ -954,10 +954,12 @@ trait Parsers requires SyntaxAnalyzer { } } else if (in.token == MATCH) { t = atPos(in.skipToken()) { + val nocheck = isIdent && in.name == BANG + if (nocheck) in.nextToken() accept(LBRACE) val cases = caseClauses() accept(RBRACE) - Match(t, cases): Tree + Match(t, cases, !nocheck) } } if ((mode & ClosureOK) != 0 && in.token == ARROW) { @@ -1145,7 +1147,7 @@ trait Parsers requires SyntaxAnalyzer { */ def blockExpr(): Tree = { val res = atPos(accept(LBRACE)) { - if (in.token == CASE) makeVisitor(caseClauses()) + if (in.token == CASE) makeVisitor(caseClauses(), true) else blockOrTuple(true) } accept(RBRACE) @@ -1688,7 +1690,7 @@ trait Parsers requires SyntaxAnalyzer { def loop: Tree = if (in.token == USCORE) { in.nextToken() - Import(t, List(Pair(nme.WILDCARD, null))) + Import(t, List({nme.WILDCARD, null})) } else if (in.token == LBRACE) { Import(t, importSelectors()) } else { @@ -1698,7 +1700,7 @@ trait Parsers requires SyntaxAnalyzer { pos = accept(DOT) loop } else { - Import(t, List(Pair(name, name))) + Import(t, List({name, name})) } } loop @@ -1706,8 +1708,8 @@ trait Parsers requires SyntaxAnalyzer { /** ImportSelectors ::= `{' {ImportSelector `,'} (ImportSelector | `_') `}' */ - def importSelectors(): List[Pair[Name, Name]] = { - val names = new ListBuffer[Pair[Name, Name]] + def importSelectors(): List[{Name, Name}] = { + val names = new ListBuffer[{Name, Name}] accept(LBRACE) var isLast = importSelector(names) while (!isLast && in.token == COMMA) { @@ -1720,19 +1722,19 @@ trait Parsers requires SyntaxAnalyzer { /** ImportSelector ::= Id [`=>' Id | `=>' `_'] */ - def importSelector(names: ListBuffer[Pair[Name, Name]]): boolean = + def importSelector(names: ListBuffer[{Name, Name}]): boolean = if (in.token == USCORE) { - in.nextToken(); names += Pair(nme.WILDCARD, null); true + in.nextToken(); names += {nme.WILDCARD, null}; true } else { val name = ident() - names += Pair( + names += { name, if (in.token == ARROW) { in.nextToken() if (in.token == USCORE) { in.nextToken(); nme.WILDCARD } else ident() } else { name - }) + }} false } @@ -1805,9 +1807,9 @@ trait Parsers requires SyntaxAnalyzer { */ def varDefOrDcl(mods: Modifiers): List[Tree] = { var newmods = mods | Flags.MUTABLE - val lhs = new ListBuffer[Pair[Int, Name]] + val lhs = new ListBuffer[{Int, Name}] do { - lhs += Pair(in.skipToken(), ident()) + lhs += {in.skipToken(), ident()} } while (in.token == COMMA) val tp = typedOpt() val rhs = if (tp.isEmpty || in.token == EQUALS) { @@ -1822,7 +1824,7 @@ trait Parsers requires SyntaxAnalyzer { newmods = newmods | Flags.DEFERRED EmptyTree } - for (val Pair(pos, name) <- lhs.toList) yield + for (val {pos, name} <- lhs.toList) yield atPos(pos) { ValDef(newmods, name, tp.duplicate, rhs.duplicate) } } @@ -2167,7 +2169,6 @@ trait Parsers requires SyntaxAnalyzer { exps.toList } - /** RefineStatSeq ::= RefineStat {StatementSeparator RefineStat} * RefineStat ::= Dcl * | type TypeDef diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 32b5f2bce2..91490f1c9c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -195,6 +195,7 @@ abstract class TreeBuilder { List( CaseDef(pat1.duplicate, EmptyTree, Literal(true)), CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))), + false, nme.CHECK_IF_REFUTABLE_STRING ))) } @@ -257,7 +258,7 @@ abstract class TreeBuilder { case Some(Pair(name, tpt)) => Function(List(ValDef(Modifiers(PARAM), name, tpt, EmptyTree)), body) case None => - makeVisitor(List(CaseDef(pat, EmptyTree, body))) + makeVisitor(List(CaseDef(pat, EmptyTree, body)), false) } def makeCombination(meth: Name, qual: Tree, pat: Tree, body: Tree): Tree = @@ -356,13 +357,14 @@ abstract class TreeBuilder { makeAlternative(List(p, Sequence(List()))) /** Create visitor x match cases> */ - def makeVisitor(cases: List[CaseDef]): Tree = - makeVisitor(cases, "x$") + def makeVisitor(cases: List[CaseDef], checkExhaustive: boolean): Tree = + makeVisitor(cases, checkExhaustive, "x$") /** Create visitor x match cases> */ - def makeVisitor(cases: List[CaseDef], prefix: String): Tree = { + def makeVisitor(cases: List[CaseDef], checkExhaustive: boolean, prefix: String): Tree = { val x = freshName(prefix) - Function(List(ValDef(Modifiers(PARAM | SYNTHETIC), x, TypeTree(), EmptyTree)), Match(Ident(x), cases)) + Function(List(ValDef(Modifiers(PARAM | SYNTHETIC), x, TypeTree(), EmptyTree)), + Match(Ident(x), cases, checkExhaustive)) } /** Create tree for case definition <case pat if guard => rhs> */ @@ -393,7 +395,7 @@ abstract class TreeBuilder { val pat1 = patvarTransformer.transform(pat) val vars = getVariables(pat1) val matchExpr = atPos(pat1.pos){ - Match(rhs, List(CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (._1) map Ident, true)))) + Match(rhs, List(CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (._1) map Ident, true))), false) } vars match { case List() => diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 37b2a39ab8..82f6eadc44 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -892,7 +892,7 @@ abstract class GenICode extends SubComponent { } ctx1 - case Match(selector, cases) => + case Match(selector, cases, _) => if (settings.debug.value) log("Generating SWITCH statement."); var ctx1 = genLoad(selector, ctx, INT) diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 931e9d9ca7..42a3210ea8 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -1003,7 +1003,7 @@ print() return Switch(selector, tags, bodies, defaultBody1, resultType); */ nCases = CaseDef(Ident(nme.WILDCARD), squeezedBlock(List(ValDef(root.symbol, selector)),defaultBody1)) :: nCases; - Match(selector, nCases) + Match(selector, nCases, false) } @@ -1310,7 +1310,8 @@ print() nCases = CaseDef(Ident(nme.WILDCARD), defBody) :: nCases; return Match(Apply(Select(selector.duplicate, defs.ScalaObjectClass_tag), List()), - nCases); + nCases, + false) } /** why not use plain `if's? the reason is that a failing *guard* must still remain diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala index 1fe18a0ff5..d29dce02ab 100644 --- a/src/compiler/scala/tools/nsc/models/Models.scala +++ b/src/compiler/scala/tools/nsc/models/Models.scala @@ -404,7 +404,7 @@ abstract class Models { flatten(expr0,filter) case Try(block, catches, finalizer) => flatten(block, filter) ::: flatten(finalizer, filter) ::: flatten0(catches, filter) - case Match(selector, cases) => + case Match(selector, cases, _) => flatten(selector, filter) ::: flatten0(cases, filter) case Apply(fun, args) => flatten(fun, filter) ::: flatten0(args, filter) diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index bdf4a4edf8..b68d487d79 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1878,40 +1878,40 @@ trait Types requires SymbolTable { * equivalent types. */ def isSameType(tp1: Type, tp2: Type): boolean = { - Pair(tp1, tp2) match { - case Pair(ErrorType, _) => true - case Pair(WildcardType, _) => true - case Pair(_, ErrorType) => true - case Pair(_, WildcardType) => true - - case Pair(NoType, _) => false - case Pair(NoPrefix, _) => tp2.symbol.isPackageClass - case Pair(_, NoType) => false - case Pair(_, NoPrefix) => tp1.symbol.isPackageClass - - case Pair(ThisType(sym1), ThisType(sym2)) + {tp1, tp2} match { + case {ErrorType, _} => true + case {WildcardType, _} => true + case {_, ErrorType} => true + case {_, WildcardType} => true + + case {NoType, _} => false + case {NoPrefix, _} => tp2.symbol.isPackageClass + case {_, NoType} => false + case {_, NoPrefix} => tp1.symbol.isPackageClass + + case {ThisType(sym1), ThisType(sym2)} if (sym1 == sym2) => true - case Pair(SingleType(pre1, sym1), SingleType(pre2, sym2)) + case {SingleType(pre1, sym1), SingleType(pre2, sym2)} if ((sym1 == sym2) && (pre1 =:= pre2)) => true /* - case Pair(SingleType(pre1, sym1), ThisType(sym2)) + case {SingleType(pre1, sym1), ThisType(sym2)} if (sym1.isModule && sym1.moduleClass == sym2 && pre1 =:= sym2.owner.thisType) => true - case Pair(ThisType(sym1), SingleType(pre2, sym2)) + case {ThisType(sym1), SingleType(pre2, sym2)} if (sym2.isModule && sym2.moduleClass == sym1 && pre2 =:= sym1.owner.thisType) => true */ - case Pair(ConstantType(value1), ConstantType(value2)) => + case {ConstantType(value1), ConstantType(value2)} => value1 == value2 - case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => + case {TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)} => sym1 == sym2 && (phase.erasedTypes || pre1 =:= pre2) && isSameTypes(args1, args2) - case Pair(RefinedType(parents1, ref1), RefinedType(parents2, ref2)) => + case {RefinedType(parents1, ref1), RefinedType(parents2, ref2)} => def isSubScope(s1: Scope, s2: Scope): boolean = s2.toList.forall { sym2 => val sym1 = s1.lookup(sym2.name) @@ -1920,31 +1920,31 @@ trait Types requires SymbolTable { } //Console.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)//DEBUG isSameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1) - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + case {MethodType(pts1, res1), MethodType(pts2, res2)} => (pts1.length == pts2.length && isSameTypes(pts1, pts2) && res1 =:= res2 && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case {PolyType(tparams1, res1), PolyType(tparams2, res2)} => (tparams1.length == tparams2.length && List.forall2(tparams1, tparams2) ((p1, p2) => p1.info =:= p2.info.substSym(tparams2, tparams1)) && res1 =:= res2.substSym(tparams2, tparams1)) - case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => + case {TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)} => lo1 =:= lo2 && hi1 =:= hi2 - case Pair(BoundedWildcardType(bounds), _) => + case {BoundedWildcardType(bounds), _} => bounds containsType tp2 - case Pair(_, BoundedWildcardType(bounds)) => + case {_, BoundedWildcardType(bounds)} => bounds containsType tp1 - case Pair(TypeVar(_, constr1), _) => + case {TypeVar(_, constr1), _} => if (constr1.inst != NoType) constr1.inst =:= tp2 else constr1 instantiate (wildcardToTypeVarMap(tp2)) - case Pair(_, TypeVar(_, constr2)) => + case {_, TypeVar(_, constr2)} => if (constr2.inst != NoType) tp1 =:= constr2.inst else constr2 instantiate (wildcardToTypeVarMap(tp1)) - case Pair(AttributedType(_,atp), _) => + case {AttributedType(_,atp), _} => isSameType(atp, tp2) - case Pair(_, AttributedType(_,atp)) => + case {_, AttributedType(_,atp)} => isSameType(tp1, atp) case _ => if (tp1.isStable && tp2.isStable) { @@ -1981,24 +1981,24 @@ trait Types requires SymbolTable { * @return ... */ def isSubType0(tp1: Type, tp2: Type): boolean = { - Pair(tp1, tp2) match { - case Pair(ErrorType, _) => true - case Pair(WildcardType, _) => true - case Pair(_, ErrorType) => true - case Pair(_, WildcardType) => true - - case Pair(NoType, _) => false - case Pair(NoPrefix, _) => tp2.symbol.isPackageClass - case Pair(_, NoType) => false - case Pair(_, NoPrefix) => tp1.symbol.isPackageClass - - case Pair(ThisType(_), ThisType(_)) => tp1 =:= tp2 - case Pair(ThisType(_), SingleType(_, _)) => tp1 =:= tp2 - case Pair(SingleType(_, _), ThisType(_)) => tp1 =:= tp2 - case Pair(SingleType(_, _), SingleType(_, _)) => tp1 =:= tp2 - case Pair(ConstantType(_), ConstantType(_)) => tp1 =:= tp2 - - case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => + {tp1, tp2} match { + case {ErrorType, _} => true + case {WildcardType, _} => true + case {_, ErrorType} => true + case {_, WildcardType} => true + + case {NoType, _} => false + case {NoPrefix, _} => tp2.symbol.isPackageClass + case {_, NoType} => false + case {_, NoPrefix} => tp1.symbol.isPackageClass + + case {ThisType(_), ThisType(_)} => tp1 =:= tp2 + case {ThisType(_), SingleType(_, _)} => tp1 =:= tp2 + case {SingleType(_, _), ThisType(_)} => tp1 =:= tp2 + case {SingleType(_, _), SingleType(_, _)} => tp1 =:= tp2 + case {ConstantType(_), ConstantType(_)} => tp1 =:= tp2 + + case {TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)} => //Console.println("isSubType " + tp1 + " " + tp2);//DEBUG def isSubArgs(tps1: List[Type], tps2: List[Type], tparams: List[Symbol]): boolean = ( @@ -2026,50 +2026,50 @@ trait Types requires SymbolTable { || // Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass)) sym1 == AllRefClass && sym2.isClass && sym2 != AllClass && (sym2 isSubClass ObjectClass)) - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + case {MethodType(pts1, res1), MethodType(pts2, res2)} => (pts1.length == pts2.length && matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && (res1 <:< res2) && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case {PolyType(tparams1, res1), PolyType(tparams2, res2)} => (tparams1.length == tparams2.length && List.forall2(tparams1, tparams2) ((p1, p2) => p2.info.substSym(tparams2, tparams1) <:< p1.info) && res1 <:< res2.substSym(tparams2, tparams1)) - case Pair(TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => + case {TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)} => lo2 <:< lo1 && hi1 <:< hi2 - case Pair(BoundedWildcardType(bounds), _) => + case {BoundedWildcardType(bounds), _} => bounds.lo <:< tp2 - case Pair(_, BoundedWildcardType(bounds)) => + case {_, BoundedWildcardType(bounds)} => tp1 <:< bounds.hi - case Pair(_, TypeVar(_, constr2)) => + case {_, TypeVar(_, constr2)} => if (constr2.inst != NoType) tp1 <:< constr2.inst else { constr2.lobounds = tp1 :: constr2.lobounds; true } - case Pair(TypeVar(_, constr1), _) => + case {TypeVar(_, constr1), _} => if (constr1.inst != NoType) constr1.inst <:< tp2 else { constr1.hibounds = tp2 :: constr1.hibounds; true } - case Pair(AttributedType(_,atp1), _) => + case {AttributedType(_,atp1), _} => atp1 <:< tp2 - case Pair(_, AttributedType(_,atp2)) => + case {_, AttributedType(_,atp2)} => tp1 <:< atp2 - case Pair(_, TypeRef(pre2, sym2, args2)) + case {_, TypeRef(pre2, sym2, args2)} if sym2.isAbstractType && !(tp2 =:= tp2.bounds.lo) && (tp1 <:< tp2.bounds.lo) => true - case Pair(_, RefinedType(parents2, ref2)) => + case {_, RefinedType(parents2, ref2)} => (parents2 forall tp1.<:<) && (ref2.toList forall tp1.specializes) && (!parents2.exists(.symbol.isAbstractType) || tp1.symbol != AllRefClass) - case Pair(RefinedType(parents1, ref1), _) => + case {RefinedType(parents1, ref1), _} => parents1 exists (.<:<(tp2)) /* todo: replace following with - case Pair(ThisType(_), _) - | Pair(SingleType(_, _), _) - | Pair(ConstantType(_), _) => + case {ThisType(_), _} + | {SingleType(_, _), _} + | {ConstantType(_), _} => once patern matching bug is fixed */ - case Pair(ThisType(_), _) => tp1.singleDeref <:< tp2 - case Pair(SingleType(_, _), _) => tp1.singleDeref <:< tp2 - case Pair(ConstantType(_), _) => tp1.singleDeref <:< tp2 + case {ThisType(_), _} => tp1.singleDeref <:< tp2 + case {SingleType(_, _), _} => tp1.singleDeref <:< tp2 + case {ConstantType(_), _} => tp1.singleDeref <:< tp2 - case Pair(TypeRef(pre1, sym1, args1), _) => + case {TypeRef(pre1, sym1, args1), _} => (sym1 == AllClass && tp2 <:< AnyClass.tpe || sym1 == AllRefClass && tp2.isInstanceOf[SingletonType] && (tp1 <:< tp2.widen)) @@ -2114,21 +2114,21 @@ trait Types requires SymbolTable { } /** A function implementing tp1 matches tp2 */ - private def matchesType(tp1: Type, tp2: Type): boolean = Pair(tp1, tp2) match { - case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) => + private def matchesType(tp1: Type, tp2: Type): boolean = {tp1, tp2} match { + case {MethodType(pts1, res1), MethodType(pts2, res2)} => (matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) && (res1 matches res2) && tp1.isInstanceOf[ImplicitMethodType] == tp2.isInstanceOf[ImplicitMethodType]) - case Pair(PolyType(tparams1, res1), PolyType(tparams2, res2)) => + case {PolyType(tparams1, res1), PolyType(tparams2, res2)} => (tparams1.length == tparams2.length && (res1 matches res2.substSym(tparams2, tparams1))) - case Pair(PolyType(List(), rtp1), MethodType(List(), rtp2)) => matchesType(rtp1, rtp2) - case Pair(MethodType(List(), rtp1), PolyType(List(), rtp2)) => matchesType(rtp1, rtp2) - case Pair(PolyType(List(), rtp1), _) => matchesType(rtp1, tp2) - case Pair(_, PolyType(List(), rtp2)) => matchesType(tp1, rtp2) - case Pair(MethodType(_, _), _) => false - case Pair(PolyType(_, _), _) => false - case Pair(_, MethodType(_, _)) => false - case Pair(_, PolyType(_, _)) => false + case {PolyType(List(), rtp1), MethodType(List(), rtp2)} => matchesType(rtp1, rtp2) + case {MethodType(List(), rtp1), PolyType(List(), rtp2)} => matchesType(rtp1, rtp2) + case {PolyType(List(), rtp1), _} => matchesType(rtp1, tp2) + case {_, PolyType(List(), rtp2)} => matchesType(tp1, rtp2) + case {MethodType(_, _), _} => false + case {PolyType(_, _), _} => false + case {_, MethodType(_, _)} => false + case {_, PolyType(_, _)} => false case _ => !phase.erasedTypes || tp1 =:= tp2 } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index c0850ddb0a..058e6bf675 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -47,8 +47,7 @@ abstract class ClassfileParser { protected var isScala: boolean = _ // does class file describe a scala class? protected var hasMeta: boolean = _ // does class file contain jaco meta attribute?s protected var busy: boolean = false // lock to detect recursive reads - protected var classTParams: Map[Name,Symbol] = - collection.immutable.ListMap.Empty[Name,Symbol] + protected var classTParams = Map[Name,Symbol]() protected val fresh = new scala.tools.nsc.util.FreshNameCreator private object metaParser extends MetaParser { @@ -362,12 +361,13 @@ abstract class ClassfileParser { val c = pool.getClassSymbol(in.nextChar) if (c != clazz) throw new IOException("class file '" + in.file + "' contains wrong " + c) - val superType = if (isAttribute) { in.nextChar; definitions.ClassfileAttributeClass.tpe } + val superType = if (isAttribute) { in.nextChar; definitions.AttributeClass.tpe } else pool.getSuperClass(in.nextChar).tpe val ifaceCount = in.nextChar - val parents = (superType :: - (for (val i <- List.range(0, ifaceCount)) - yield pool.getSuperClass(in.nextChar).tpe)) + var ifaces = for (val i <- List.range(0, ifaceCount)) yield pool.getSuperClass(in.nextChar).tpe + if (isAttribute) ifaces = definitions.ClassfileAttributeClass.tpe :: ifaces + val parents = superType :: ifaces + instanceDefs = newScope staticDefs = newScope val classInfo = ClassInfoType(parents, instanceDefs, clazz) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala index e31b29eaf6..9e8b55e678 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala @@ -51,6 +51,7 @@ object PickleFormat { * | 34 LITERALnull len_Nat * | 35 LITERALclass len_Nat type_Ref * | 40 ATTRIBUTE len_Nat sym_Ref info_Ref {constant_Ref} {nameRef constantRef} + * | 41 CHILDREN len_Nat sym_Ref {sym_Ref} * | 72 PosTYPEsym len_Nat pos_Nat SymbolInfo * | 73 PosALIASsym len_Nat pos_Nat SymbolInfo * | 74 PosCLASSsym len_Nat pos_Nat SymbolInfo [thistype_Ref] @@ -102,7 +103,7 @@ object PickleFormat { final val LITERALnull = 34 final val LITERALclass = 35 final val ATTRIBUTE = 40 - + final val CHILDREN = 41 final val firstSymTag = NONEsym final val lastSymTag = VALsym final val lastExtSymTag = EXTMODCLASSref diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index a0cf082760..faa15d9c92 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -108,6 +108,8 @@ abstract class Pickler extends SubComponent { if (sym.thisSym != sym) putType(sym.typeOfThis); putSymbol(sym.alias) + if (!sym.children.isEmpty) + putChildren(sym, sym.children) for (val attr <- sym.attributes.reverse) { if (attr.atp.symbol isNonBottomSubClass definitions.StaticAttributeClass) @@ -166,8 +168,13 @@ abstract class Pickler extends SubComponent { else if (c.tag == ClassTag) putEntry(c.typeValue) } + private def putChildren(sym: Symbol, children: Set[Symbol]): unit = { + assert(putEntry{sym, children}) + children foreach putSymbol + } + private def putAttribute(sym: Symbol, attr: AttrInfo): unit = { - assert(putEntry({sym, attr})) + assert(putEntry{sym, attr}) putType(attr.atp) for (val c <- attr.args) putConstant(c) for (val {name, c} <- attr.assocs) { putEntry(name); putConstant(c) } @@ -270,14 +277,18 @@ abstract class Pickler extends SubComponent { else if (c.tag == StringTag) writeRef(newTermName(c.stringValue)) else if (c.tag == ClassTag) writeRef(c.typeValue) LITERAL + c.tag + case AttributedType(attribs, tp) => + writeBody(tp) // obviously, this should be improved case {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) } ATTRIBUTE - case AttributedType(attribs, tp) => - writeBody(tp) // obviously, this should be improved + case {target: Symbol, children: Set[_]} => + writeRef(target) + for (val c <- children) writeRef(c.asInstanceOf[Symbol]) + CHILDREN case _ => throw new FatalError("bad entry: " + entry + " " + entry.getClass())//debug } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 951b96c84f..e28ed90b69 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -48,7 +48,7 @@ abstract class UnPickler { for (val i <- 0 until index.length) { if (isSymbolEntry(i)) { at(i, readSymbol); {} } - else if (isAttributeEntry(i)) { at(i, readAttribute); {} } + else if (isAnnotationEntry(i)) { at(i, readAnnotation); {} } } if (settings.debug.value) global.log("unpickled " + classRoot + ":" + classRoot.rawInfo + ", " + moduleRoot + ":" + moduleRoot.rawInfo);//debug @@ -89,8 +89,10 @@ abstract class UnPickler { } /** Does entry represent a symbol attribute? */ - private def isAttributeEntry(i: int): boolean = - bytes(index(i)) == ATTRIBUTE + private def isAnnotationEntry(i: int): boolean = { + val tag = bytes(index(i)) + tag == ATTRIBUTE || tag == CHILDREN + } /** Does entry represent a refinement symbol? * pre: Entry is a class symbol @@ -279,21 +281,25 @@ abstract class UnPickler { } /** Read an attribute and store in referenced symbol */ - private def readAttribute(): AttrInfo = { + private def readAnnotation(): AnyRef = { val tag = readByte() val end = readNat() + readIndex val target = readSymbolRef() - val attrType = readTypeRef() - val args = new ListBuffer[Constant] - val assocs = new ListBuffer[{Name, Constant}] - while (readIndex != end) { - val argref = readNat() - if (isNameEntry(argref)) assocs += {at(argref, readName), readConstantRef()} - else args += at(argref, readConstant) + if (tag == ATTRIBUTE) { + val attrType = readTypeRef() + val args = new ListBuffer[Constant] + val assocs = new ListBuffer[{Name, Constant}] + while (readIndex != end) { + val argref = readNat() + if (isNameEntry(argref)) assocs += {at(argref, readName), readConstantRef()} + else args += at(argref, readConstant) + } + val attr = AttrInfo(attrType, args.toList, assocs.toList) + target.attributes = attr :: target.attributes + } else if (tag == CHILDREN) { + while (readIndex != end) target addChild readSymbolRef() } - val attr = AttrInfo(attrType, args.toList, assocs.toList) - target.attributes = attr :: target.attributes - attr + null } /** Read a reference to a name, symbol, type or constant */ diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 7615e04cf8..c0dcd5b896 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -486,8 +486,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { tree1 match { case If(cond, thenp, elsep) => copy.If(tree1, cond, adaptBranch(thenp), adaptBranch(elsep)) - case Match(selector, cases) => - copy.Match(tree1, selector, cases map adaptCase) + case Match(selector, cases, check) => + copy.Match(tree1, selector, cases map adaptCase, check) case Try(block, catches, finalizer) => copy.Try(tree1, adaptBranch(block), catches map adaptCase, finalizer) case _ => diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 6be8b472d4..9aa1d7ff23 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -468,7 +468,7 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter } super.transform(copy.Apply(tree, sel, outerVal :: args)) - case Match(selector, cases) => // <----- transmatch hook + case Match(selector, cases, checkExhaustive) => // <----- transmatch hook val tid = if (settings.debug.value) { val q = unit.fresh.newName("tidmark") Console.println("transforming patmat with tidmark "+q+" ncases = "+cases.length) diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index c83430f265..6628751d30 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -213,8 +213,8 @@ abstract class TailCalls extends Transform case If(cond, thenp, elsep) => copy.If(tree, cond, transform(thenp), transform(elsep)); - case Match(selector, cases) => //super.transform(tree); - copy.Match(tree, transform(selector, mkContext(ctx, false)), transformTrees(cases).asInstanceOf[List[CaseDef]]); + case Match(selector, cases, check) => //super.transform(tree); + copy.Match(tree, transform(selector, mkContext(ctx, false)), transformTrees(cases).asInstanceOf[List[CaseDef]], check); case Return(expr) => super.transform(tree) case Try(block, catches, finalizer) => diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 3fb78e63b2..02d2d69c85 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -244,7 +244,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { .setFlag(FINAL).setInfo(MethodType(formals, BooleanClass.tpe)) anonClass.info.decls enter isDefinedAtMethod def idbody(idparam: Symbol) = fun.body match { - case Match(_, cases) => + case Match(_, cases, check) => val substParam = new TreeSymSubstituter(List(fun.vparams.head.symbol), List(idparam)); def transformCase(cdef: CaseDef): CaseDef = substParam( @@ -255,7 +255,8 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { Match( Ident(idparam), (cases map transformCase) ::: - List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false)))) + List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))), + check) } members = DefDef(isDefinedAtMethod, vparamss => idbody(vparamss.head.head)) :: members; } @@ -470,7 +471,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers { CaseDef( Bind(exname, Ident(nme.WILDCARD)), EmptyTree, - Match(Ident(exname), cases)) + Match(Ident(exname), cases, false)) } if (settings.debug.value) log("rewrote try: " + catches + " ==> " + catchall); val catches1 = localTyper.typedCases( diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 706f16a5ad..43a2946c98 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -616,7 +616,7 @@ abstract class RefChecks extends InfoTransform { Select(qual, nme.filter), List(Function( List(ValDef(_, pname, tpt, _)), - Match(_, CaseDef(pat1, _, _) :: _)))) + Match(_, CaseDef(pat1, _, _) :: _, _)))) if ((pname startsWith nme.CHECK_IF_REFUTABLE_STRING) && isIrrefutable(pat1, tpt.tpe)) => result = qual diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index bb410170bd..9c911f81fc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -87,7 +87,7 @@ trait SyntheticMethods requires Analyzer { Throw(New(TypeTree(IndexOutOfBoundsExceptionClass.tpe), List(List( Select(Ident(vparamss.head.head), nme.toString_) )))))) - }))) + }, false))) } def moduleToStringMethod: Tree = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 3d6bc33c02..15ad5db003 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1949,10 +1949,10 @@ trait Typers requires Analyzer { copy.If(tree, cond1, thenp1, elsep1) setType ptOrLub(List(thenp1.tpe, elsep1.tpe)) } - case Match(selector, cases) => + case Match(selector, cases, check) => val selector1 = typed(selector) val cases1 = typedCases(tree, cases, selector1.tpe.widen, pt) - copy.Match(tree, selector1, cases1) setType ptOrLub(cases1 map (.tpe)) + copy.Match(tree, selector1, cases1, check) setType ptOrLub(cases1 map (.tpe)) case Return(expr) => val enclMethod = context.enclMethod diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala index 1114b4785e..37bbb9dce4 100644 --- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala +++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala @@ -57,18 +57,6 @@ extends Map[A, B] override def transform(f: (A, B) => B): Unit = { imap = imap.transform(f) } - [deprecated] override def map[C](f: Pair[A, B] => C): Iterable[C] = { - val f1 = f.asInstanceOf[Pair[A, B] => B] - imap = imap transform { (x, y) => f1(Pair(x, y)) } - null - } - - /** @deprecated use retain instead */ - [deprecated] override def filter(p: Pair[A, B] => Boolean): Iterable[Pair[A, B]] = { - imap = imap.filter(p) - this - } - override def retain(p: (A, B) => Boolean): Unit = { imap = imap.filter(xy => p(xy._1, xy._2)) } diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala index 3ce815403d..431a9d5273 100644 --- a/src/library/scala/collection/mutable/MapProxy.scala +++ b/src/library/scala/collection/mutable/MapProxy.scala @@ -53,6 +53,4 @@ trait MapProxy[A, B] extends Map[A, B] with collection.MapProxy[A, B] { override def clone(): Map[A, B] = self.clone() [deprecated] override def incl(mappings: Pair[A, B]*): Unit = self.incl(mappings: _*) [deprecated] override def excl(keys: A*): Unit = self.excl(keys: _*) - [deprecated] override def map[C](f: Pair[A, B] => C): Iterable[C] = self map f - [deprecated] override def filter(p: Pair[A, B] => Boolean): Iterable[Pair[A, B]] = self filter p } diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 0ba86c668d..e0053f37e2 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -18,8 +18,8 @@ x = List({buffers,20},{layers,2},{title,3}) y = List({buffers,20},{layers,2},{title,3}) x equals y: true - y equals x: true -x = Map(title -> 3, layers -> 2, buffers -> 20) -y = Map(title -> 3, layers -> 2, buffers -> 20) +x = Map(buffers -> 20, layers -> 2, title -> 3) +y = Map(buffers -> 20, layers -> 2, title -> 3) x equals y: true - y equals x: true x = Set(2, 3) diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index d1a9e7ff37..888f5d6545 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -205,7 +205,7 @@ object Test { val a4: String = "a-z"; val a5: Symbol = 'token; val a6: HashMap = new HashMap(); - val a7: TreeMap = scala.collection.immutable.TreeMap.Empty[Int, Any]; + val a7: TreeMap = scala.collection.immutable.TreeMap.empty[Int, Any]; val a8: Strings = List("a", "z"); val v0: Unit = (); -- cgit v1.2.3