@@ -4501,9 +4501,21 @@ object Types {
4501
4501
* @param creatorState The typer state in which the variable was created.
4502
4502
* @param nestingLevel Symbols with a nestingLevel strictly greater than this
4503
4503
* will not appear in the instantiation of this type variable.
4504
- * This is enforced in `ConstraintHandling#fixLevels`.
4505
- * The `nestingLevel` of a type variable can be made smaller when
4506
- * fixing the levels for some other type variable instance.
4504
+ * This is enforced in `ConstraintHandling`, dependig on the
4505
+ * Config flags setting `checkLevelsOnConstraints` and
4506
+ * `checkLevelsOnInstantiation`.
4507
+ *
4508
+ * Under `checkLevelsOnConstraints` we maintain the invariant that
4509
+ * the `nonParamBounds` of a type variable never refer to a type with a
4510
+ * greater `nestingLevel` (see `legalBound` for the reason why this
4511
+ * cannot be delayed until instantiation). Then, on instantiation,
4512
+ * we replace any param in the param bound with a level greater than
4513
+ * nestingLevel (see `fullLowerBound`).
4514
+ *
4515
+ * Under `checkLevelsOnInstantiation`, we avoid incorrect levels only
4516
+ * when a type variable is instantiated, see `ConstraintHandling$fixLevels`.
4517
+ * Under this mode, the `nestingLevel` of a type variable can be made
4518
+ * smaller when fixing the levels for some other type variable instance.
4507
4519
*/
4508
4520
final class TypeVar private (initOrigin : TypeParamRef , creatorState : TyperState | Null , var nestingLevel : Int ) extends CachedProxyType with ValueType {
4509
4521
private var currentOrigin = initOrigin
0 commit comments