aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/ConstraintHandling.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-13 17:35:12 +0100
committerMartin Odersky <odersky@gmail.com>2015-01-13 17:35:12 +0100
commit3e3ef5222429beddedd6912feeff7975bdd67bf8 (patch)
tree9646fa0c2fd872c923fc8d3cb2a16f72884c30ee /src/dotty/tools/dotc/core/ConstraintHandling.scala
parent155049286628843eb7aeb2d8d610ac53291ea6f3 (diff)
downloaddotty-3e3ef5222429beddedd6912feeff7975bdd67bf8.tar.gz
dotty-3e3ef5222429beddedd6912feeff7975bdd67bf8.tar.bz2
dotty-3e3ef5222429beddedd6912feeff7975bdd67bf8.zip
Two new hooks in ConstraintHandling
Unlike isSubtypeWhenFrozen, these can be implemented by TrackingConstraint without needing full bounds, which is expensive.
Diffstat (limited to 'src/dotty/tools/dotc/core/ConstraintHandling.scala')
-rw-r--r--src/dotty/tools/dotc/core/ConstraintHandling.scala8
1 files changed, 7 insertions, 1 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)