Skip to content

Commit 52b5e22

Browse files
committed
Add missing case in TypeComparer
TypeArgRefs with equal prefix, classes and indices should compare as equal. Previously this probably was not detected because equal prefixes happened to be identical and then the `eq` case in isSubType would kick in. The problematic case happened when comparing `ParMapLike[<lots of arguments>]#<typearg Sequential>` with itself except that one side had a Lazy(CC) where the other had a CC. It was in compileStdLib, in case you were wondering.
1 parent d3e1eef commit 52b5e22

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
528528
}
529529
compareExpr
530530
case tp2: TypeArgRef =>
531-
isSubType(tp1, tp2.underlying.loBound) || fourthTry(tp1, tp2)
531+
def sameTypeArgRef = tp1 match {
532+
case tp1: TypeArgRef =>
533+
tp1.clsRef == tp2.clsRef && tp1.idx == tp2.idx && tp1.prefix =:= tp2.prefix
534+
case _ =>
535+
false
536+
}
537+
sameTypeArgRef || isSubType(tp1, tp2.underlying.loBound) || fourthTry(tp1, tp2)
532538
case tp2 @ TypeBounds(lo2, hi2) =>
533539
def compareTypeBounds = tp1 match {
534540
case tp1 @ TypeBounds(lo1, hi1) =>

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CompilationTests extends ParallelTesting {
3232
// Positive tests ------------------------------------------------------------
3333

3434
// @Test // enable to test compileStdLib separately with detailed stats
35-
def compileStdLib: Unit = {
36-
implicit val testGroup: TestGroup = TestGroup("compileStdLib")
35+
def compileStdLibOnly: Unit = {
36+
implicit val testGroup: TestGroup = TestGroup("compileStdLibOnly")
3737
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline", "-Ydetailed-stats"))
3838
}.checkCompile()
3939

0 commit comments

Comments
 (0)