Skip to content

Commit 36abd38

Browse files
committed
Document suspicious code in ProperGadtConstraint#tvar
1 parent a505b6a commit 36abd38

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
@@ -197,14 +197,20 @@ final class ProperGadtConstraint private(
197197
case null =>
198198
val res = {
199199
import NameKinds.DepParamName
200+
// For symbols standing for HK types, we need to preserve the kind information
201+
// (see also usage of adaptHKvariances above)
202+
// Ideally we'd always preserve the bounds,
203+
// but first we need an equivalent of ConstraintHandling#addConstraint
204+
// TODO: implement the above
205+
val initialBounds = sym.info match {
206+
case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb
207+
case _ => TypeBounds.empty
208+
}
200209
// avoid registering the TypeVar with TyperState / TyperState#constraint
201210
// - we don't want TyperState instantiating these TypeVars
202211
// - we don't want TypeComparer constraining these TypeVars
203212
val poly = PolyType(DepParamName.fresh(sym.name.toTypeName) :: Nil)(
204-
pt => (sym.info match {
205-
case tb @ TypeBounds(_, hi) if hi.isLambdaSub => tb
206-
case _ => TypeBounds.empty
207-
}) :: Nil,
213+
pt => initialBounds :: Nil,
208214
pt => defn.AnyType)
209215
new TypeVar(poly.paramRefs.head, creatorState = null)
210216
}

0 commit comments

Comments
 (0)