aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala108
1 files changed, 0 insertions, 108 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 0af244054..b4418642d 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -97,114 +97,6 @@ trait TypeOps { this: Context =>
}
}
- final def glb(tp1: Type, tp2: Type): Type =
- if (tp1 eq tp2) tp1
- else if (!tp1.exists) tp2
- else if (!tp2.exists) tp1
- else tp2 match { // normalize to disjunctive normal form if possible.
- case OrType(tp21, tp22) =>
- tp1 & tp21 | tp1 & tp22
- case _ =>
- tp1 match {
- case OrType(tp11, tp12) =>
- tp11 & tp2 | tp12 & tp2
- case _ =>
- val t1 = mergeIfSub(tp1, tp2)
- if (t1.exists) t1
- else {
- val t2 = mergeIfSub(tp2, tp1)
- if (t2.exists) t2
- else {
- tp1 match {
- case tp1: TypeType =>
- tp2 match {
- case tp2: TypeType =>
- val b1 = tp1.bounds
- val b2 = tp2.bounds
- return TypeBounds(b1.lo | b2.lo, b1.hi & b2.hi)
- case _ =>
- }
- case _ =>
- }
- AndType(tp1, tp2)
- }
- }
- }
- }
-
- final def glb(tps: List[Type]): Type =
- (defn.AnyType /: tps)(glb)
-
- def lub(tp1: Type, tp2: Type): Type =
- if (tp1 eq tp2) tp1
- else if (!tp1.exists) tp1
- else if (!tp2.exists) tp2
- else {
- val t1 = mergeIfSuper(tp1, tp2)
- if (t1.exists) t1
- else {
- val t2 = mergeIfSuper(tp2, tp1)
- if (t2.exists) t2
- else {
- tp1 match {
- case tp1: TypeType =>
- tp2 match {
- case tp2: TypeType =>
- val b1 = t1.bounds
- val b2 = t2.bounds
- return TypeBounds(b1.lo & b2.lo, b1.hi | b2.hi)
- case _ =>
- }
- case _ =>
- }
- OrType(tp1, tp2)
- }
- }
- }
-
- final def lub(tps: List[Type]): Type =
- (defn.NothingType /: tps)(lub)
-
- /** Merge `t1` into `tp2` if t1 is a subtype of some &-summand of tp2.
- */
- private def mergeIfSub(tp1: Type, tp2: Type)(implicit ctx: Context): Type =
- if (tp1 <:< tp2)
- if (tp2 <:< tp1) tp2 else tp1 // keep existing type if possible
- else tp2 match {
- case tp2 @ AndType(tp21, tp22) =>
- val lower1 = mergeIfSub(tp1, tp21)
- if (lower1 eq tp21) tp2
- else if (lower1.exists) lower1 & tp22
- else {
- val lower2 = mergeIfSub(tp1, tp22)
- if (lower2 eq tp22) tp2
- else if (lower2.exists) tp21 & lower2
- else NoType
- }
- case _ =>
- NoType
- }
-
- /** Merge `tp1` into `tp2` if tp1 is a supertype of some |-summand of tp2.
- */
- private def mergeIfSuper(tp1: Type, tp2: Type)(implicit ctx: Context): Type =
- if (tp2 <:< tp1)
- if (tp1 <:< tp2) tp2 else tp1 // keep existing type if possible
- else tp2 match {
- case tp2 @ OrType(tp21, tp22) =>
- val higher1 = mergeIfSuper(tp1, tp21)
- if (higher1 eq tp21) tp2
- else if (higher1.exists) higher1 | tp22
- else {
- val higher2 = mergeIfSuper(tp1, tp22)
- if (higher2 eq tp22) tp2
- else if (higher2.exists) tp21 | higher2
- else NoType
- }
- case _ =>
- NoType
- }
-
/** Normalize a list of parent types of class `cls` that may contain refinements
* to a list of typerefs, by converting all refinements to member
* definitions in scope `decls`. Can add members to `decls` as a side-effect.