diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:02 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:02 +0000 |
commit | 7bee6a54009c4978c0e7511b88c59e68aa39683c (patch) | |
tree | e4359de8d8f0ae8315e82f7325e004c968eab947 /src | |
parent | 02f73a54eed0d5153a657728b0fa9f3db629d7f4 (diff) | |
download | scala-7bee6a54009c4978c0e7511b88c59e68aa39683c.tar.gz scala-7bee6a54009c4978c0e7511b88c59e68aa39683c.tar.bz2 scala-7bee6a54009c4978c0e7511b88c59e68aa39683c.zip |
A crasher in the pattern matcher revealed a fla...
A crasher in the pattern matcher revealed a flaw in how equality
comparisons were constructed. Closes #3570, no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 22 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 1 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 34d3423401..a24c8c01d3 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -76,20 +76,24 @@ trait TreeDSL { else gen.mkAnd(target, other) /** Note - calling ANY_== in the matcher caused primitives to get boxed - * for the comparison, whereas looking up nme.EQ does not. + * for the comparison, whereas looking up nme.EQ does not. See #3570 for + * an example of how target.tpe can be non-null, yet it claims not to have + * a mmeber called nme.EQ. Not sure if that should happen, but we can be + * robust by dragging in Any regardless. */ def MEMBER_== (other: Tree) = { - if (target.tpe == null) ANY_==(other) - else fn(target, target.tpe member nme.EQ, other) + val opSym = if (target.tpe == null) NoSymbol else target.tpe member nme.EQ + if (opSym == NoSymbol) ANY_==(other) + else fn(target, opSym, other) } - def ANY_NE (other: Tree) = fn(target, nme.ne, toAnyRef(other)) def ANY_EQ (other: Tree) = fn(target, nme.eq, toAnyRef(other)) + def ANY_NE (other: Tree) = fn(target, nme.ne, toAnyRef(other)) def ANY_== (other: Tree) = fn(target, Any_==, other) - def ANY_>= (other: Tree) = fn(target, nme.GE, other) - def ANY_<= (other: Tree) = fn(target, nme.LE, other) - def OBJ_!= (other: Tree) = fn(target, Object_ne, other) - def OBJ_EQ (other: Tree) = fn(target, nme.eq, other) - def OBJ_NE (other: Tree) = fn(target, nme.ne, other) + def ANY_!= (other: Tree) = fn(target, Any_!=, other) + def OBJ_== (other: Tree) = fn(target, Object_==, other) + def OBJ_!= (other: Tree) = fn(target, Object_!=, other) + def OBJ_EQ (other: Tree) = fn(target, Object_eq, other) + def OBJ_NE (other: Tree) = fn(target, Object_ne, other) def INT_| (other: Tree) = fn(target, getMember(IntClass, nme.OR), other) def INT_& (other: Tree) = fn(target, getMember(IntClass, nme.AND), other) diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 77997c4565..f9e7a1bdcf 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -886,6 +886,7 @@ trait ParallelMatching extends ast.TreeDSL } case _: SingletonType if useEqTest => val eqTest = REF(tpe.termSymbol) MEMBER_== scrutTree + // See ticket #1503 for the motivation behind checking for a binding. // The upshot is that it is unsound to assume equality means the right // type, but if the value doesn't appear on the right hand side of the |