-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace symbol travelsal with tree traversal when finding top level e…
…xperimentals
- Loading branch information
Showing
3 changed files
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class MetricsGroup[A] | ||
object MetricsGroup: | ||
import scala.quoted.* | ||
|
||
transparent inline final def refine[A]: MetricsGroup[A] = | ||
${ refineImpl[A] } | ||
|
||
private def refineImpl[A](using qctx: Quotes, tpe: Type[A]): Expr[MetricsGroup[A]] = | ||
import qctx.reflect.* | ||
|
||
val mt = MethodType(Nil)(_ => Nil, _ => TypeRepr.of[A]) | ||
val tpe = Refinement(TypeRepr.of[MetricsGroup[A]], "apply", mt).asType | ||
tpe match | ||
case '[tpe] => | ||
'{ MetricsGroup[A]().asInstanceOf[MetricsGroup[A] & tpe] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -experimental -Ydebug | ||
|
||
class ProbeFailedException(cause: Exception) extends Exception(cause) | ||
trait Probing: | ||
self: Metrics => | ||
val probeFailureCounter: MetricsGroup[Counter] = | ||
counters("ustats_probe_failures_count").labelled | ||
|
||
|
||
trait Counter | ||
class Metrics: | ||
class counters(name: String): | ||
transparent inline final def labelled: MetricsGroup[Counter] = MetricsGroup.refine[Counter] |