Skip to content

Commit d32bd56

Browse files
committed
Fix #5666: Fix normalizing map when testing for seen pairs
When testing for seen pairs we subject both types to a "normalize" type map that derefereces LayVals. This is tricky but necessary. But we should take care that the map does not disturbe the types in any other way. In particular it should not replace a TypeVar by its instance.
1 parent a4d38b9 commit d32bd56

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
171171
derefCount += 1
172172
if (derefCount >= DerefLimit) NoType
173173
else try mapOver(t.ref) finally derefCount -= 1
174+
case tp: TypeVar =>
175+
tp
174176
case _ =>
175177
mapOver(t)
176178
}

tests/pos/i5666.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file should still compile if Config.LogPrendingSubtypesthreshold is set to 9.
2+
sealed trait HList
3+
trait HNil extends HList
4+
trait HCons[+H, +T] extends HList
5+
6+
trait Concat[L1, L2] { type Out }
7+
object Concat {
8+
implicit def i0[L]:
9+
Concat[HNil, L] { type Out = L } = null
10+
11+
implicit def i1[H, T, L, O]
12+
(implicit c: Concat[T, L] { type Out = O }):
13+
Concat[HCons[H, T], L] { type Out = HCons[H, O] } = null
14+
}
15+
16+
object Test {
17+
type L1 = HCons[Unit, HNil]
18+
19+
implicitly[Concat[L1, L1]]
20+
}

0 commit comments

Comments
 (0)