Skip to content

Commit

Permalink
Remove tvars cleanup in typedArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Oct 25, 2024
1 parent 6d9c46b commit 1d009a4
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -500,29 +500,6 @@ object ProtoTypes {
// We only need to propagate constraints if we typed the arguments in a different
// TyperState and if that created additional constraints.
if (passedTyperState ne protoTyperState) && (oldConstraint ne newConstraint) then
// To respect the pre-condition of `mergeConstraintWith` and keep
// `protoTyperState` committable we must ensure that it does not
// contain any type variable which don't already exist in the passed
// TyperState. This is achieved by instantiating any such type
// variable. NOTE: this does not suffice to discard type variables
// in ancestors of `protoTyperState`, if this situation ever
// comes up, an assertion in TyperState will trigger and this code
// will need to be generalized.
if protoTyperState.isCommittable then
val passedConstraint = passedTyperState.constraint
val newLambdas = newConstraint.domainLambdas.filter(tl =>
!passedConstraint.contains(tl) || passedConstraint.hasConflictingTypeVarsFor(tl, newConstraint))
val newTvars = newLambdas.flatMap(_.paramRefs).map(newConstraint.typeVarOfParam)

args1.foreach(arg => Inferencing.instantiateSelected(arg.tpe, newTvars))

// `instantiateSelected` can leave some type variables uninstantiated,
// so we maximize them in a second pass.
newTvars.foreach {
case tvar: TypeVar if !tvar.isInstantiated =>
tvar.instantiate(fromBelow = false)
case _ =>
}
passedTyperState.mergeConstraintWith(protoTyperState)(using passedCtx)
end if
args1
Expand Down

0 comments on commit 1d009a4

Please sign in to comment.