aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-09-11 16:27:00 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-11 16:27:00 +0200
commitdc44f88bbf31db68d51177c137c9c43eb4f11398 (patch)
tree7c8b4b02dc13aaae694ec38790c2e2b9f861baab /src/dotty/tools/dotc/core/TypeOps.scala
parent76d083889d52a5abbf883e5577b1fd21c9a1d903 (diff)
downloaddotty-dc44f88bbf31db68d51177c137c9c43eb4f11398.tar.gz
dotty-dc44f88bbf31db68d51177c137c9c43eb4f11398.tar.bz2
dotty-dc44f88bbf31db68d51177c137c9c43eb4f11398.zip
Pull out isLegal prefix.
It is used twice, should use same logic each time.
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)