summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-04-14 15:43:33 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-04-14 22:49:03 +0200
commitc2cd6acf993d66eac6f6917ee3b7300eeaceb8a3 (patch)
treea1f27c15db5c898263b72a94d8d402e541f3a0cb /src
parent28483739c365b1a3b748ebab50b03bd66a4db61d (diff)
downloadscala-c2cd6acf993d66eac6f6917ee3b7300eeaceb8a3.tar.gz
scala-c2cd6acf993d66eac6f6917ee3b7300eeaceb8a3.tar.bz2
scala-c2cd6acf993d66eac6f6917ee3b7300eeaceb8a3.zip
don't emit tiny switches: optimizer chokes on them
workaround for inliner bug in run/t3835 see SI-5672 for the optimizer bug tiny switches (2 cases or less) don't make sense anyway, so this is not a big deal the annotDepMethType.flags contained -Xexperimental, which causes Any* to be considered as a valid return type, before we weren't exposed to this, because the product methods used (tiny) switches; with this change, they went back to pattern matches in any case, the -Xexperimental was intended to turn on dependent method types, not Any* as valid type (I can only assume), and they are now on by default the other tests were affected by our refusal to emit tiny switches
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
index 82e2442ba8..88cea2231f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
@@ -1570,7 +1570,7 @@ class Foo(x: Other) { x._1 } // no error in this order
// TODO: if patterns allow switch but the type of the scrutinee doesn't, cast (type-test) the scrutinee to the corresponding switchable type and switch on the result
if (regularSwitchMaker.switchableTpe(scrutSym.tpe)) {
val caseDefsWithDefault = regularSwitchMaker(cases map {c => (scrutSym, c)}, pt)
- if (caseDefsWithDefault isEmpty) None
+ if (caseDefsWithDefault.length <= 2) None // not worth emitting a switch... also, the optimizer has trouble digesting tiny switches, apparently, so let's be nice and not generate them
else {
// match on scrutSym -- converted to an int if necessary -- not on scrut directly (to avoid duplicating scrut)
val scrutToInt: Tree =