@@ -421,15 +421,15 @@ trait ImplicitRunInfo { self: Run =>
421
421
override implicit protected val ctx : Context = liftingCtx
422
422
override def stopAtStatic = true
423
423
def apply (tp : Type ) = tp match {
424
- case tp : TypeRef if tp.symbol.isAbstractOrAliasType =>
424
+ case tp : TypeRef if ! tp.symbol.canHaveCompanion =>
425
425
val pre = tp.prefix
426
426
def joinClass (tp : Type , cls : ClassSymbol ) =
427
427
AndType .make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
428
428
val lead = if (tp.prefix eq NoPrefix ) defn.AnyType else apply(tp.prefix)
429
429
(lead /: tp.classSymbols)(joinClass)
430
430
case tp : TypeVar =>
431
431
apply(tp.underlying)
432
- case tp : AppliedType if ! tp.tycon.typeSymbol.isClass =>
432
+ case tp : AppliedType if ! tp.tycon.typeSymbol.canHaveCompanion =>
433
433
def applyArg (arg : Type ) = arg match {
434
434
case TypeBounds (lo, hi) => AndType .make(lo, hi)
435
435
case WildcardType (TypeBounds (lo, hi)) => AndType .make(lo, hi)
@@ -467,21 +467,24 @@ trait ImplicitRunInfo { self: Run =>
467
467
case tp : NamedType =>
468
468
val pre = tp.prefix
469
469
comps ++= iscopeRefs(pre)
470
- def addClassScope (cls : ClassSymbol ): Unit = {
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 addParentScope (parent : Type ): Unit =
479
- iscopeRefs(tp.baseType(parent.classSymbol)) foreach addRef
480
- val companion = cls.companionModule
470
+ def addRef (companion : TermRef ): Unit = {
471
+ val compSym = companion.symbol
472
+ if (compSym is Package )
473
+ addRef(companion.select(nme.PACKAGE ))
474
+ else if (compSym.exists)
475
+ comps += companion.asSeenFrom(pre, compSym.owner).asInstanceOf [TermRef ]
476
+ }
477
+ def addCompanionOf (sym : Symbol ) = {
478
+ val companion = sym.companionModule
481
479
if (companion.exists) addRef(companion.termRef)
482
- cls.classParents foreach addParentScope
483
480
}
484
- tp.classSymbols(liftingCtx) foreach addClassScope
481
+ def addClassScope (cls : ClassSymbol ): Unit = {
482
+ addCompanionOf(cls)
483
+ for (parent <- cls.classParents; ref <- iscopeRefs(tp.baseType(parent.classSymbol)))
484
+ addRef(ref)
485
+ }
486
+ if (tp.widen.typeSymbol.isOpaqueAlias) addCompanionOf(tp.widen.typeSymbol)
487
+ else tp.classSymbols(liftingCtx).foreach(addClassScope)
485
488
case _ =>
486
489
for (part <- tp.namedPartsWith(_.isType)) comps ++= iscopeRefs(part)
487
490
}
0 commit comments