From 95c5a5dc4f940d63a8b4884524d82105c9dced6f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 31 Dec 2013 19:09:36 +0100 Subject: Combining AndType, OrType into common Trait. Still need to explore where we can use this (one usage will be in TypeComparers). --- src/dotty/tools/dotc/core/Types.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 9d3cf898d..2fd6ef6b7 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1378,7 +1378,12 @@ object Types { // --- AndType/OrType --------------------------------------------------------------- - abstract case class AndType(tp1: Type, tp2: Type) extends CachedGroundType with ValueType { + trait AndOrType extends ValueType { // todo: check where we can simplify using AndOrType + def tp1: Type + def tp2: Type + } + + abstract case class AndType(tp1: Type, tp2: Type) extends CachedGroundType with AndOrType { assert(tp1.isInstanceOf[ValueType] && tp2.isInstanceOf[ValueType], s"$tp1 & $tp2") def derivedAndType(tp1: Type, tp2: Type)(implicit ctx: Context) = @@ -1395,7 +1400,7 @@ object Types { unique(new CachedAndType(tp1, tp2)) } - abstract case class OrType(tp1: Type, tp2: Type) extends CachedGroundType with ValueType { + abstract case class OrType(tp1: Type, tp2: Type) extends CachedGroundType with AndOrType { assert(tp1.isInstanceOf[ValueType] && tp2.isInstanceOf[ValueType], s"$tp1 | $tp2") def derivedOrType(tp1: Type, tp2: Type)(implicit ctx: Context) = -- cgit v1.2.3