aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-05 17:14:25 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-05 17:14:25 +0200
commitce45711bfcadf22fee2ade9c86b43ada2db0609b (patch)
tree022351e46ba5a3bce8825e6ccaf6997eb9df72a4 /src
parent7736cfb8ff8f5fafee87eb094f15627f4f097165 (diff)
downloaddotty-ce45711bfcadf22fee2ade9c86b43ada2db0609b.tar.gz
dotty-ce45711bfcadf22fee2ade9c86b43ada2db0609b.tar.bz2
dotty-ce45711bfcadf22fee2ade9c86b43ada2db0609b.zip
Made & , | NoType-aware.
For the pruposes of & and |, NoType is now treated as top type, above Any.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala8
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala4
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
3 files changed, 8 insertions, 8 deletions
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