summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-01-06 14:08:48 -0800
committerPaul Phillips <paulp@improving.org>2013-01-06 14:08:48 -0800
commit8685257f389ae5e8301bdbd590e5b0b218b6d8a8 (patch)
tree2ea9c7cd981bdfa6509665414056cff1eb4df028 /src
parent0d3de0c25212febfed646ed505837aa0a17d2b3e (diff)
parenteeb6ee6eb21e7bd473ab5775474444b5d1b72856 (diff)
downloadscala-8685257f389ae5e8301bdbd590e5b0b218b6d8a8.tar.gz
scala-8685257f389ae5e8301bdbd590e5b0b218b6d8a8.tar.bz2
scala-8685257f389ae5e8301bdbd590e5b0b218b6d8a8.zip
Merge pull request #1840 from paulp/issue/6911
SI-6911, regression in generated case class equality.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 17e67e6429..a907ab6c66 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -157,11 +157,23 @@ trait SyntheticMethods extends ast.TreeDSL {
Ident(m.firstParam) IS_OBJ classExistentialType(clazz))
}
- /** (that.isInstanceOf[this.C])
- * where that is the given methods first parameter.
+ /** that match { case _: this.C => true ; case _ => false }
+ * where `that` is the given method's first parameter.
+ *
+ * An isInstanceOf test is insufficient because it has weaker
+ * requirements than a pattern match. Given an inner class Foo and
+ * two different instantiations of the container, an x.Foo and and a y.Foo
+ * are both .isInstanceOf[Foo], but the one does not match as the other.
*/
- def thatTest(eqmeth: Symbol): Tree =
- gen.mkIsInstanceOf(Ident(eqmeth.firstParam), classExistentialType(clazz), true, false)
+ def thatTest(eqmeth: Symbol): Tree = {
+ Match(
+ Ident(eqmeth.firstParam),
+ List(
+ CaseDef(Typed(Ident(nme.WILDCARD), TypeTree(clazz.tpe)), EmptyTree, TRUE),
+ CaseDef(WILD.empty, EmptyTree, FALSE)
+ )
+ )
+ }
/** (that.asInstanceOf[this.C])
* where that is the given methods first parameter.