diff options
author | Martin Odersky <odersky@gmail.com> | 2015-01-19 09:51:11 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-01-19 09:51:11 +0100 |
commit | 6771786961e708178e56b22b1c2869712f6c3891 (patch) | |
tree | ee8aced652fe51756a3bfb701ec10435c83d4d3a /src/dotty/tools/dotc/core/TypeComparer.scala | |
parent | 5354f88c6ef2dafd5ae876c16c9758155a780783 (diff) | |
download | dotty-6771786961e708178e56b22b1c2869712f6c3891.tar.gz dotty-6771786961e708178e56b22b1c2869712f6c3891.tar.bz2 dotty-6771786961e708178e56b22b1c2869712f6c3891.zip |
Compare ThisType refactoring
Moved comparisons between ThisType x$.this and NamedType x.type
where x$ is the module class of x. They were uner NamedType, are
now under ThisType. That way NamedType reasoning is a bit uncluttered.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 720e372d2..ae9e0f660 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -174,8 +174,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi !tp1.isInstanceOf[WithFixedSym] && !tp2.isInstanceOf[WithFixedSym] ) || isHKSubType || secondTryNamed(tp1, tp2) - case tp1: ThisType if tp1.cls eq tp2.symbol.moduleClass => - isSubType(tp1.cls.owner.thisType, tp2.prefix) case _ => isHKSubType || secondTry(tp1, tp2) } @@ -216,6 +214,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi // A's selftype derives from B and B's selftype derives from A. tp1.cls.classInfo.selfType.derivesFrom(tp2.cls) && tp2.cls.classInfo.selfType.derivesFrom(tp1.cls) + case tp1: TermRef if tp2.cls eq tp1.symbol.moduleClass => + isSubType(tp1.prefix, tp2.cls.owner.thisType) case _ => secondTry(tp1, tp2) } @@ -238,14 +238,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi private def secondTry(tp1: Type, tp2: Type): Boolean = tp1 match { case tp1: NamedType => - tp2 match { - case tp2: ThisType if tp2.cls eq tp1.symbol.moduleClass => - isSubType(tp1.prefix, tp2.cls.owner.thisType) - case _ => - secondTryNamed(tp1, tp2) - } - case OrType(tp11, tp12) => - isSubType(tp11, tp2) && isSubType(tp12, tp2) + secondTryNamed(tp1, tp2) case tp1: PolyParam => def flagNothingBound = { if ((!frozenConstraint) && @@ -268,6 +261,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi } } comparePolyParam + case tp1: ThisType => + tp2 match { + case tp2: TermRef if tp1.cls eq tp2.symbol.moduleClass => + isSubType(tp1.cls.owner.thisType, tp2.prefix) + case _ => + thirdTry(tp1, tp2) + } case tp1: SkolemType => tp2 match { case tp2: SkolemType if tp1 == tp2 => true @@ -287,6 +287,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi isSubType(tp1.ref, tp2) case tp1: AnnotatedType => isSubType(tp1.tpe, tp2) + case OrType(tp11, tp12) => + isSubType(tp11, tp2) && isSubType(tp12, tp2) case ErrorType => true case _ => |