@@ -766,23 +766,33 @@ class Namer { typer: Typer =>
766
766
* `denot` is a compiler generated case class method that clashes
767
767
* with a user-defined method in the same scope with a matching type.
768
768
*/
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 ) =
771
772
owner.isClass && {
772
773
if (owner.is(Module )) owner.linkedClass.is(CaseClass )
773
774
else owner.is(CaseClass )
774
775
}
775
- val isClashingSynthetic =
776
- denot.is(Synthetic ) &&
777
- desugar.isRetractableCaseClassMethodName(denot.name) &&
778
- isCaseClass(denot.owner) &&
776
+
777
+ def definesMember =
779
778
denot.owner.info.decls.lookupAll(denot.name).exists(alt =>
780
779
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 , butNot = ConstructorProxy )
788
+ && desugar.isRetractableCaseClassMethodName(denot.name)
789
+ && isCaseClassOrCompanion(denot.owner)
790
+ && (definesMember || inheritsConcreteMember)
791
+
792
+ if isClashingSynthetic then
782
793
typr.println(i " invalidating clashing $denot in ${denot.owner}" )
783
794
denot.markAbsent()
784
- }
785
- }
795
+ end invalidateIfClashingSynthetic
786
796
787
797
/** If completed symbol is an enum value or a named class, register it as a child
788
798
* in all direct parent classes which are sealed.
0 commit comments