summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-12-11 15:15:15 +0000
committermichelou <michelou@epfl.ch>2007-12-11 15:15:15 +0000
commit8586583b98b94a33ed426b33341fa489682795bf (patch)
treed19c141506a26d899881d2ab3678e4e28685eeda
parent0e3c21fae806c55626b8972b00da9e413b3e99bf (diff)
downloadscala-8586583b98b94a33ed426b33341fa489682795bf.tar.gz
scala-8586583b98b94a33ed426b33341fa489682795bf.tar.bz2
scala-8586583b98b94a33ed426b33341fa489682795bf.zip
propagated r13490 change
-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 _ =>