From ce45711bfcadf22fee2ade9c86b43ada2db0609b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 5 Apr 2013 17:14:25 +0200 Subject: Made & , | NoType-aware. For the pruposes of & and |, NoType is now treated as top type, above Any. --- src/dotty/tools/dotc/core/SymDenotations.scala | 8 +------- src/dotty/tools/dotc/core/TypeOps.scala | 4 ++++ src/dotty/tools/dotc/core/Types.scala | 4 +++- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 209ef8eae..ad2b8834c 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -857,13 +857,7 @@ object SymDenotations { final def baseTypeOf(tp: Type)(implicit ctx: Context): Type = { def foldGlb(bt: Type, ps: List[Type]): Type = ps match { - case p :: ps1 => - val bt2 = baseTypeOf(p) - val combined = - if (!bt.exists) bt2 - else if (!bt2.exists) bt - else bt & bt2 - foldGlb(combined, ps1) + case p :: ps1 => foldGlb(bt & baseTypeOf(p), ps1) case _ => bt } diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 42dd34f18..efededd7a 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -90,6 +90,8 @@ 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 @@ -113,6 +115,8 @@ trait TypeOps { this: Context => 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 diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index d296acea1..03def9e9a 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -295,7 +295,7 @@ object Types { // member in Super instead of Sub. // As an example of this in the wild, see // loadClassWithPrivateInnerAndSubSelf in ShowClassTests - tp.cls.symbolicRef.findMember(name, pre, excluded) + tp.cls.symbolicRef.findMember(name, pre, excluded) orElse d case tp: TypeProxy => tp.underlying.findMember(name, pre, excluded) case tp: ClassInfo => @@ -1162,6 +1162,8 @@ object Types { // --- AndType/OrType --------------------------------------------------------------- abstract case class AndType(tp1: Type, tp2: Type) extends CachedGroundType with ValueType { + assert(tp1.isValueType) + assert(tp2.isValueType) type This <: AndType -- cgit v1.2.3