@@ -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 )
@@ -491,13 +492,19 @@ trait ImplicitRunInfo { self: Run =>
491
492
object liftToClasses extends TypeMap {
492
493
override implicit protected val ctx : Context = liftingCtx
493
494
override def stopAtStatic = true
495
+
494
496
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)
497
+ case tp : TypeRef =>
498
+ val sym = tp.symbol
499
+ if (sym.isClass || sym.isOpaqueAlias) tp
500
+ else {
501
+ val pre = tp.prefix
502
+ def joinClass (tp : Type , cls : Symbol ) =
503
+ AndType .make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
504
+ val lead = if (pre eq NoPrefix ) defn.AnyType else apply(pre)
505
+ def isLiftTarget (sym : Symbol ) = sym.isClass || sym.isOpaqueAlias
506
+ (lead /: tp.parentSymbols(isLiftTarget))(joinClass)
507
+ }
501
508
case tp : TypeVar =>
502
509
apply(tp.underlying)
503
510
case tp : AppliedType if ! tp.tycon.typeSymbol.isClass =>
@@ -516,7 +523,7 @@ trait ImplicitRunInfo { self: Run =>
516
523
517
524
// todo: compute implicits directly, without going via companionRefs?
518
525
def collectCompanions (tp : Type ): TermRefSet = track(" computeImplicitScope" ) {
519
- trace(i " collectCompanions( $tp) " , implicits ) {
526
+ trace(i " collectCompanions( $tp) " , implicitsDetailed ) {
520
527
521
528
def iscopeRefs (t : Type ): TermRefSet = implicitScopeCache.get(t) match {
522
529
case Some (is) =>
@@ -575,8 +582,10 @@ trait ImplicitRunInfo { self: Run =>
575
582
def computeIScope () = {
576
583
val liftedTp = if (isLifted) tp else liftToClasses(tp)
577
584
val refs =
578
- if (liftedTp ne tp)
585
+ if (liftedTp ne tp) {
586
+ implicitsDetailed.println(i " lifted of $tp = $liftedTp" )
579
587
iscope(liftedTp, isLifted = true ).companionRefs
588
+ }
580
589
else
581
590
collectCompanions(tp)
582
591
val result = new OfTypeImplicits (tp, refs)(ctx)
@@ -673,7 +682,7 @@ trait Implicits { self: Typer =>
673
682
}
674
683
675
684
/** Synthesize the tree for `'[T]` for an implicit `scala.quoted.Type[T]`.
676
- * `T` is deeply dealiassed to avoid references to local type aliases.
685
+ * `T` is deeply dealiased to avoid references to local type aliases.
677
686
*/
678
687
lazy val synthesizedTypeTag : SpecialHandler =
679
688
(formal, span) => implicit ctx => {
0 commit comments