@@ -1353,19 +1353,18 @@ object Types {
13531353 def tp1 : Type
13541354 def tp2 : Type
13551355 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?
13581357 }
13591358
13601359 abstract case class AndType (tp1 : Type , tp2 : Type ) extends CachedGroundType with AndOrType {
13611360
13621361 def isAnd = true
13631362
1364- def derivedAndType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndType =
1363+ def derivedAndType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
13651364 if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
1366- else AndType (tp1, tp2)
1365+ else AndType .make (tp1, tp2)
13671366
1368- def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndOrType =
1367+ def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
13691368 derivedAndType(tp1, tp2)
13701369
13711370 override def computeHash = doHash(tp1, tp2)
@@ -1381,18 +1380,19 @@ object Types {
13811380 def unchecked (tp1 : Type , tp2 : Type )(implicit ctx : Context ) = {
13821381 unique(new CachedAndType (tp1, tp2))
13831382 }
1383+ def make (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
1384+ if (tp1 eq tp2) tp1 else apply(tp1, tp2)
13841385 }
13851386
13861387 abstract case class OrType (tp1 : Type , tp2 : Type ) extends CachedGroundType with AndOrType {
13871388 assert(tp1.isInstanceOf [ValueType ] && tp2.isInstanceOf [ValueType ])
1388-
13891389 def isAnd = false
13901390
1391- def derivedOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): OrType =
1391+ def derivedOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
13921392 if ((tp1 eq this .tp1) && (tp2 eq this .tp2)) this
1393- else OrType (tp1, tp2)
1393+ else OrType .make (tp1, tp2)
13941394
1395- def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): AndOrType =
1395+ def derivedAndOrType (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type =
13961396 derivedOrType(tp1, tp2)
13971397
13981398 override def computeHash = doHash(tp1, tp2)
@@ -1403,6 +1403,8 @@ object Types {
14031403 object OrType {
14041404 def apply (tp1 : Type , tp2 : Type )(implicit ctx : Context ) =
14051405 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)
14061408 }
14071409
14081410 // ----- Method types: MethodType/ExprType/PolyType -------------------------------
0 commit comments