@@ -666,14 +666,16 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
666666 val expectedOuter = expectedTp.normalizedPrefix match {
667667 // case ThisType(clazz) => This(clazz)
668668 // case NoType => Literal(Constant(true)) // fallback for SI-6183 todo?
669- case pre => ref(pre.typeSymbol )
669+ case pre => ref(pre.termSymbol )
670670 }
671671
672672 // ExplicitOuter replaces `Select(q, outerSym) OBJ_EQ expectedPrefix` by `Select(q, outerAccessor(outerSym.owner)) OBJ_EQ expectedPrefix`
673673 // if there's an outer accessor, otherwise the condition becomes `true` -- TODO: can we improve needsOuterTest so there's always an outerAccessor?
674674 // val outer = expectedTp.typeSymbol.newMethod(vpmName.outer, newFlags = SYNTHETIC | ARTIFACT) setInfo expectedTp.prefix
675675
676- codegen._asInstanceOf(testedBinder, expectedTp).select(" <outer>" .toTermName).select(ctx.definitions.Object_eq ).appliedTo(expectedOuter)
676+ val expectedClass = expectedTp.dealias.classSymbol.asClass
677+ ExplicitOuter .ensureOuterAccessors(expectedClass)
678+ codegen._asInstanceOf(testedBinder, expectedTp).select(ExplicitOuter .outerAccessor(expectedClass)).select(ctx.definitions.Object_eq ).appliedTo(expectedOuter)
677679 }
678680 }
679681
@@ -750,11 +752,12 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
750752
751753 override lazy val localSubstitution : Substitution = EmptySubstitution
752754
753- lazy val outerTestNeeded = (
754- (expectedTp.normalizedPrefix.typeSymbol ne NoSymbol )
755- && ! expectedTp.normalizedPrefix.typeSymbol.isPackageObject
756- && false && needsOuterTest(expectedTp, testedBinder.info, matchOwner)
757- )
755+ def outerTestNeeded = {
756+ val np = expectedTp.normalizedPrefix
757+ val ts = np.termSymbol
758+ (ts ne NoSymbol ) && needsOuterTest(expectedTp, testedBinder.info, matchOwner)
759+
760+ }
758761
759762 // the logic to generate the run-time test that follows from the fact that
760763 // a `prevBinder` is expected to have type `expectedTp`
0 commit comments