diff options
author | Burak Emir <emir@epfl.ch> | 2006-12-11 16:16:50 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-12-11 16:16:50 +0000 |
commit | a64a94ca5292c93a31040442e99d6f68fea24c40 (patch) | |
tree | 047b2e124b6bc2bb312253050b092648b73cc517 | |
parent | 0c657593da8bb0835d3c24e93b14daf9361521ba (diff) | |
download | scala-a64a94ca5292c93a31040442e99d6f68fea24c40.tar.gz scala-a64a94ca5292c93a31040442e99d6f68fea24c40.tar.bz2 scala-a64a94ca5292c93a31040442e99d6f68fea24c40.zip |
fixed #855
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 32 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala | 2 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 45ff87c4de..7337d01155 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -967,11 +967,13 @@ print() def generalSwitchToTree(): Tree = { this.exit = owner.newLabel(root.pos, "exit").setInfo(new MethodType(List(resultType), resultType)); val result = exit.newValueParameter(root.pos, "result").setInfo( resultType ); - return squeezedBlock( + + + squeezedBlock( List( ValDef(root.symbol, selector), - toTree(root.and), - ThrowMatchError(selector.pos, Ident(root.symbol))), + typed { toTree(root.and) }, + ThrowMatchError(selector.pos, Ident(root.symbol))) , LabelDef(exit, List(result), Ident(result))) } @@ -1001,7 +1003,7 @@ print() var node = node1; - var res: Tree = typed(Literal(Constant(false))); //.setInfo(defs.BooleanClass); + var res: Tree = Literal(Constant(false)); //.setInfo(defs.BooleanClass); while (node ne null) node match { @@ -1025,32 +1027,32 @@ print() return Literal(Constant(true)); } var i = guard.length - 1; while(i >= 0) { - val ts:Seq[Tree] = bound(i).asInstanceOf[Array[Tree]]; - val temp = owner.newValue(body(i).pos, cunit.fresh.newName("r$")) - .setFlag(Flags.SYNTHETIC).setInfo(resultType); + val ts:Seq[Tree] = bound(i).asInstanceOf[Array[Tree]]; + val temp = owner.newValue(body(i).pos, cunit.fresh.newName("r$")) + .setFlag(Flags.SYNTHETIC) .setInfo(body(i).tpe); // used to be resultType + var res0: Tree = - //Block( - // List(Assign(Ident(resultVar), body(i))), - // Literal(Constant(true))); squeezedBlock( List( ValDef(temp, body(i)), - Apply(Ident(exit), List(Ident(temp)))), + Apply(Ident(exit), List(Ident(temp)) ) + ), Literal(Constant(true)) ); // forward jump + if (guard(i) != EmptyTree) res0 = And(guard(i), res0); - res = Or(squeezedBlock(ts.toList, res0), res); + res = Or(squeezedBlock(ts.toList, res0), res) i = i - 1 } if (_b.or ne null) res = Or(res, toTree(_b.or)) - return res; + return res case _ => scala.Predef.error("error in toTree"); - } - return res; } + return res + } class TagNodePair(tag1: int, node1: PatternNode, next1: TagNodePair) { var tag: int = tag1 diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index f8b11f164f..1a714600c0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -210,7 +210,7 @@ trait SyntheticMethods requires Analyzer { } if (!hasDirectImplementation(nme.productPrefix)) ts += productPrefixMethod - val accessors = if(clazz hasFlag CASE) clazz.caseFieldAccessors else clazz.constrParamAccessors + val accessors = clazz.caseFieldAccessors for (val i <- 0 until accessors.length) { val acc = accessors(i) if (acc.name.toString != "_"+(i+1)) ts += productSelectorMethod(i+1, acc) |