Skip to content

Commit dc44f88

Browse files
committed
Pull out isLegal prefix.
It is used twice, should use same logic each time.
1 parent 76d0838 commit dc44f88

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
4343
* for more complicated types.
4444
*/
4545
final def asSeenFrom(tp: Type, pre: Type, cls: Symbol): Type = {
46-
val m = if (pre.isStable || !ctx.phase.isTyper) null else new AsSeenFromMap(pre, cls)
46+
val m = if (isLegalPrefix(pre)) null else new AsSeenFromMap(pre, cls)
4747
var res = asSeenFrom(tp, pre, cls, m)
4848
if (m != null && m.unstable) asSeenFrom(tp, SkolemType(pre), cls) else res
4949
}
@@ -61,7 +61,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
6161
if ((pre eq NoType) || (pre eq NoPrefix) || (cls is PackageClass))
6262
tp
6363
else if (thiscls.derivesFrom(cls) && pre.baseTypeRef(thiscls).exists) {
64-
if (theMap != null && theMap.currentVariance <= 0 && !pre.isStable)
64+
if (theMap != null && theMap.currentVariance <= 0 && !isLegalPrefix(pre))
6565
theMap.unstable = true
6666
pre match {
6767
case SuperType(thispre, _) => thispre
@@ -111,6 +111,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
111111
}
112112
}
113113

114+
private def isLegalPrefix(pre: Type)(implicit ctx: Context) =
115+
pre.isStable || !ctx.phase.isTyper
116+
114117
/** The TypeMap handling the asSeenFrom in more complicated cases */
115118
class AsSeenFromMap(pre: Type, cls: Symbol) extends TypeMap {
116119
def apply(tp: Type) = asSeenFrom(tp, pre, cls, this)

0 commit comments

Comments
 (0)