Fix OrderingConstraint#order forgetting constraints; fix avoidLambdaParams #15077
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
order
takescurrent
as input and returns a constraint set that subsumes bothcurrent
andparam1 <: param2
, but it's an instance method because it relieson
this
to determine ifcurrent
is used linearly such that we can reuse itsbacking arrays instead of copying them. However, the implementation of
order
mistakenly returned
this
and called methods onthis
instead ofcurrent
.This lead to issues like #11682 but that was compensated by logic inserted
in ConstraintHandling#addToConstraint which we can now remove.
Fixing this also required fixing an unrelated issue in avoidLambdaParams to
prevent a regression in tests/pos/i9676.scala: we shouldn't avoid a lambda param
under its own binder even if it is in
comparedTypeLambdas
, the sequence ofoperations where this happens is:
We end up checking
[A] =>> List[A] <:< G
instead of justList <:< G
becauseof
ensureLambdaSub
incompareAppliedTypeParamRef
. I'm not sure if this isactually needed, but I decided to not disturb that code too much for now.