Skip to content

Commit 98a2573

Browse files
committed
Use searchImplicit and searchImplicitExpr
1 parent 2b7b57c commit 98a2573

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
18561856

18571857
type ImplicitSearchResult = Tree
18581858

1859-
def findImplicitFor(tpe: Type)(implicit ctx: Context): ImplicitSearchResult =
1859+
def searchImplicit(tpe: Type)(implicit ctx: Context): ImplicitSearchResult =
18601860
ctx.typer.inferImplicitArg(tpe, rootPosition.span)
18611861

18621862
type ImplicitSearchSuccess = Tree

docs/docs/reference/metaprogramming/macros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,13 @@ sum
572572
### Find implicits within a macro
573573

574574
Similarly to the `implicit match` construct, it is possible to make implicit search available
575-
in a quote context. For this we simply provide `scala.quoted.matching.getImplicitExpr:
575+
in a quote context. For this we simply provide `scala.quoted.matching.searchImplicitExpr:
576576

577577
```scala
578578
inline def setFor[T]: Set[T] = ${ setForExpr[T] }
579579

580580
def setForExpr[T: Type] given QuoteContext: Expr[Set[T]] = {
581-
getImplicitExpr[Ordering[T]] match {
581+
searchImplicitExpr[Ordering[T]] match {
582582
case Some(ord) => '{ new TreeSet[T]()($ord) }
583583
case _ => '{ new HashSet[T] }
584584
}

library/src-3.x/scala/quoted/matching/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ package object matching {
1010
* @param tpe quoted type of the implicit parameter
1111
* @param qctx current context
1212
*/
13-
def getImplicitExpr[T] given (tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = {
13+
def searchImplicitExpr[T] given (tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = {
1414
import qctx.tasty._
15-
findImplicitFor(tpe.unseal.tpe) match {
15+
searchImplicit(tpe.unseal.tpe) match {
1616
case IsImplicitSearchSuccess(iss) => Some(iss.tree.seal.asInstanceOf[Expr[T]])
1717
case IsImplicitSearchFailure(isf) => None
1818
}

library/src/scala/tasty/reflect/ImplicitsOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package scala.tasty.reflect
22

33
trait ImplicitsOps extends Core {
44

5-
def findImplicitFor(tpe: Type)(implicit ctx: Context): ImplicitSearchResult =
6-
kernel.findImplicitFor(tpe)
5+
def searchImplicit(tpe: Type)(implicit ctx: Context): ImplicitSearchResult =
6+
kernel.searchImplicit(tpe)
77

88
object IsImplicitSearchSuccess {
99
def unapply(isr: ImplicitSearchResult)(implicit ctx: Context): Option[ImplicitSearchSuccess] =

library/src/scala/tasty/reflect/Kernel.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,6 @@ trait Kernel {
15371537
* @param tpe type of the implicit parameter
15381538
* @param ctx current context
15391539
*/
1540-
def findImplicitFor(tpe: Type)(implicit ctx: Context): ImplicitSearchResult
1540+
def searchImplicit(tpe: Type)(implicit ctx: Context): ImplicitSearchResult
15411541

15421542
}

tests/neg-macros/delegate-match-1/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl given (qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty._
8-
findImplicitFor(('[A]).unseal.tpe) match {
8+
searchImplicit(('[A]).unseal.tpe) match {
99
case IsImplicitSearchSuccess(x) =>
1010
'{}
1111
case IsDivergingImplicit(x) => '{}

tests/neg-macros/delegate-match-2/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl given (qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty._
8-
findImplicitFor(('[A]).unseal.tpe) match {
8+
searchImplicit(('[A]).unseal.tpe) match {
99
case IsImplicitSearchSuccess(x) =>
1010
'{}
1111
case IsDivergingImplicit(x) => '{}

tests/neg-macros/delegate-match-3/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl }
55

66
private def fImpl given (qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty._
8-
findImplicitFor(('[A]).unseal.tpe) match {
8+
searchImplicit(('[A]).unseal.tpe) match {
99
case IsImplicitSearchSuccess(x) =>
1010
'{}
1111
case IsDivergingImplicit(x) => '{}

tests/run-macros/quote-implicitMatch/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import scala.quoted.matching._
66
inline def f1[T]() = ${ f1Impl[T] }
77

88
def f1Impl[T: Type] given QuoteContext = {
9-
getImplicitExpr[Ordering[T]] match {
9+
searchImplicitExpr[Ordering[T]] match {
1010
case Some(ord) => '{ new TreeSet[T]()($ord) }
1111
case _ => '{ new HashSet[T] }
1212
}
@@ -18,7 +18,7 @@ class B
1818
inline def g = ${ gImpl }
1919

2020
def gImpl given QuoteContext = {
21-
if (getImplicitExpr[A].isDefined) '{ println("A") }
22-
else if (getImplicitExpr[B].isDefined) '{ println("B") }
21+
if (searchImplicitExpr[A].isDefined) '{ println("A") }
22+
else if (searchImplicitExpr[B].isDefined) '{ println("B") }
2323
else throw new MatchError("")
2424
}

0 commit comments

Comments
 (0)