diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-05-23 12:41:14 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-06-01 16:04:56 +0200 |
commit | bc991663fd9ac34ebc3d3ebb5a7825d478a7b2e7 (patch) | |
tree | 11b81a2a519db73c73e97bfc709ffd1a839713de | |
parent | 66220c91094e9d5a97d0f92780f6e934155aaa6c (diff) | |
download | scala-bc991663fd9ac34ebc3d3ebb5a7825d478a7b2e7.tar.gz scala-bc991663fd9ac34ebc3d3ebb5a7825d478a7b2e7.tar.bz2 scala-bc991663fd9ac34ebc3d3ebb5a7825d478a7b2e7.zip |
construct typed trees in TypeTestTM
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 63547a84eb..08621fabae 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -991,6 +991,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL if (outerTestNeeded) and(typeTest(testedBinder, expectedTp), outerTest(testedBinder, expectedTp)) else typeTest(testedBinder, expectedTp) + // propagate expected type + @inline def expTp(t: Tree): t.type = t setType expectedTp + // true when called to type-test the argument to an extractor // don't do any fancy equality checking, just test the type if (extractorArgTypeTest) default @@ -1000,11 +1003,11 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL case SingleType(_, sym) => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen)) // must use == to support e.g. List() == Nil case ThisType(sym) if sym.isModule => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen)) - case ConstantType(const) => equalsTest(Literal(const), testedBinder) + case ConstantType(const) => equalsTest(expTp(Literal(const)), testedBinder) - case ThisType(sym) => eqTest(This(sym), testedBinder) + case ThisType(sym) => eqTest(expTp(This(sym)), testedBinder) case ConstantType(Constant(null)) if testedBinder.info.widen <:< AnyRefClass.tpe - => eqTest(CODE.NULL, testedBinder) + => eqTest(expTp(CODE.NULL), testedBinder) // TODO: verify that we don't need to special-case Array // I think it's okay: |