diff options
author | Burak Emir <emir@epfl.ch> | 2007-09-01 06:51:58 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-09-01 06:51:58 +0000 |
commit | 8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea (patch) | |
tree | 3ec75d2046cb589b9c7d4d0ae4bffa27f1159b26 /src/compiler | |
parent | 77de72ce86f2fd83c646cfc1c5fd21de26318477 (diff) | |
download | scala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.tar.gz scala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.tar.bz2 scala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.zip |
fixed ticket #2 (patch from tags/R_2_6_0-RC2), ...
fixed ticket #2 (patch from tags/R_2_6_0-RC2), reorganized test cases
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 31 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 2 |
2 files changed, 7 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index e21ebc42c4..31ec804325 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -814,7 +814,7 @@ trait ParallelMatching { val (casted,srep,frep) = this.getTransition val condUntyped = condition(casted.tpe, this.scrutinee) var cond = rep.handleOuter(typed { condUntyped }) // <- throws exceptions in some situations? - if(needsOuterTest(casted.tpe, this.scrutinee.tpe)) // @todo merge into def condition + if(needsOuterTest(casted.tpe, this.scrutinee.tpe, theOwner)) // @todo merge into def condition cond = addOuterCondition(cond, casted.tpe, mkIdent(this.scrutinee), rep.handleOuter) val succ = repToTree(srep) @@ -1484,35 +1484,16 @@ trait ParallelMatching { gen.mkIsInstanceOf(scrutineeTree, tpe) } - final def needsOuterTest(tpe2test: Type, scrutinee: Type) = tpe2test.normalize match { - case TypeRef(prefix,_,_) => - prefix.termSymbol.isTerm && - !prefix.termSymbol.isPackage && - outerAlwaysEqual(tpe2test, scrutinee) == Some(false) - case _ => - false - } - - /** returns a result if both are TypeRefs, returns Some(true) if left and right are statically known to have - * the same outer, i.e. if their prefixes are the same - */ - final def outerAlwaysEqual(left: Type, right: Type): Option[Boolean] = - (left.normalize, right.normalize) match { - case (TypeRef(lprefix, _, _), TypeRef(rprefix, _, _)) => - //if(!(lprefix =:= rprefix)) { - //DEBUG("DEBUG(outerAlwaysEqual) Some(f) for"+(left,right)) - //} - Some(lprefix =:= rprefix) - case _ => - None - } - /** adds a test comparing the dynamic outer to the static outer */ final def addOuterCondition(cond:Tree, tpe2test: Type, scrutinee: Tree, handleOuter: Tree=>Tree) = { val TypeRef(prefix,_,_) = tpe2test //Console.println("addOuterCondition: "+prefix) assert(prefix ne NoPrefix) - var theRef = gen.mkAttributedRef(prefix.prefix, prefix.termSymbol) + var theRef = prefix match { + case ThisType(clazz) => gen.mkAttributedThis(clazz) + case _ => gen.mkAttributedRef(prefix.prefix, prefix.termSymbol) + } + // needs explicitouter treatment theRef = handleOuter(theRef) diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 677c850a92..5d7fc44e9a 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -1204,7 +1204,7 @@ print() // compare outer instance for patterns like foo1.Bar foo2.Bar if not statically known to match casted.tpe match { - case TypeRef(prefix,_,_) if needsOuterTest(casted.tpe, selector.tpe) => + case TypeRef(prefix,_,_) if needsOuterTest(casted.tpe, selector.tpe, owner) => //@attention, deep typer bug: if we omit "typed" here, we crash when typing the tree that contains this fragment cond = typed{ addOuterCondition(cond, casted.tpe, selector.duplicate, handleOuter) } |