Skip to content

Commit 0e8d0bb

Browse files
committed
Make better use of AndOrTypes.
1 parent 608fbca commit 0e8d0bb

File tree

4 files changed

+1458
-40
lines changed

4 files changed

+1458
-40
lines changed

src/dotty/tools/dotc/Main.scala

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import reporting.Reporter
1010

1111
/* To do:
1212
* - simplify hk types
13-
* - make use of AndOrType
1413
* - review isSubType
1514
* - have a second look at normalization (leave at method types if pt is method type?)
1615
* - Don't open package objects from class files if they are present in source

src/dotty/tools/dotc/core/TypeComparer.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,7 @@ class TypeComparer(initctx: Context) extends DotClass {
481481
def isCappable(tp: Type): Boolean = tp match {
482482
case tp: PolyParam => constraint contains tp
483483
case tp: TypeProxy => isCappable(tp.underlying)
484-
case tp: AndType => isCappable(tp.tp1) || isCappable(tp.tp2)
485-
case tp: OrType => isCappable(tp.tp1) || isCappable(tp.tp2)
484+
case tp: AndOrType => isCappable(tp.tp1) || isCappable(tp.tp2)
486485
case _ => false
487486
}
488487

src/dotty/tools/dotc/core/Types.scala

+5-11
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ object Types {
250250
val lsym = l.classSymbol
251251
val rsym = r.classSymbol
252252
if (lsym isSubClass rsym) lsym
253-
else if (rsym.isSubClass(lsym)) rsym
253+
else if (rsym isSubClass lsym) rsym
254254
else NoSymbol
255255
case OrType(l, r) =>
256256
val lsym = l.classSymbol
@@ -2177,11 +2177,8 @@ object Types {
21772177
val inst = tp.instanceOpt
21782178
if (inst.exists) apply(inst) else tp
21792179

2180-
case tp: AndType =>
2181-
tp.derivedAndType(this(tp.tp1), this(tp.tp2))
2182-
2183-
case tp: OrType =>
2184-
tp.derivedOrType(this(tp.tp1), this(tp.tp2))
2180+
case tp: AndOrType =>
2181+
tp.derivedAndOrType(this(tp.tp1), this(tp.tp2))
21852182

21862183
case tp @ AnnotatedType(annot, underlying) =>
21872184
val underlying1 = mapOver(underlying)
@@ -2330,11 +2327,8 @@ object Types {
23302327
case tp @ ClassInfo(prefix, _, _, _, _) =>
23312328
this(x, prefix)
23322329

2333-
case AndType(l, r) =>
2334-
this(this(x, l), r)
2335-
2336-
case OrType(l, r) =>
2337-
this(this(x, l), r)
2330+
case tp: AndOrType =>
2331+
this(this(x, tp.tp1), tp.tp2)
23382332

23392333
case AnnotatedType(annot, underlying) =>
23402334
this(this(x, annot), underlying)

0 commit comments

Comments
 (0)