@@ -394,16 +394,17 @@ trait Checking {
394
394
ctx.error(i " $tp cannot be instantiated since it ${rstatus.msg}" , pos)
395
395
}
396
396
397
- /** Check that `tp` is a class type with a stable prefix. Also, if `traitReq` is
398
- * true check that `tp` is a trait.
399
- * Stability checking is disabled in phases after RefChecks.
397
+ /** Check that `tp` is a class type.
398
+ * Also, if `traitReq` is true, check that `tp` is a trait.
399
+ * Also, if `stablePrefixReq` is true and phase is not after RefChecks,
400
+ * check that class prefix is stable.
400
401
* @return `tp` itself if it is a class or trait ref, ObjectType if not.
401
402
*/
402
- def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type =
403
+ def checkClassType (tp : Type , pos : Position , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type =
403
404
tp.underlyingClassRef(refinementOK = false ) match {
404
405
case tref : TypeRef =>
405
- if (ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos)
406
406
if (traitReq && ! (tref.symbol is Trait )) ctx.error(d " $tref is not a trait " , pos)
407
+ if (stablePrefixReq && ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos)
407
408
tp
408
409
case _ =>
409
410
ctx.error(d " $tp is not a class type " , pos)
@@ -506,7 +507,7 @@ trait NoChecking extends Checking {
506
507
override def checkNonCyclic (sym : Symbol , info : TypeBounds , reportErrors : Boolean )(implicit ctx : Context ): Type = info
507
508
override def checkValue (tree : Tree , proto : Type )(implicit ctx : Context ): tree.type = tree
508
509
override def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit = ()
509
- override def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type = tp
510
+ override def checkClassType (tp : Type , pos : Position , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type = tp
510
511
override def checkImplicitParamsNotSingletons (vparamss : List [List [ValDef ]])(implicit ctx : Context ): Unit = ()
511
512
override def checkFeasible (tp : Type , pos : Position , where : => String = " " )(implicit ctx : Context ): Type = tp
512
513
override def checkNoDoubleDefs (cls : Symbol )(implicit ctx : Context ): Unit = ()
0 commit comments