Skip to content

Commit 824108c

Browse files
committed
Document suspicious code in ProperGadtConstraint#tvar
1 parent e1df3ae commit 824108c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,20 @@ final class ProperGadtConstraint private(
193193
case null =>
194194
val res = {
195195
import NameKinds.DepParamName
196+
// For symbols standing for HK types, we need to preserve the kind information
197+
// (see also usage of adaptHKvariances above)
198+
// Ideally we'd always preserve the bounds,
199+
// but first we need an equivalent of ConstraintHandling#addConstraint
200+
// TODO: implement the above
201+
val initialBounds = sym.info match {
202+
case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb
203+
case _ => TypeBounds.empty
204+
}
196205
// avoid registering the TypeVar with TyperState / TyperState#constraint
197206
// - we don't want TyperState instantiating these TypeVars
198207
// - we don't want TypeComparer constraining these TypeVars
199208
val poly = PolyType(DepParamName.fresh(sym.name.toTypeName) :: Nil)(
200-
pt => (sym.info match {
201-
case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb
202-
case _ => TypeBounds.empty
203-
}) :: Nil,
209+
pt => initialBounds :: Nil,
204210
pt => defn.AnyType)
205211
new TypeVar(poly.paramRefs.head, creatorState = null)
206212
}

0 commit comments

Comments
 (0)