aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-06-05 20:23:19 +0200
committerMartin Odersky <odersky@gmail.com>2015-06-06 11:05:27 +0200
commitd5ba5fb89f41432c710e253d084497658be077f8 (patch)
tree896a8326b0820e28c5f3c3053bdfb7006813cfb1 /src/dotty/tools/dotc/core/TypeOps.scala
parent9c63c8b56f65d78c4da2b006ac74a260ae748b26 (diff)
downloaddotty-d5ba5fb89f41432c710e253d084497658be077f8.tar.gz
dotty-d5ba5fb89f41432c710e253d084497658be077f8.tar.bz2
dotty-d5ba5fb89f41432c710e253d084497658be077f8.zip
Track unstability in asSeenFrom
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index a01f8af9f..c4673d569 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -12,19 +12,25 @@ import ast.tpd._
trait TypeOps { this: Context => // TODO: Make standalone object.
- final def asSeenFrom(tp: Type, pre: Type, cls: Symbol): Type =
+ final def asSeenFrom(tp: Type, pre: Type, cls: Symbol): Type = {
+ val m = if (pre.isStable || ctx.isAfterTyper) null else new AsSeenFromMap(pre, cls)
asSeenFrom(tp, pre, cls, null)
-
+ }
+
final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = {
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)
+ else if (thiscls.derivesFrom(cls) && pre.baseTypeRef(thiscls).exists) {
+ if (!pre.isStable && theMap != null && theMap.currentVariance <= 0) {
+ theMap.unstable = true
+ }
pre match {
case SuperType(thispre, _) => thispre
case _ => pre
}
+ }
else if ((pre.termSymbol is Package) && !(thiscls is Package))
toPrefix(pre.select(nme.PACKAGE), cls, thiscls)
else
@@ -36,7 +42,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
case tp: NamedType =>
val sym = tp.symbol
if (sym.isStatic) tp
- else tp.derivedSelect(asSeenFrom(tp.prefix, pre, cls, theMap))
+ else {
+ val pre1 = asSeenFrom(tp.prefix, pre, cls, theMap)
+ if (theMap != null && theMap.unstable) {
+ pre1.member(tp.name).info match {
+ case TypeAlias(alias) => return alias
+ case _ =>
+ }
+ }
+ tp.derivedSelect(pre1)
+ }
case tp: ThisType =>
toPrefix(pre, cls, tp.cls)
case _: BoundType | NoPrefix =>
@@ -57,6 +72,8 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
class AsSeenFromMap(pre: Type, cls: Symbol) extends TypeMap {
def apply(tp: Type) = asSeenFrom(tp, pre, cls, this)
+ def currentVariance = variance
+ var unstable = false
}
/** Implementation of Types#simplified */