@@ -596,7 +596,7 @@ trait Implicits {
596596 // workaround for deficient context provided by ModelFactoryImplicitSupport#makeImplicitConstraints
597597 val isScalaDoc = context.tree == EmptyTree
598598
599- val itree = atPos(pos.focus) {
599+ val itree0 = atPos(pos.focus) {
600600 if (isLocal && ! isScalaDoc) {
601601 // SI-4270 SI-5376 Always use an unattributed Ident for implicits in the local scope,
602602 // rather than an attributed Select, to detect shadowing.
@@ -608,15 +608,16 @@ trait Implicits {
608608 Select (gen.mkAttributedQualifier(info.pre), implicitMemberName)
609609 }
610610 }
611- typingLog(" considering" , typeDebug.ptTree(itree))
611+ val itree1 = if (isBlackbox(info.sym)) suppressMacroExpansion(itree0) else itree0
612+ typingLog(" considering" , typeDebug.ptTree(itree1))
612613
613- def fail (reason : String ): SearchResult = failure(itree , reason)
614- def fallback = typed1(itree , EXPRmode , wildPt)
614+ def fail (reason : String ): SearchResult = failure(itree0 , reason)
615+ def fallback = typed1(itree1 , EXPRmode , wildPt)
615616 try {
616- val itree1 = if (! isView) fallback else pt match {
617+ val itree2 = if (! isView) fallback else pt match {
617618 case Function1 (arg1, arg2) =>
618619 typed1(
619- atPos(itree .pos)(Apply (itree , List (Ident (" <argument>" ) setType approximate(arg1)))),
620+ atPos(itree0 .pos)(Apply (itree1 , List (Ident (" <argument>" ) setType approximate(arg1)))),
620621 EXPRmode ,
621622 approximate(arg2)
622623 ) match {
@@ -647,10 +648,10 @@ trait Implicits {
647648
648649 if (Statistics .canEnable) Statistics .incCounter(typedImplicits)
649650
650- val itree2 = if (isView) treeInfo.dissectApplied(itree1 ).callee
651- else adapt(itree1 , EXPRmode , wildPt)
651+ val itree3 = if (isView) treeInfo.dissectApplied(itree2 ).callee
652+ else adapt(itree2 , EXPRmode , wildPt)
652653
653- typingStack.showAdapt(itree, itree2 , pt, context)
654+ typingStack.showAdapt(itree0, itree3 , pt, context)
654655
655656 def hasMatchingSymbol (tree : Tree ): Boolean = (tree.symbol == info.sym) || {
656657 tree match {
@@ -663,21 +664,21 @@ trait Implicits {
663664
664665 if (context.hasErrors)
665666 fail(" hasMatchingSymbol reported error: " + context.firstError.get.errMsg)
666- else if (isLocal && ! hasMatchingSymbol(itree1 ))
667+ else if (isLocal && ! hasMatchingSymbol(itree2 ))
667668 fail(" candidate implicit %s is shadowed by %s" .format(
668- info.sym.fullLocationString, itree1 .symbol.fullLocationString))
669+ info.sym.fullLocationString, itree2 .symbol.fullLocationString))
669670 else {
670671 val tvars = undetParams map freshVar
671672 def ptInstantiated = pt.instantiateTypeParams(undetParams, tvars)
672673
673- if (matchesPt(itree2 .tpe, ptInstantiated, undetParams)) {
674+ if (matchesPt(itree3 .tpe, ptInstantiated, undetParams)) {
674675 if (tvars.nonEmpty)
675676 typingLog(" solve" , ptLine(" tvars" -> tvars, " tvars.constr" -> tvars.map(_.constr)))
676677
677- val targs = solvedTypes(tvars, undetParams, undetParams map varianceInType(pt), upper = false , lubDepth(itree2 .tpe :: pt :: Nil ))
678+ val targs = solvedTypes(tvars, undetParams, undetParams map varianceInType(pt), upper = false , lubDepth(itree3 .tpe :: pt :: Nil ))
678679
679680 // #2421: check that we correctly instantiated type parameters outside of the implicit tree:
680- checkBounds(itree2 , NoPrefix , NoSymbol , undetParams, targs, " inferred " )
681+ checkBounds(itree3 , NoPrefix , NoSymbol , undetParams, targs, " inferred " )
681682 context.firstError match {
682683 case Some (err) =>
683684 return fail(" type parameters weren't correctly instantiated outside of the implicit tree: " + err.errMsg)
@@ -693,7 +694,7 @@ trait Implicits {
693694 if (okParams.isEmpty) EmptyTreeTypeSubstituter
694695 else {
695696 val subst = new TreeTypeSubstituter (okParams, okArgs)
696- subst traverse itree2
697+ subst traverse itree3
697698 notifyUndetparamsInferred(okParams, okArgs)
698699 subst
699700 }
@@ -711,23 +712,23 @@ trait Implicits {
711712 // This is just called for the side effect of error detection,
712713 // see SI-6966 to see what goes wrong if we use the result of this
713714 // as the SearchResult.
714- itree2 match {
715- case TypeApply (fun, args) => typedTypeApply(itree2 , EXPRmode , fun, args)
716- case Apply (TypeApply (fun, args), _) => typedTypeApply(itree2 , EXPRmode , fun, args) // t2421c
715+ itree3 match {
716+ case TypeApply (fun, args) => typedTypeApply(itree3 , EXPRmode , fun, args)
717+ case Apply (TypeApply (fun, args), _) => typedTypeApply(itree3 , EXPRmode , fun, args) // t2421c
717718 case t => t
718719 }
719720
720721 context.firstError match {
721722 case Some (err) =>
722723 fail(" typing TypeApply reported errors for the implicit tree: " + err.errMsg)
723724 case None =>
724- val result = new SearchResult (itree2 , subst)
725+ val result = new SearchResult (unsuppressMacroExpansion(itree3) , subst)
725726 if (Statistics .canEnable) Statistics .incCounter(foundImplicits)
726727 typingLog(" success" , s " inferred value of type $ptInstantiated is $result" )
727728 result
728729 }
729730 }
730- else fail(" incompatible: %s does not match expected type %s" .format(itree2 .tpe, ptInstantiated))
731+ else fail(" incompatible: %s does not match expected type %s" .format(itree3 .tpe, ptInstantiated))
731732 }
732733 }
733734 catch {
0 commit comments