From 842e966a233084539fbc755320c83f8c6fed7ef0 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 13 Jan 2016 14:09:42 +0100 Subject: [PATCH 1/3] Fix i939: Patmat shouldn't compare selectors to module TypeTrees. It would be great to augment Ycheck to ensure that some trees are not permitted, e.g. TypeTree cannot be a stat in a block or a receiver of a call. Currently this is `ensured` by backend by failing. --- src/dotty/tools/dotc/transform/PatternMatcher.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala index 5b4d4268367b..7c8d0a10f41f 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 From b18c930965c0ca70e1fbd15674d042d83a38ef4e Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 13 Jan 2016 14:14:02 +0100 Subject: [PATCH 2/3] Test that #939 is fixed --- tests/pos/i939.scala | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/pos/i939.scala diff --git a/tests/pos/i939.scala b/tests/pos/i939.scala new file mode 100644 index 000000000000..720bf764c910 --- /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) + } + } +} From 150d62960d294b1076eafe774b610a022543e4d9 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 13 Jan 2016 14:14:21 +0100 Subject: [PATCH 3/3] Add IntMap and LongMap to collections whitelist. --- test/dotc/scala-collections.whitelist | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/dotc/scala-collections.whitelist b/test/dotc/scala-collections.whitelist index f6a13cc72926..4c7be07680ac 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