aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/ConstraintHandling.scala8
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala4
2 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/ConstraintHandling.scala b/src/dotty/tools/dotc/core/ConstraintHandling.scala
index 2aa2a4acd..c3243f5d9 100644
--- a/src/dotty/tools/dotc/core/ConstraintHandling.scala
+++ b/src/dotty/tools/dotc/core/ConstraintHandling.scala
@@ -68,8 +68,14 @@ trait ConstraintHandling {
try isSubType(tp1, tp2)
finally frozenConstraint = saved
}
+
+ protected def constraintImpliesSub(param: PolyParam, tp: Type): Boolean =
+ isSubTypeWhenFrozen(bounds(param).hi, tp)
+
+ protected def constraintImpliesSuper(param: PolyParam, tp: Type): Boolean =
+ isSubTypeWhenFrozen(tp, bounds(param).lo)
- /** The current bounds of type parameter `param` */
+ /** The current bounds of type parameter `param` */
final def bounds(param: PolyParam): TypeBounds = constraint at param match {
case bounds: TypeBounds if !ignoreConstraint => bounds
case _ => param.binder.paramBounds(param.paramNum)
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 457b29829..d327da017 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -180,7 +180,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
tp2 == tp1 || {
if (solvedConstraint && (constraint contains tp2)) isSubType(tp1, bounds(tp2).lo)
else
- isSubTypeWhenFrozen(tp1, bounds(tp2).lo) || {
+ constraintImpliesSuper(tp2, tp1) || {
if (isConstrained(tp2)) addConstraint(tp2, tp1.widenExpr, fromBelow = true)
else (ctx.mode is Mode.TypevarsMissContext) || secondTry(tp1, tp2)
}
@@ -242,7 +242,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
tp1 == tp2 || {
if (solvedConstraint && (constraint contains tp1)) isSubType(bounds(tp1).lo, tp2)
else
- isSubTypeWhenFrozen(bounds(tp1).hi, tp2) || {
+ constraintImpliesSub(tp1, tp2) || {
if (isConstrained(tp1))
addConstraint(tp1, tp2, fromBelow = false) && {
if ((!frozenConstraint) &&