diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-01-23 00:28:21 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-01-23 00:28:43 +0100 |
commit | 4dceb2268780462823a98168d7350687d5cf27a8 (patch) | |
tree | 7b606d90b5769e951e1a8de1f12cdc3b0e843fb1 /src | |
parent | 884737c75dc7f2765a3d769342ecc832deeddb81 (diff) | |
download | scala-4dceb2268780462823a98168d7350687d5cf27a8.tar.gz scala-4dceb2268780462823a98168d7350687d5cf27a8.tar.bz2 scala-4dceb2268780462823a98168d7350687d5cf27a8.zip |
[backport] Fix SI-6637 (misoptimization in erasure)
commit f9ef5300ab561628e53c654df9000c75f488d74a
Author: Jan Niehusmann <jan@gondor.com>
Date: Fri Nov 9 15:05:58 2012 +0100
Fix SI-6637 (misoptimization in erasure)
Move the optimization one level deeper so the expression
being tested with isInstanceOf is always evaluated.
(cherry picked from commit b540aaee4ba30e2dd980456a44e8c6d732222df1)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 41aada473a..889d309ba9 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -1057,17 +1057,17 @@ abstract class Erasure extends AddInterfaces Apply(Select(qual, cmpOp), List(gen.mkAttributedQualifier(targ.tpe))) } case RefinedType(parents, decls) if (parents.length >= 2) => - // Optimization: don't generate isInstanceOf tests if the static type - // conforms, because it always succeeds. (Or at least it had better.) - // At this writing the pattern matcher generates some instance tests - // involving intersections where at least one parent is statically known true. - // That needs fixing, but filtering the parents here adds an additional - // level of robustness (in addition to the short term fix.) - val parentTests = parents filterNot (qual.tpe <:< _) - - if (parentTests.isEmpty) Literal(Constant(true)) - else gen.evalOnce(qual, currentOwner, unit) { q => - atPos(tree.pos) { + gen.evalOnce(qual, currentOwner, unit) { q => + // Optimization: don't generate isInstanceOf tests if the static type + // conforms, because it always succeeds. (Or at least it had better.) + // At this writing the pattern matcher generates some instance tests + // involving intersections where at least one parent is statically known true. + // That needs fixing, but filtering the parents here adds an additional + // level of robustness (in addition to the short term fix.) + val parentTests = parents filterNot (qual.tpe <:< _) + + if (parentTests.isEmpty) Literal(Constant(true)) + else atPos(tree.pos) { parentTests map mkIsInstanceOf(q) reduceRight gen.mkAnd } } |