Skip to content

Commit 9ac88f6

Browse files
committed
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.
1 parent 66e73e0 commit 9ac88f6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
787787
// - Scala's arrays are invariant (so we don't drop type tests unsoundly)
788788
if (extractorArgTypeTest) mkDefault
789789
else expectedTp match {
790-
case ThisType(tref) if tref.symbol.flags is Flags.Module => and(mkEqualsTest(ref(tref.symbol)), mkTypeTest) // must use == to support e.g. List() == Nil
790+
case ThisType(tref) if tref.symbol.flags is Flags.Module =>
791+
and(mkEqualsTest(ref(tref.symbol.companionModule)), mkTypeTest) // must use == to support e.g. List() == Nil
791792
case ConstantType(Constant(null)) if isAnyRef => mkEqTest(expTp(Literal(Constant(null))))
792793
case ConstantType(const) => mkEqualsTest(expTp(Literal(const)))
793794
case t:SingletonType => mkEqTest(singleton(expectedTp)) // SI-4577, SI-4897

0 commit comments

Comments
 (0)