diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-07 09:09:18 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-12 10:49:51 +0200 |
commit | f0578aa4bd3c87bd00658f4138eef3e4624f035e (patch) | |
tree | 1edd2d8a6976d248962875021b8a5a04f27dc734 /src/dotty/tools/dotc/core/TypeComparer.scala | |
parent | afd9a66453848412ae0a974ddd475da2b0d846bf (diff) | |
download | dotty-f0578aa4bd3c87bd00658f4138eef3e4624f035e.tar.gz dotty-f0578aa4bd3c87bd00658f4138eef3e4624f035e.tar.bz2 dotty-f0578aa4bd3c87bd00658f4138eef3e4624f035e.zip |
Two fixes to TypeComparer
1) Eliminated a case in the comparison that did not work and was apparently not needed anyway.
2) Augmented another case to also work when paths go through getters.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 6d0f81c72..f36572755 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -587,11 +587,22 @@ class TypeComparer(initctx: Context) extends DotClass { else thirdTry(tp1, tp2) } tp1.info match { + // There was the following code, which was meant to implement this logic: + // If x has type A | B, then x.type <: C if + // x.type <: C assuming x has type A, and + // x.type <: C assuming x has type B. + // But it did not work, because derivedRef would always give back the same + // type and cache the denotation. So it ended up copmparing just one branch. + // The code seems to be unncessary for the tests and does not seems to help performance. + // So it is commented out. If we ever need to come back to this, we would have + // to create unchached TermRefs in order to avoid cross talk between the branches. + /* case OrType(tp11, tp12) => val sd = tp1.denot.asSingleDenotation def derivedRef(tp: Type) = NamedType(tp1.prefix, tp1.name, sd.derivedSingleDenotation(sd.symbol, tp)) secondTry(OrType.make(derivedRef(tp11), derivedRef(tp12)), tp2) + */ case TypeBounds(lo1, hi1) => if ((ctx.mode is Mode.GADTflexible) && (tp1.symbol is GADTFlexType) && !isSubTypeWhenFrozen(hi1, tp2)) @@ -762,6 +773,8 @@ class TypeComparer(initctx: Context) extends DotClass { tp2.info match { case tp2i: TermRef => isSubType(tp1, tp2i) + case ExprType(tp2i: TermRef) if (ctx.phase.id > ctx.gettersSettersPhase.id) => + isSubType(tp1, tp2i) case _ => false } |