Skip to content

Commit

Permalink
Rename rigid --> hard
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jul 10, 2022
1 parent bf7356e commit b0d0611
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling

def hardenTypeVars(tp2: Type): Unit = tp2.dealiasKeepRefiningAnnots match
case tvar: TypeVar if constraint.contains(tvar.origin) =>
state.rigidVars += tvar
state.hardVars += tvar
case tp2: TypeParamRef if constraint.contains(tp2) =>
hardenTypeVars(constraint.typeVarOfParam(tp2))
case tp2: AndOrType =>
Expand Down
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/dotc/core/TyperState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object TyperState {
def snapshot()(using Context): Snapshot =
var previouslyInstantiated: TypeVars = SimpleIdentitySet.empty
for tv <- ts.ownedVars do if tv.inst.exists then previouslyInstantiated += tv
(ts.constraint, ts.ownedVars, previouslyInstantiated, ts.rigidVars)
(ts.constraint, ts.ownedVars, previouslyInstantiated, ts.hardVars)

def resetTo(state: Snapshot)(using Context): Unit =
val (c, tvs, previouslyInstantiated, rvars) = state
Expand All @@ -38,7 +38,7 @@ object TyperState {
tv.resetInst(ts)
ts.ownedVars = tvs
ts.constraint = c
ts.rigidVars = rvars
ts.hardVars = rvars
}

class TyperState() {
Expand Down Expand Up @@ -94,9 +94,9 @@ class TyperState() {
* its lower bound, top-level soft unions in the instance type are converted
* to hard unions instead of being widened in `widenOr`.
*/
private var myRigidVars: TypeVars = _
def rigidVars: TypeVars = myRigidVars
def rigidVars_=(tvs: TypeVars): Unit = myRigidVars = tvs
private var myHardVars: TypeVars = _
def hardVars: TypeVars = myHardVars
def hardVars_=(tvs: TypeVars): Unit = myHardVars = tvs

/** Initializes all fields except reporter, isCommittable, which need to be
* set separately.
Expand All @@ -108,7 +108,7 @@ class TyperState() {
this.myConstraint = constraint
this.previousConstraint = constraint
this.myOwnedVars = SimpleIdentitySet.empty
this.myRigidVars = SimpleIdentitySet.empty
this.myHardVars = SimpleIdentitySet.empty
this.isCommitted = false
this

Expand All @@ -119,7 +119,7 @@ class TyperState() {
val ts = TyperState().init(this, this.constraint)
.setReporter(reporter)
.setCommittable(committable)
ts.rigidVars = this.rigidVars
ts.hardVars = this.hardVars
ts

/** The uninstantiated variables */
Expand Down Expand Up @@ -173,7 +173,7 @@ class TyperState() {
constr.println(i"committing $this to $targetState, fromConstr = $constraint, toConstr = ${targetState.constraint}")
if targetState.constraint eq previousConstraint then
targetState.constraint = constraint
targetState.rigidVars = rigidVars
targetState.hardVars = hardVars
if !ownedVars.isEmpty then ownedVars.foreach(targetState.includeVar)
else
targetState.mergeConstraintWith(this)
Expand Down Expand Up @@ -226,7 +226,7 @@ class TyperState() {
val otherLos = other.lower(p)
val otherHis = other.upper(p)
val otherEntry = other.entry(p)
if that.rigidVars.contains(tv) then this.myRigidVars += tv
if that.hardVars.contains(tv) then this.myHardVars += tv
( (otherLos eq constraint.lower(p)) || otherLos.forall(_ <:< p)) &&
( (otherHis eq constraint.upper(p)) || otherHis.forall(p <:< _)) &&
((otherEntry eq constraint.entry(p)) || otherEntry.match
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4576,7 +4576,7 @@ object Types {
instantiateWith(tp)

def widenUnions(using Context) =
!ctx.typerState.rigidVars.contains(this)
!ctx.typerState.hardVars.contains(this)

/** For uninstantiated type variables: the entry in the constraint (either bounds or
* provisional instance value)
Expand Down

0 comments on commit b0d0611

Please sign in to comment.