@@ -361,13 +361,23 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
361361 * to the current scope, provided (1) variances of both aliases are the same, and
362362 * (2) X is not yet defined in current scope. This "short-circuiting" prevents
363363 * long chains of aliases which would have to be traversed in type comparers.
364+ *
365+ * Note: Test i1401.scala shows that `forwardRefs` is also necessary
366+ * for typechecking in the case where self types refer to type parameters
367+ * that are upper-bounded by subclass instances.
364368 */
365369 def forwardRefs (from : Symbol , to : Type , prefs : List [TypeRef ]) = to match {
366370 case to @ TypeBounds (lo1, hi1) if lo1 eq hi1 =>
367- for (pref <- prefs)
368- for (argSym <- pref.decls)
369- if (argSym is BaseTypeArg )
370- forwardRef(argSym, from, to, cls, decls)
371+ for (pref <- prefs) {
372+ def forward (): Unit =
373+ for (argSym <- pref.decls)
374+ if (argSym is BaseTypeArg )
375+ forwardRef(argSym, from, to, cls, decls)
376+ pref.info match {
377+ case info : TempClassInfo => info.addSuspension(forward)
378+ case _ => forward()
379+ }
380+ }
371381 case _ =>
372382 }
373383
@@ -419,9 +429,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
419429 s " redefinition of ${decls.lookup(name).debugString} in ${cls.showLocated}" )
420430 enterArgBinding(formals(name), refinedInfo, cls, decls)
421431 }
422- // Forward definitions in super classes that have one of the refined paramters
432+ // Forward definitions in super classes that have one of the refined parameters
423433 // as aliases directly to the refined info.
424- // Note that this cannot be fused bwith the previous loop because we now
434+ // Note that this cannot be fused with the previous loop because we now
425435 // assume that all arguments have been entered in `decls`.
426436 refinements foreachBinding { (name, refinedInfo) =>
427437 forwardRefs(formals(name), refinedInfo, parentRefs)
0 commit comments