@@ -766,23 +766,33 @@ class Namer { typer: Typer =>
766766 * `denot` is a compiler generated case class method that clashes
767767 * with a user-defined method in the same scope with a matching type.
768768 */
769- private def invalidateIfClashingSynthetic (denot : SymDenotation ): Unit = {
770- def isCaseClass (owner : Symbol ) =
769+ private def invalidateIfClashingSynthetic (denot : SymDenotation ): Unit =
770+
771+ def isCaseClassOrCompanion (owner : Symbol ) =
771772 owner.isClass && {
772773 if (owner.is(Module )) owner.linkedClass.is(CaseClass )
773774 else owner.is(CaseClass )
774775 }
775- val isClashingSynthetic =
776- denot.is(Synthetic ) &&
777- desugar.isRetractableCaseClassMethodName(denot.name) &&
778- isCaseClass(denot.owner) &&
776+
777+ def definesMember =
779778 denot.owner.info.decls.lookupAll(denot.name).exists(alt =>
780779 alt != denot.symbol && alt.info.matchesLoosely(denot.info))
781- if (isClashingSynthetic) {
780+
781+ def inheritsConcreteMember =
782+ denot.owner.asClass.classParents.exists(parent =>
783+ parent.member(denot.name).hasAltWith(sd =>
784+ ! sd.symbol.is(Deferred ) && sd.matches(denot)))
785+
786+ val isClashingSynthetic =
787+ denot.is(Synthetic )
788+ && desugar.isRetractableCaseClassMethodName(denot.name)
789+ && isCaseClassOrCompanion(denot.owner)
790+ && (definesMember || inheritsConcreteMember)
791+
792+ if isClashingSynthetic then
782793 typr.println(i " invalidating clashing $denot in ${denot.owner}" )
783794 denot.markAbsent()
784- }
785- }
795+ end invalidateIfClashingSynthetic
786796
787797 /** If completed symbol is an enum value or a named class, register it as a child
788798 * in all direct parent classes which are sealed.
0 commit comments