diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-11 09:00:50 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-14 14:30:10 +0100 |
commit | 82f59af99df93e198b31b14a854fc22af97f04a9 (patch) | |
tree | 06e47d55cf4da3bb2245522f3348fe20072a21fe /src/dotty/tools/dotc/core/TypeOps.scala | |
parent | 7cdbcdb3203dfd6a5d2bb099e06321da7d12fcd6 (diff) | |
download | dotty-82f59af99df93e198b31b14a854fc22af97f04a9.tar.gz dotty-82f59af99df93e198b31b14a854fc22af97f04a9.tar.bz2 dotty-82f59af99df93e198b31b14a854fc22af97f04a9.zip |
Fix problem handling SuperTypes in asSeenFrom
A SuperType should behave just as the underlying ThisType in asSeenFrom.
Without this patch, compiling the ...ViewLike hierarachy crashes with
a YCheck error in resolveSuper. The underlying issue is that the very
complicated tangle of supercalls does not type check because an asSeenFrom
with a SuperType prefix does not compute the right type.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index fae8df04d..3dfe698f0 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -61,18 +61,19 @@ trait TypeOps { this: Context => // TODO: Make standalone object. def toPrefix(pre: Type, cls: Symbol, thiscls: ClassSymbol): Type = /*>|>*/ ctx.conditionalTraceIndented(TypeOps.track, s"toPrefix($pre, $cls, $thiscls)") /*<|<*/ { if ((pre eq NoType) || (pre eq NoPrefix) || (cls is PackageClass)) tp - else if (thiscls.derivesFrom(cls) && pre.baseTypeRef(thiscls).exists) { - if (theMap != null && theMap.currentVariance <= 0 && !isLegalPrefix(pre)) - theMap.unstable = true - pre match { - case SuperType(thispre, _) => thispre - case _ => pre - } + else pre match { + case pre: SuperType => toPrefix(pre.thistpe, cls, thiscls) + case _ => + if (thiscls.derivesFrom(cls) && pre.baseTypeRef(thiscls).exists) { + if (theMap != null && theMap.currentVariance <= 0 && !isLegalPrefix(pre)) + theMap.unstable = true + pre + } + else if ((pre.termSymbol is Package) && !(thiscls is Package)) + toPrefix(pre.select(nme.PACKAGE), cls, thiscls) + else + toPrefix(pre.baseTypeRef(cls).normalizedPrefix, cls.owner, thiscls) } - else if ((pre.termSymbol is Package) && !(thiscls is Package)) - toPrefix(pre.select(nme.PACKAGE), cls, thiscls) - else - toPrefix(pre.baseTypeRef(cls).normalizedPrefix, cls.owner, thiscls) } /*>|>*/ ctx.conditionalTraceIndented(TypeOps.track, s"asSeen ${tp.show} from (${pre.show}, ${cls.show})", show = true) /*<|<*/ { // !!! DEBUG |