summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2007-12-10 23:47:50 +0000
committerBurak Emir <emir@epfl.ch>2007-12-10 23:47:50 +0000
commitda79f1b5fb171972704df6738ee2d9a17da4c8dc (patch)
tree39fa1a1dec756b3e47f11cfcd9ac135db33e88ee /src/compiler
parentb097e75380d268d9811c811b0ab3f6e3ffb9667c (diff)
downloadscala-da79f1b5fb171972704df6738ee2d9a17da4c8dc.tar.gz
scala-da79f1b5fb171972704df6738ee2d9a17da4c8dc.tar.bz2
scala-da79f1b5fb171972704df6738ee2d9a17da4c8dc.zip
better approximation of <:<_erased, fixes bug i...
better approximation of <:<_erased, fixes bug in PrettyPrinter (oddly)
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/matching/ParallelMatching.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
index 32b95944e4..dffd1f3db9 100644
--- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
+++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
@@ -682,10 +682,17 @@ trait ParallelMatching {
}
}
+ /** an approximation of _tp1 <:< tp2 that ignores _ types. this code is wrong,
+ * ideally there is a better way to do it, and ideally defined in Types.scala
+ */
def subsumes_erased(_tp1:Type, tp2:Type) = {
val tp1 = patternType_wrtEquals(_tp1)
tp1.isInstanceOf[TypeRef] && tp2.isInstanceOf[TypeRef] &&
- ((tp1.prefix =:= tp2.prefix) && (tp1.typeSymbol eq tp2.typeSymbol) && (tp1.typeSymbol ne definitions.ArrayClass))
+ ((tp1.prefix =:= tp2.prefix) &&
+ ((tp1.typeSymbol eq tp2.typeSymbol) &&
+ (tp1.typeSymbol ne definitions.ArrayClass)) ||
+ tp1.parents.exists(_.typeSymbol eq tp2.typeSymbol))
+ // rather: tp1.baseTypes.exists...?
}
/** returns true if pattern tests an object */
@@ -706,7 +713,6 @@ trait ParallelMatching {
val pat = pats.head
val strippedPattern = strip2(pat)
val patternType = strippedPattern.tpe
-
sr = strippedPattern match {
case Literal(Constant(null)) if !(headPatternType =:= patternType) => //special case for constant null pattern
(ms,ss,(j,pat)::rs);
@@ -725,7 +731,7 @@ trait ParallelMatching {
case qq if subsumes_erased(patternType, headPatternType) || (patternType_wrtEquals(patternType) <:< headPatternType) && !isDefaultPattern(pat) =>
({if (pat.tpe =:= headPatternType /*never true for <equals>*/) EmptyTree else pat}::ms, (j,subpatterns(pat))::ss, rs);
- case _ if (headPatternType <:< patternType /*never true for <equals>*/) || isDefaultPattern(pat) =>
+ case _ if subsumes_erased(headPatternType, patternType) || (headPatternType <:< patternType /*never true for <equals>*/) || isDefaultPattern(pat) =>
(EmptyTree::ms, (j, dummies)::ss, (j,pat)::rs) // subsuming (matched *and* remaining pattern)
case _ =>