aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-09-24 16:42:14 +0200
committerMartin Odersky <odersky@gmail.com>2015-10-01 19:33:25 +0200
commit424fab79e56d376acbc2cdb5a203a527d0b2248d (patch)
tree314b979305d74e58b4f79aa4deadaedfec2dfe33 /src
parent6288a1bb35f8167ad3ba8784fb9ac95e7fbde7e7 (diff)
downloaddotty-424fab79e56d376acbc2cdb5a203a527d0b2248d.tar.gz
dotty-424fab79e56d376acbc2cdb5a203a527d0b2248d.tar.bz2
dotty-424fab79e56d376acbc2cdb5a203a527d0b2248d.zip
Opportunistically merge A & A -> A and B | B -> B in <:<
Cases like these (in fact one of the operads was a type variable the other its underlying polyparam) arose in pos/overloads.scala and caused deep subtype recursions.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index d98ff1f03..0c736078b 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -215,6 +215,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
compareSuper
case AndType(tp21, tp22) =>
isSubType(tp1, tp21) && isSubType(tp1, tp22)
+ case OrType(tp21, tp22) =>
+ if (tp21.stripTypeVar eq tp22.stripTypeVar) isSubType(tp1, tp21)
+ else thirdTry(tp1, tp2)
case TypeErasure.ErasedValueType(cls2, underlying2) =>
def compareErasedValueType = tp1 match {
case TypeErasure.ErasedValueType(cls1, underlying1) =>
@@ -277,6 +280,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
isSubType(tp1.ref, tp2)
case tp1: AnnotatedType =>
isSubType(tp1.tpe, tp2)
+ case AndType(tp11, tp12) =>
+ if (tp11.stripTypeVar eq tp12.stripTypeVar) isSubType(tp11, tp2)
+ else thirdTry(tp1, tp2)
case OrType(tp11, tp12) =>
isSubType(tp11, tp2) && isSubType(tp12, tp2)
case ErrorType =>