@@ -422,15 +422,15 @@ trait ImplicitRunInfo { self: Run =>
422422 override implicit protected val ctx : Context = liftingCtx
423423 override def stopAtStatic = true
424424 def apply (tp : Type ) = tp match {
425- case tp : TypeRef if tp.symbol.isAbstractOrAliasType =>
425+ case tp : TypeRef if ! tp.symbol.canHaveCompanion =>
426426 val pre = tp.prefix
427427 def joinClass (tp : Type , cls : ClassSymbol ) =
428428 AndType .make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
429429 val lead = if (tp.prefix eq NoPrefix ) defn.AnyType else apply(tp.prefix)
430430 (lead /: tp.classSymbols)(joinClass)
431431 case tp : TypeVar =>
432432 apply(tp.underlying)
433- case tp : AppliedType if ! tp.tycon.typeSymbol.isClass =>
433+ case tp : AppliedType if ! tp.tycon.typeSymbol.canHaveCompanion =>
434434 def applyArg (arg : Type ) = arg match {
435435 case TypeBounds (lo, hi) => AndType .make(lo, hi)
436436 case WildcardType (TypeBounds (lo, hi)) => AndType .make(lo, hi)
@@ -468,21 +468,24 @@ trait ImplicitRunInfo { self: Run =>
468468 case tp : NamedType =>
469469 val pre = tp.prefix
470470 comps ++= iscopeRefs(pre)
471- def addClassScope (cls : ClassSymbol ): Unit = {
472- def addRef (companion : TermRef ): Unit = {
473- val compSym = companion.symbol
474- if (compSym is Package )
475- addRef(companion.select(nme.PACKAGE ))
476- else if (compSym.exists)
477- comps += companion.asSeenFrom(pre, compSym.owner).asInstanceOf [TermRef ]
478- }
479- def addParentScope (parent : Type ): Unit =
480- iscopeRefs(tp.baseType(parent.classSymbol)) foreach addRef
481- val companion = cls.companionModule
471+ def addRef (companion : TermRef ): Unit = {
472+ val compSym = companion.symbol
473+ if (compSym is Package )
474+ addRef(companion.select(nme.PACKAGE ))
475+ else if (compSym.exists)
476+ comps += companion.asSeenFrom(pre, compSym.owner).asInstanceOf [TermRef ]
477+ }
478+ def addCompanionOf (sym : Symbol ) = {
479+ val companion = sym.companionModule
482480 if (companion.exists) addRef(companion.termRef)
483- cls.classParents foreach addParentScope
484481 }
485- tp.classSymbols(liftingCtx) foreach addClassScope
482+ def addClassScope (cls : ClassSymbol ): Unit = {
483+ addCompanionOf(cls)
484+ for (parent <- cls.classParents; ref <- iscopeRefs(tp.baseType(parent.classSymbol)))
485+ addRef(ref)
486+ }
487+ if (tp.widen.typeSymbol.isOpaqueAlias) addCompanionOf(tp.widen.typeSymbol)
488+ else tp.classSymbols(liftingCtx).foreach(addClassScope)
486489 case _ =>
487490 for (part <- tp.namedPartsWith(_.isType)) comps ++= iscopeRefs(part)
488491 }
0 commit comments