Skip to content

Remove Type#hasNonWildcard{LowerBound, UpperBound} #13784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4615,20 +4615,6 @@ object Types {
/** For uninstantiated type variables: Is the upper bound different from Any? */
def hasUpperBound(using Context): Boolean = !currentEntry.hiBound.isRef(defn.AnyClass)

/** For uninstantiated type variables: Is the lower bound different from Nothing and
* does it not contain wildcard types?
*/
def hasNonWildcardLowerBound(using Context): Boolean =
val lo = currentEntry.loBound
!lo.isExactlyNothing && !lo.containsWildcardTypes

/** For uninstantiated type variables: Is the upper bound different from Any and
* does it not contain wildcard types?
*/
def hasNonWildcardUpperBound(using Context): Boolean =
val hi = currentEntry.hiBound
!hi.isRef(defn.AnyClass) && !hi.containsWildcardTypes

/** Unwrap to instance (if instantiated) or origin (if not), until result
* is no longer a TypeVar
*/
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ object Inferencing {
&& {
val direction = instDirection(tvar.origin)
if minimizeSelected then
if direction <= 0 && tvar.hasNonWildcardLowerBound then
if direction <= 0 && tvar.hasLowerBound then
instantiate(tvar, fromBelow = true)
else if direction >= 0 && tvar.hasNonWildcardUpperBound then
else if direction >= 0 && tvar.hasUpperBound then
instantiate(tvar, fromBelow = false)
// else hold off instantiating unbounded unconstrained variable
else if direction != 0 then
Expand Down