@@ -232,6 +232,7 @@ object Implicits {
232
232
*/
233
233
class OfTypeImplicits (tp : Type , val companionRefs : TermRefSet )(initctx : Context ) extends ImplicitRefs (initctx) {
234
234
assert(initctx.typer != null )
235
+ implicits.println(i " implicits of type $tp = ${companionRefs.toList}%, % " )
235
236
@ threadUnsafe lazy val refs : List [ImplicitRef ] = {
236
237
val buf = new mutable.ListBuffer [TermRef ]
237
238
for (companion <- companionRefs) buf ++= companion.implicitMembers(ImplicitOrImpliedOrGiven )
@@ -492,12 +493,21 @@ trait ImplicitRunInfo { self: Run =>
492
493
override implicit protected val ctx : Context = liftingCtx
493
494
override def stopAtStatic = true
494
495
def apply (tp : Type ) = tp match {
495
- case tp : TypeRef if ! tp.symbol.isClass =>
496
- val pre = tp.prefix
497
- def joinClass (tp : Type , cls : ClassSymbol ) =
498
- AndType .make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
499
- val lead = if (pre eq NoPrefix ) defn.AnyType else apply(pre)
500
- (lead /: tp.classSymbols)(joinClass)
496
+ case tp : NamedType =>
497
+ tp.info match {
498
+ case TypeAlias (alias) =>
499
+ apply(alias)
500
+ case TypeBounds (_, hi) =>
501
+ if (tp.symbol.isOpaqueAlias) tp
502
+ else {
503
+ val pre = tp.prefix
504
+ def joinClass (tp : Type , cls : ClassSymbol ) =
505
+ AndType .make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
506
+ val lead = if (pre eq NoPrefix ) defn.AnyType else apply(pre)
507
+ (lead /: hi.classSymbols)(joinClass)
508
+ }
509
+ case _ => tp
510
+ }
501
511
case tp : TypeVar =>
502
512
apply(tp.underlying)
503
513
case tp : AppliedType if ! tp.tycon.typeSymbol.isClass =>
@@ -516,7 +526,7 @@ trait ImplicitRunInfo { self: Run =>
516
526
517
527
// todo: compute implicits directly, without going via companionRefs?
518
528
def collectCompanions (tp : Type ): TermRefSet = track(" computeImplicitScope" ) {
519
- trace(i " collectCompanions( $tp) " , implicits ) {
529
+ trace(i " collectCompanions( $tp) " , implicitsDetailed ) {
520
530
521
531
def iscopeRefs (t : Type ): TermRefSet = implicitScopeCache.get(t) match {
522
532
case Some (is) =>
@@ -575,8 +585,10 @@ trait ImplicitRunInfo { self: Run =>
575
585
def computeIScope () = {
576
586
val liftedTp = if (isLifted) tp else liftToClasses(tp)
577
587
val refs =
578
- if (liftedTp ne tp)
588
+ if (liftedTp ne tp) {
589
+ implicitsDetailed.println(i " lifted of $tp = $liftedTp" )
579
590
iscope(liftedTp, isLifted = true ).companionRefs
591
+ }
580
592
else
581
593
collectCompanions(tp)
582
594
val result = new OfTypeImplicits (tp, refs)(ctx)
@@ -673,7 +685,7 @@ trait Implicits { self: Typer =>
673
685
}
674
686
675
687
/** Synthesize the tree for `'[T]` for an implicit `scala.quoted.Type[T]`.
676
- * `T` is deeply dealiassed to avoid references to local type aliases.
688
+ * `T` is deeply dealiased to avoid references to local type aliases.
677
689
*/
678
690
lazy val synthesizedTypeTag : SpecialHandler =
679
691
(formal, span) => implicit ctx => {
0 commit comments