From 928a2a99288c3aa425654e63aea5ddc70359d4ac Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 18 Jun 2013 23:23:24 +0200 Subject: Distribute & into TypeTypes. &, | on two TypeTypes yielded AndTypes and OrTypes, which is wrong. We now turn any ClassInfoTypes into TypeBounds and distribute the operator into the bounds, creating a TypeBounds type. --- src/dotty/tools/dotc/core/TypeOps.scala | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc') diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 164335554..7d82cbffe 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -114,7 +114,20 @@ trait TypeOps { this: Context => else { val t2 = mergeIfSub(tp2, tp1) if (t2.exists) t2 - else AndType(tp1, tp2) + 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) + } } } } @@ -132,7 +145,20 @@ trait TypeOps { this: Context => else { val t2 = mergeIfSuper(tp2, tp1) if (t2.exists) t2 - else OrType(tp1, tp2) + 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) + } } } -- cgit v1.2.3