From 0e8d0bb1fbe557665f4db9edcd51dc4c49a7ae15 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 20 Jan 2014 15:59:25 +0100 Subject: Make better use of AndOrTypes. --- src/dotty/tools/dotc/Main.scala | 1 - src/dotty/tools/dotc/core/TypeComparer.scala | 3 +-- src/dotty/tools/dotc/core/Types.scala | 16 +++++----------- 3 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src/dotty') diff --git a/src/dotty/tools/dotc/Main.scala b/src/dotty/tools/dotc/Main.scala index 0222924da..a86422f52 100644 --- a/src/dotty/tools/dotc/Main.scala +++ b/src/dotty/tools/dotc/Main.scala @@ -10,7 +10,6 @@ import reporting.Reporter /* To do: * - simplify hk types - * - make use of AndOrType * - review isSubType * - have a second look at normalization (leave at method types if pt is method type?) * - Don't open package objects from class files if they are present in source diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 631363e3e..3a15a50e1 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -481,8 +481,7 @@ class TypeComparer(initctx: Context) extends DotClass { def isCappable(tp: Type): Boolean = tp match { case tp: PolyParam => constraint contains tp case tp: TypeProxy => isCappable(tp.underlying) - case tp: AndType => isCappable(tp.tp1) || isCappable(tp.tp2) - case tp: OrType => isCappable(tp.tp1) || isCappable(tp.tp2) + case tp: AndOrType => isCappable(tp.tp1) || isCappable(tp.tp2) case _ => false } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index b628d9c50..0325c5460 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -250,7 +250,7 @@ object Types { val lsym = l.classSymbol val rsym = r.classSymbol if (lsym isSubClass rsym) lsym - else if (rsym.isSubClass(lsym)) rsym + else if (rsym isSubClass lsym) rsym else NoSymbol case OrType(l, r) => val lsym = l.classSymbol @@ -2177,11 +2177,8 @@ object Types { val inst = tp.instanceOpt if (inst.exists) apply(inst) else tp - case tp: AndType => - tp.derivedAndType(this(tp.tp1), this(tp.tp2)) - - case tp: OrType => - tp.derivedOrType(this(tp.tp1), this(tp.tp2)) + case tp: AndOrType => + tp.derivedAndOrType(this(tp.tp1), this(tp.tp2)) case tp @ AnnotatedType(annot, underlying) => val underlying1 = mapOver(underlying) @@ -2330,11 +2327,8 @@ object Types { case tp @ ClassInfo(prefix, _, _, _, _) => this(x, prefix) - case AndType(l, r) => - this(this(x, l), r) - - case OrType(l, r) => - this(this(x, l), r) + case tp: AndOrType => + this(this(x, tp.tp1), tp.tp2) case AnnotatedType(annot, underlying) => this(this(x, annot), underlying) -- cgit v1.2.3