From d32bd56a4444a5ca945700ece8c0ae93201093e1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 4 Jan 2019 19:02:57 +0100 Subject: [PATCH] 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. --- .../dotty/tools/dotc/core/TypeComparer.scala | 2 ++ tests/pos/i5666.scala | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/pos/i5666.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 9152d6d38a51..f50d1a9a9896 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -171,6 +171,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] { derefCount += 1 if (derefCount >= DerefLimit) NoType else try mapOver(t.ref) finally derefCount -= 1 + case tp: TypeVar => + tp case _ => mapOver(t) } diff --git a/tests/pos/i5666.scala b/tests/pos/i5666.scala new file mode 100644 index 000000000000..fb4be4e02da3 --- /dev/null +++ b/tests/pos/i5666.scala @@ -0,0 +1,20 @@ +// This file should still compile if Config.LogPrendingSubtypesthreshold is set to 9. +sealed trait HList +trait HNil extends HList +trait HCons[+H, +T] extends HList + +trait Concat[L1, L2] { type Out } +object Concat { + implicit def i0[L]: + Concat[HNil, L] { type Out = L } = null + + implicit def i1[H, T, L, O] + (implicit c: Concat[T, L] { type Out = O }): + Concat[HCons[H, T], L] { type Out = HCons[H, O] } = null +} + +object Test { + type L1 = HCons[Unit, HNil] + + implicitly[Concat[L1, L1]] +} \ No newline at end of file