diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2017-03-13 14:12:01 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-03-20 15:05:20 +0100 |
commit | 8716fac3e392e2968df4f681474b2ee2964c834f (patch) | |
tree | 59b72697ae31c0dd3a791c38dafc3cfdf7d730c5 /compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala | |
parent | aedd4e01f27ac694f8c0a484d7e0c775c64aaed9 (diff) | |
download | dotty-8716fac3e392e2968df4f681474b2ee2964c834f.tar.gz dotty-8716fac3e392e2968df4f681474b2ee2964c834f.tar.bz2 dotty-8716fac3e392e2968df4f681474b2ee2964c834f.zip |
Fix #2084.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala index 3774127fa..a2119bfe4 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala @@ -96,23 +96,30 @@ trait TypeTestsCasts { /** Transform isInstanceOf OrType * * expr.isInstanceOf[A | B] ~~> expr.isInstanceOf[A] | expr.isInstanceOf[B] + * expr.isInstanceOf[A & B] ~~> expr.isInstanceOf[A] & expr.isInstanceOf[B] * * The transform happens before erasure of `argType`, thus cannot be merged * with `transformIsInstanceOf`, which depends on erased type of `argType`. */ - def transformOrTypeTest(qual: Tree, argType: Type): Tree = argType.dealias match { + def transformTypeTest(qual: Tree, argType: Type): Tree = argType.dealias match { case OrType(tp1, tp2) => evalOnce(qual) { fun => - transformOrTypeTest(fun, tp1) - .select(nme.OR) - .appliedTo(transformOrTypeTest(fun, tp2)) + transformTypeTest(fun, tp1) + .select(defn.Boolean_||) + .appliedTo(transformTypeTest(fun, tp2)) + } + case AndType(tp1, tp2) => + evalOnce(qual) { fun => + transformTypeTest(fun, tp1) + .select(defn.Boolean_&&) + .appliedTo(transformTypeTest(fun, tp2)) } case _ => transformIsInstanceOf(qual, erasure(argType)) } if (sym eq defn.Any_isInstanceOf) - transformOrTypeTest(qual, tree.args.head.tpe) + transformTypeTest(qual, tree.args.head.tpe) else if (sym eq defn.Any_asInstanceOf) transformAsInstanceOf(erasure(tree.args.head.tpe)) else tree |