Skip to content

Commit a9ad052

Browse files
committed
Fix "have same type after erasure" check
Perform the overriding checks after elimByName. I observed some problem with catsEffect2, where a super accessor method with a `() ?=> T` parameter was compared with a corresponding super accessor method with a `=> T` parameter. One of these methods was generated before elimByName, the other after. So comparing them at phase elimRepeated + 1 gave two different types. The problem is fixed by comparing after elimByName, which means that the type of the second method is converted to match the first.
1 parent 368cca1 commit a9ad052

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,17 +1512,17 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
15121512
arg2.contains(arg1norm)
15131513
case ExprType(arg2res)
15141514
if ctx.phaseId > elimByNamePhase.id && !ctx.erasedTypes
1515-
&& defn.isByNameFunction(arg1) =>
1515+
&& defn.isByNameFunction(arg1.dealias) =>
15161516
// ElimByName maps `=> T` to `()? => T`, but only in method parameters. It leaves
15171517
// embedded `=> T` arguments alone. This clause needs to compensate for that.
1518-
isSubArg(arg1.argInfos.head, arg2res)
1518+
isSubArg(arg1.dealias.argInfos.head, arg2res)
15191519
case _ =>
15201520
arg1 match
15211521
case arg1: TypeBounds =>
15221522
compareCaptured(arg1, arg2)
15231523
case ExprType(arg1res)
15241524
if ctx.phaseId > elimByNamePhase.id && !ctx.erasedTypes
1525-
&& defn.isByNameFunction(arg2) =>
1525+
&& defn.isByNameFunction(arg2.dealias) =>
15261526
isSubArg(arg1res, arg2.argInfos.head)
15271527
case _ =>
15281528
(v > 0 || isSubType(arg2, arg1)) &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ElimErasedValueType extends MiniPhase with InfoTransformer { thisPhase =>
117117
// Do the test at the earliest phase where both symbols existed.
118118
val phaseId =
119119
sym1.originDenotation.validFor.firstPhaseId max sym2.originDenotation.validFor.firstPhaseId
120-
atPhase(elimRepeatedPhase.next)(checkNoConflict(sym1, sym2, sym1.info))
120+
atPhase(elimByNamePhase.next)(checkNoConflict(sym1, sym2, sym1.info))
121121
opc.next()
122122
}
123123
}

0 commit comments

Comments
 (0)