Skip to content

Commit 956794e

Browse files
committed
Clarify conflict logic bypass for PolyFunctions.
1 parent bb8e5b5 commit 956794e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,19 @@ class ElimErasedValueType extends MiniPhase with InfoTransformer { thisPhase =>
8383
override def matches(sym1: Symbol, sym2: Symbol) =
8484
sym1.signature == sym2.signature
8585
}
86+
8687
def checkNoConflict(sym1: Symbol, sym2: Symbol, info: Type)(implicit ctx: Context): Unit = {
8788
val site = root.thisType
8889
val info1 = site.memberInfo(sym1)
8990
val info2 = site.memberInfo(sym2)
90-
if (!info1.matchesLoosely(info2) &&
91-
!(sym1.name == nme.apply &&
92-
(sym1.owner.derivesFrom(defn.PolyFunctionClass) ||
93-
sym2.owner.derivesFrom(defn.PolyFunctionClass))))
91+
// PolyFunction apply methods will be eliminated later during
92+
// ElimPolyFunction, so we let them pass here.
93+
def bothPolyApply =
94+
sym1.name == nme.apply &&
95+
(sym1.owner.derivesFrom(defn.PolyFunctionClass) ||
96+
sym2.owner.derivesFrom(defn.PolyFunctionClass))
97+
98+
if (!info1.matchesLoosely(info2) && !bothPolyApply)
9499
ctx.error(DoubleDefinition(sym1, sym2, root), root.sourcePos)
95100
}
96101
val earlyCtx = ctx.withPhase(ctx.elimRepeatedPhase.next)

0 commit comments

Comments
 (0)