diff options
author | Martin Odersky <odersky@gmail.com> | 2015-07-23 17:13:35 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-01 19:33:25 +0200 |
commit | 78239daf86cf6d45fec46f259e55e1fdbd963046 (patch) | |
tree | e8ee2a45d06a7918a427d87b8484f2162362bae4 /src/dotty/tools/dotc/core/TypeComparer.scala | |
parent | 3ae9347bca8edbd46aa296570bb2b718a4849665 (diff) | |
download | dotty-78239daf86cf6d45fec46f259e55e1fdbd963046.tar.gz dotty-78239daf86cf6d45fec46f259e55e1fdbd963046.tar.bz2 dotty-78239daf86cf6d45fec46f259e55e1fdbd963046.zip |
Generalize rules for isSubType between NamedTypes.
Can assume P#T <: Q#T if P <: Q. This follows from
the rules how we expand # to existentials.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index e3e5f3960..d98ff1f03 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -154,24 +154,10 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp1: NamedType => val sym1 = tp1.symbol (if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) - ctx.erasedTypes || sym1.isStaticOwner || - { // Implements: A # X <: B # X - // if either A =:= B (i.e. A <: B and B <: A), or the following three conditions hold: - // 1. X is a class type, - // 2. B is a class type without abstract type members. - // 3. A <: B. - // Dealiasing is taken care of elsewhere. - val pre1 = tp1.prefix - val pre2 = tp2.prefix - isSameType(pre1, pre2) || - sym1.isClass && - pre2.classSymbol.exists && - pre2.abstractTypeMembers.isEmpty && - isSubType(pre1, pre2) - } + ctx.erasedTypes || sym1.isStaticOwner || isSubType(tp1.prefix, tp2.prefix) else (tp1.name eq tp2.name) && - isSameType(tp1.prefix, tp2.prefix) && + isSubType(tp1.prefix, tp2.prefix) && (tp1.signature == tp2.signature) && !tp1.isInstanceOf[WithFixedSym] && !tp2.isInstanceOf[WithFixedSym] |