summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-05-26 04:43:01 +0000
committerPaul Phillips <paulp@improving.org>2011-05-26 04:43:01 +0000
commit3f192157811eb268d46f3a71011a5b2b966faa14 (patch)
tree58259d2ca3e449288368fe24a8ebc5305cb345b2 /src
parentd3ff7ee9fcac1d10c145bbd1f37a69b989a73cdf (diff)
downloadscala-3f192157811eb268d46f3a71011a5b2b966faa14.tar.gz
scala-3f192157811eb268d46f3a71011a5b2b966faa14.tar.bz2
scala-3f192157811eb268d46f3a71011a5b2b966faa14.zip
Finished reverting the misbegotten r23262, no r...
Finished reverting the misbegotten r23262, no review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index bc6a468538..c5f32a344f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -614,7 +614,6 @@ trait Namers { self: Analyzer =>
* modifier is the present means of signaling that a constant
* value should not be widened, so it has a use even in situations
* whether it is otherwise redundant (such as in a singleton.)
- * Method-defined locals are also excluded from widening.
*/
private def widenIfNecessary(sym: Symbol, tpe: Type, pt: Type): Type = {
val getter =
@@ -633,11 +632,16 @@ trait Namers { self: Analyzer =>
}
val tpe1 = tpe.deconst
val tpe2 = tpe1.widen
- if ((sym.isVariable || sym.isMethod && !sym.hasAccessorFlag))
+ if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag)
if (tpe2 <:< pt) tpe2 else tpe1
else if (isHidden(tpe)) tpe2
- else if (sym.isFinal || sym.owner.isMethod) tpe
- else tpe1
+ // In an attempt to make pattern matches involving method local vals
+ // compilable into switches, for a time I had a more generous condition:
+ // `if (sym.isFinal || sym.isLocal) tpe else tpe1`
+ // This led to issues with expressions like classOf[List[_]] which apparently
+ // depend on being deconst-ed here, so this is again the original:
+ else if (!sym.isFinal) tpe1
+ else tpe
}
// sets each ValDef's symbol