diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/CodeFactory.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternNodes.scala | 4 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala index 24b4a908c8..13fc7f830c 100644 --- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala +++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala @@ -97,17 +97,11 @@ trait CodeFactory { final def Eq (left: Tree, right: Tree): Tree = fn(left, nme.eq, right) final def GTE (left: Tree, right: Tree): Tree = fn(left, nme.GE, right) // >= - final def Not(arg: Tree) = arg match { - case TRUE => FALSE - case FALSE => TRUE - case t => Select(arg, NOT) - } + final def Not(arg: Tree) = + Select(arg, NOT) - final def And(left: Tree, right: Tree): Tree = (left, right) match { - case (Const(value: Boolean), _) => if (value) right else left - case (_, TRUE) => left - case _ => fn(left, AND, right) - } + final def And(left: Tree, right: Tree): Tree = + fn(left, AND, right) final def ThrowMatchError(pos: Position, obj: Tree) = atPos(pos) { Throw( New(TypeTree(MatchErrorClass.tpe), List(List(obj))) ) diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala index 57ff8faeaf..43b8af7da8 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala @@ -133,7 +133,9 @@ trait PatternNodes { self: transform.ExplicitOuter => * The corresponding list of value definitions. */ final def targetParams(implicit typer: Typer): List[ValDef] = - bindings.toList.map{ case Binding(v, t) => ValDef(v, typer.typed(mkIdent(t))) } + bindings.toList.map{ case Binding(v, t) => ValDef(v, + typer.typed{if(t.tpe <:< v.tpe) mkIdent(t) + else gen.mkAsInstanceOf(mkIdent(t), v.tpe)})} } val NoBinding: Bindings = Bindings() |