Skip to content

Commit 4dea9a7

Browse files
committed
Drop traces of previous dependency checking which was based on levels
1 parent 26e2030 commit 4dea9a7

File tree

3 files changed

+4
-75
lines changed

3 files changed

+4
-75
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,6 @@ abstract class Constraint extends Showable {
188188
*/
189189
def dependsOn(tv: TypeVar, except: TypeVars, co: Boolean)(using Context): Boolean
190190

191-
/** If the type variable `tv` would be instantiated to a larger type, the
192-
* constraint over outer type variables would be narrowed.
193-
*/
194-
def outerDependsCovariantlyOn(tv: TypeVar)(using Context): Boolean
195-
196-
/** If the type variable `tv` would be instantiated to a smaller type, the
197-
* constraint over outer type variables would be narrowed.
198-
*/
199-
def outerDependsContravariantlyOn(tv: TypeVar)(using Context): Boolean
200-
201191
/** Check that no constrained parameter contains itself as a bound */
202192
def checkNonCyclic()(using Context): this.type
203193

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,28 +227,6 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
227227

228228
var coDeps, contraDeps: TypeVarDeps = SimpleIdentityMap.empty
229229

230-
private def outerDependsOn(tv: TypeVar, nestingLevel: Int, deps: TypeVarDeps, lens: ConstraintLens[List[TypeParamRef]], seen: TypeVars)(using Context): Boolean =
231-
232-
def qualifies(tp: Type): Boolean = tp match
233-
case tv1: TypeVar =>
234-
tv1.nestingLevel < tv.nestingLevel
235-
|| tv1.nestingLevel == tv.nestingLevel && tv.origin.paramName.is(DepParamName)
236-
// dependent parameters get created at the same nesting level as the current constraint,
237-
// but are logically nested inside the variables of the expected result type.
238-
|| outerDependsOn(tv1, nestingLevel, deps, lens, seen + tv)
239-
case tp: TypeParamRef =>
240-
qualifies(typeVarOfParam(tp))
241-
case _ =>
242-
false
243-
244-
val tvdeps = deps(tv)
245-
null != tvdeps
246-
&& !seen.contains(tv)
247-
&& (tvdeps.exists(qualifies)
248-
|| lens(this, tv.origin.binder, tv.origin.paramNum).exists(qualifies))
249-
//.showing(i"outer depends on $tv ${tv.initNestingLevel} with ${tvdeps.toList.map(_.initNestingLevel)}%, % = $result")
250-
end outerDependsOn
251-
252230
def dependsOn(tv: TypeVar, except: TypeVars, co: Boolean)(using Context): Boolean =
253231
def test(deps: TypeVarDeps, lens: ConstraintLens[List[TypeParamRef]]) =
254232
val tvdeps = deps(tv)
@@ -258,12 +236,6 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
258236
//.showing(i"outer depends on $tv with ${tvdeps.toList}%, % = $result")
259237
if co then test(coDeps, upperLens) else test(contraDeps, lowerLens)
260238

261-
def outerDependsCovariantlyOn(tv: TypeVar)(using Context) =
262-
outerDependsOn(tv, tv.nestingLevel, coDeps, upperLens, SimpleIdentitySet.empty)
263-
264-
def outerDependsContravariantlyOn(tv: TypeVar)(using Context) =
265-
outerDependsOn(tv, tv.nestingLevel, contraDeps, lowerLens, SimpleIdentitySet.empty)
266-
267239
private class Adjuster(tvar: TypeVar)(using Context) extends TypeTraverser:
268240
var add: Boolean = compiletime.uninitialized
269241

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ import core._
66
import ast._
77
import Contexts._, Types._, Flags._, Symbols._
88
import ProtoTypes._
9-
import NameKinds.{AvoidNameKind, UniqueName}
9+
import NameKinds.UniqueName
1010
import util.Spans._
11-
import util.{Stats, SimpleIdentityMap, SrcPos}
11+
import util.{Stats, SimpleIdentityMap, SimpleIdentitySet, SrcPos}
1212
import Decorators._
1313
import config.Printers.{gadts, typr}
1414
import annotation.tailrec
1515
import reporting._
1616
import collection.mutable
17-
1817
import scala.annotation.internal.sharable
19-
import dotty.tools.dotc.util.SimpleIdentitySet
2018

2119
object Inferencing {
2220

@@ -629,22 +627,6 @@ trait Inferencing { this: Typer =>
629627
// instantiated `tvar` through unification.
630628
val v = vs(tvar)
631629
if v == null then
632-
// Even though `tvar` is non-occurring in `v`, the specific
633-
// instantiation we pick still matters because `tvar` might appear
634-
// in the bounds of a non-`qualifying` type variable in the
635-
// constraint.
636-
// In particular, if `tvar` was created as the upper or lower
637-
// bound of an existing variable by `LevelAvoidMap`, we
638-
// instantiate it in the direction corresponding to the
639-
// original variable which might be further constrained later.
640-
// Otherwise, we simply rely on `hasLowerBound`.
641-
//val name = tvar.origin.paramName
642-
//val fromBelow =
643-
// if name.is(AvoidNameKind.UpperBound) then true
644-
// else if name.is(AvoidNameKind.LowerBound) then false
645-
// else if constraint.outerDependsCovariantlyOn(tvar) then true
646-
// else if constraint.outerDependsContravariantlyOn(tvar) then false
647-
// else tvar.hasLowerBound
648630
toInstantiate += ((tvar, 0))
649631
else if v.intValue != 0 then
650632
toInstantiate += ((tvar, v.intValue))
@@ -699,23 +681,8 @@ trait Inferencing { this: Typer =>
699681
if v == 0 then
700682
val aboveOK = !constraint.dependsOn(tvar, varsToInstantiate, co = true)
701683
val belowOK = !constraint.dependsOn(tvar, varsToInstantiate, co = false)
702-
val now =
703-
if aboveOK == belowOK then tvar.hasLowerBound
704-
else belowOK
705-
/*
706-
val was =
707-
val name = tvar.origin.paramName
708-
val depCo = constraint.outerDependsCovariantlyOn(tvar)
709-
val depContra = constraint.outerDependsContravariantlyOn(tvar)
710-
if name.is(AvoidNameKind.UpperBound) then true
711-
else if name.is(AvoidNameKind.LowerBound) then false
712-
else if constraint.outerDependsCovariantlyOn(tvar) then true
713-
else if constraint.outerDependsContravariantlyOn(tvar) then false
714-
else tvar.hasLowerBound
715-
if now != was then
716-
println(i"diff for $tvar, was $was, aboveOK = $aboveOK, belowOK = $belowOK, depCo = $depCo, depContra = $depContra")
717-
*/
718-
now
684+
if aboveOK == belowOK then tvar.hasLowerBound
685+
else belowOK
719686
else
720687
v == 1
721688
typr.println(

0 commit comments

Comments
 (0)