Skip to content

Commit 6044a54

Browse files
committed
nonParamBounds: convert result to Bounds if needed
Be more defensive to handle other issues such as #4720 (comment). Code that needs to access the actual entry can call `entry` or `contains` instead.
1 parent b06d079 commit 6044a54

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ abstract class Constraint extends Showable {
6060
* are not contained in the return bounds.
6161
* @pre `param` is not part of the constraint domain.
6262
*/
63-
def nonParamBounds(param: TypeParamRef): TypeBounds
63+
def nonParamBounds(param: TypeParamRef)(implicit ctx: Context): TypeBounds
6464

6565
/** The lower bound of `param` including all known-to-be-smaller parameters */
6666
def fullLowerBound(param: TypeParamRef)(implicit ctx: Context): Type

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
191191
def isLess(param1: TypeParamRef, param2: TypeParamRef): Boolean =
192192
upper(param1).contains(param2)
193193

194-
def nonParamBounds(param: TypeParamRef): TypeBounds =
195-
entry(param).asInstanceOf[TypeBounds]
194+
def nonParamBounds(param: TypeParamRef)(implicit ctx: Context): TypeBounds =
195+
entry(param).bounds
196196

197197
def fullLowerBound(param: TypeParamRef)(implicit ctx: Context): Type =
198198
(nonParamBounds(param).lo /: minLower(param))(_ | _)

0 commit comments

Comments
 (0)