diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-13 13:12:21 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-13 13:12:21 +0200 |
commit | 1f41bd2ff0770a3188186d38405f807dac5633b5 (patch) | |
tree | 1e8313a9e1a81350352ebf402bd42c6b9b9d7820 /src/dotty/tools/dotc/core/TypeComparer.scala | |
parent | 15a63974d23511a3a879c3354552bed504061617 (diff) | |
download | dotty-1f41bd2ff0770a3188186d38405f807dac5633b5.tar.gz dotty-1f41bd2ff0770a3188186d38405f807dac5633b5.tar.bz2 dotty-1f41bd2ff0770a3188186d38405f807dac5633b5.zip |
Bug fixes in <:<
1) Tightened optimization criteria for comparing refined types in last commit
2) Handles case where ThisType and SIngleType of module class coincide.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 4d6c6a60b..1b8350841 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -165,6 +165,14 @@ class TypeComparer(initctx: Context) extends DotClass { case _ => secondTry(tp1, tp2) } + case tp2 @ ThisType(cls) => + if (cls is ModuleClass) + tp1 match { + case tp1: TermRef => + return tp1.symbol.moduleClass == cls && tp1.prefix <:< cls.owner.thisType + case _ => + } + secondTry(tp1, tp2) case tp2: PolyParam => tp2 == tp1 || { //println(constraint.show) @@ -194,6 +202,14 @@ class TypeComparer(initctx: Context) extends DotClass { } def secondTry(tp1: Type, tp2: Type): Boolean = tp1 match { + case tp1 @ ThisType(cls) => + if (cls is ModuleClass) + tp2 match { + case tp2: TermRef => + return tp2.symbol.moduleClass == cls && cls.owner.thisType <:< tp2.prefix + case _ => + } + thirdTry(tp1, tp2) case tp1: PolyParam => (tp1 == tp2) || { constraint(tp1) match { @@ -235,9 +251,10 @@ class TypeComparer(initctx: Context) extends DotClass { case tp2: NamedType => thirdTryNamed(tp1, tp2) case tp2 @ RefinedType(parent2, name2) => - tp1 match - case tp1 @ RefinedType(parent1, name1) if name1 == name2 => - isSubType(parent1, parent2) && isSubType(tp1.refinedInfo, tp2.refinedInfo) + tp1 match { + case tp1 @ RefinedType(parent1, name1) if (name1 == name2) && name1.isTypeName => + // optimized case; all info on t1.name2 is in refinement tp1.refinedInfo. + isSubType(tp1, parent2) && isSubType(tp1.refinedInfo, tp2.refinedInfo) case _ => isSubType(tp1, parent2) && ( name2 == nme.WILDCARD |