aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index b61d39749..2a9dbd09c 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -43,7 +43,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
* for more complicated types.
*/
final def asSeenFrom(tp: Type, pre: Type, cls: Symbol): Type = {
- val m = if (pre.isStable || !ctx.phase.isTyper) null else new AsSeenFromMap(pre, cls)
+ val m = if (isLegalPrefix(pre)) null else new AsSeenFromMap(pre, cls)
var res = asSeenFrom(tp, pre, cls, m)
if (m != null && m.unstable) asSeenFrom(tp, SkolemType(pre), cls) else res
}
@@ -61,7 +61,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
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 && !pre.isStable)
+ if (theMap != null && theMap.currentVariance <= 0 && !isLegalPrefix(pre))
theMap.unstable = true
pre match {
case SuperType(thispre, _) => thispre
@@ -111,6 +111,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
}
}
+ private def isLegalPrefix(pre: Type)(implicit ctx: Context) =
+ pre.isStable || !ctx.phase.isTyper
+
/** The TypeMap handling the asSeenFrom in more complicated cases */
class AsSeenFromMap(pre: Type, cls: Symbol) extends TypeMap {
def apply(tp: Type) = asSeenFrom(tp, pre, cls, this)