aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala3
-rw-r--r--test/dotc/scala-collections.whitelist8
-rw-r--r--tests/pos/i939.scala8
3 files changed, 13 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala
index 5b4d42683..7c8d0a10f 100644
--- a/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -787,7 +787,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
// - Scala's arrays are invariant (so we don't drop type tests unsoundly)
if (extractorArgTypeTest) mkDefault
else expectedTp match {
- case ThisType(tref) if tref.symbol.flags is Flags.Module => and(mkEqualsTest(ref(tref.symbol)), mkTypeTest) // must use == to support e.g. List() == Nil
+ case ThisType(tref) if tref.symbol.flags is Flags.Module =>
+ and(mkEqualsTest(ref(tref.symbol.companionModule)), mkTypeTest) // must use == to support e.g. List() == Nil
case ConstantType(Constant(null)) if isAnyRef => mkEqTest(expTp(Literal(Constant(null))))
case ConstantType(const) => mkEqualsTest(expTp(Literal(const)))
case t:SingletonType => mkEqTest(singleton(expectedTp)) // SI-4577, SI-4897
diff --git a/test/dotc/scala-collections.whitelist b/test/dotc/scala-collections.whitelist
index f6a13cc72..4c7be0768 100644
--- a/test/dotc/scala-collections.whitelist
+++ b/test/dotc/scala-collections.whitelist
@@ -189,13 +189,11 @@
./scala-scala/src/library/scala/collection/immutable/HashMap.scala
./scala-scala/src/library/scala/collection/immutable/HashSet.scala
-# https://github.com/lampepfl/dotty/issues/939 -> @darkdimius
-#./scala-scala/src/library/scala/collection/immutable/IntMap.scala
+
+./scala-scala/src/library/scala/collection/immutable/IntMap.scala
./scala-scala/src/library/scala/collection/immutable/ListMap.scala
./scala-scala/src/library/scala/collection/immutable/ListSet.scala
-
-# https://github.com/lampepfl/dotty/issues/939 -> @darkdimius
-#./scala-scala/src/library/scala/collection/immutable/LongMap.scala
+./scala-scala/src/library/scala/collection/immutable/LongMap.scala
./scala-scala/src/library/scala/collection/immutable/Map.scala
./scala-scala/src/library/scala/collection/immutable/MapLike.scala
diff --git a/tests/pos/i939.scala b/tests/pos/i939.scala
new file mode 100644
index 000000000..720bf764c
--- /dev/null
+++ b/tests/pos/i939.scala
@@ -0,0 +1,8 @@
+object IntMap {
+ private case object Nil {
+ override def equals(that : Any) = that match {
+ case _: this.type => true
+ case _ => super.equals(that)
+ }
+ }
+}