@@ -1353,19 +1353,18 @@ object Types {
1353
1353
def tp1 : Type
1354
1354
def tp2 : Type
1355
1355
def isAnd : Boolean
1356
- def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndOrType // needed?
1357
-
1356
+ def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type // needed?
1358
1357
}
1359
1358
1360
1359
abstract case class AndType (tp1 : Type , tp2 : Type ) extends CachedGroundType with AndOrType {
1361
1360
1362
1361
def isAnd = true
1363
1362
1364
- def derivedAndType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndType =
1363
+ def derivedAndType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1365
1364
if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
1366
- else AndType (tp1, tp2)
1365
+ else AndType .make (tp1, tp2)
1367
1366
1368
- def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndOrType =
1367
+ def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1369
1368
derivedAndType(tp1, tp2)
1370
1369
1371
1370
override def computeHash = doHash(tp1, tp2)
@@ -1381,18 +1380,19 @@ object Types {
1381
1380
def unchecked (tp1 : Type , tp2 : Type )(implicit ctx : Context ) = {
1382
1381
unique(new CachedAndType (tp1, tp2))
1383
1382
}
1383
+ def make (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1384
+ if (tp1 eq tp2) tp1 else apply(tp1, tp2)
1384
1385
}
1385
1386
1386
1387
abstract case class OrType (tp1 : Type , tp2 : Type ) extends CachedGroundType with AndOrType {
1387
1388
assert(tp1.isInstanceOf [ValueType ] && tp2.isInstanceOf [ValueType ])
1388
-
1389
1389
def isAnd = false
1390
1390
1391
- def derivedOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): OrType =
1391
+ def derivedOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1392
1392
if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
1393
- else OrType (tp1, tp2)
1393
+ else OrType .make (tp1, tp2)
1394
1394
1395
- def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndOrType =
1395
+ def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1396
1396
derivedOrType(tp1, tp2)
1397
1397
1398
1398
override def computeHash = doHash(tp1, tp2)
@@ -1403,6 +1403,8 @@ object Types {
1403
1403
object OrType {
1404
1404
def apply (tp1 : Type , tp2 : Type )(implicit ctx : Context ) =
1405
1405
unique(new CachedOrType (tp1, tp2))
1406
+ def make (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1407
+ if (tp1 eq tp2) tp1 else apply(tp1, tp2)
1406
1408
}
1407
1409
1408
1410
// ----- Method types: MethodType/ExprType/PolyType -------------------------------
0 commit comments