@@ -241,16 +241,20 @@ trait Checking {
241241 def checkLegalPrefix (tp : Type , selector : Name , pos : Position )(implicit ctx : Context ): Unit =
242242 if (! tp.isLegalPrefixFor(selector)) ctx.error(d " $tp is not a valid prefix for '# $selector' " , pos)
243243
244- /** Check that `tp` is a class type with a stable prefix. Also, if `traitReq` is
245- * true check that `tp` is a trait.
244+ /** Check that `tp` is a class type with a stable prefix. Also:
245+ * If `traitReq` is true, check that `tp` refers to a trait.
246+ * If `concreteReq` is true, check that `tp` refers to a nonAbstract class.
246247 * Stability checking is disabled in phases after RefChecks.
247248 * @return `tp` itself if it is a class or trait ref, ObjectClass.typeRef if not.
248249 */
249- def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type =
250+ def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean = false , concreteReq : Boolean = false )(implicit ctx : Context ): Type =
250251 tp.underlyingClassRef(refinementOK = false ) match {
251252 case tref : TypeRef =>
252253 if (ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos)
253- if (traitReq && ! (tref.symbol is Trait )) ctx.error(d " $tref is not a trait " , pos)
254+ if (traitReq && ! (tref.symbol is Trait ))
255+ ctx.error(d " $tref is not a trait " , pos)
256+ if (concreteReq && false && (tref.symbol is AbstractOrTrait ))
257+ ctx.error(d " ${tref.symbol} is abstract; cannot be instantiated, owner = ${ctx.owner}" , pos)
254258 tp
255259 case _ =>
256260 ctx.error(d " $tp is not a class type " , pos)
@@ -329,7 +333,7 @@ trait NoChecking extends Checking {
329333 override def checkBounds (args : List [tpd.Tree ], poly : PolyType )(implicit ctx : Context ): Unit = ()
330334 override def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit = ()
331335 override def checkLegalPrefix (tp : Type , selector : Name , pos : Position )(implicit ctx : Context ): Unit = ()
332- override def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type = tp
336+ override def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean , concreteReq : Boolean )(implicit ctx : Context ): Type = tp
333337 override def checkImplicitParamsNotSingletons (vparamss : List [List [ValDef ]])(implicit ctx : Context ): Unit = ()
334338 override def checkFeasible (tp : Type , pos : Position , where : => String = " " )(implicit ctx : Context ): Type = tp
335339 override def checkNoDoubleDefs (cls : Symbol )(implicit ctx : Context ): Unit = ()
0 commit comments