-
-
Notifications
You must be signed in to change notification settings - Fork 68
LogStage: logMethod support #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
fd6fcc2
to
e4344a9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2266 +/- ##
===========================================
+ Coverage 66.63% 66.70% +0.06%
===========================================
Files 594 595 +1
Lines 11691 11742 +51
Branches 1396 1341 -55
===========================================
+ Hits 7790 7832 +42
- Misses 3901 3910 +9 🚀 New features to boost your workflow:
|
logImplicits: Boolean, | ||
qp: c.Expr[QuasiIO[F]], | ||
): c.Expr[F[A]] = { | ||
val (variables, logString) = createVariablesAndLogStringTrees(function, logTypes, logImplicits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val (variables, logString) = createVariablesAndLogStringTrees(function, logTypes, logImplicits) | |
logMethodIOF(level, c.Expr[F[A]](q"$qp.maybeSuspend($function)"), logTypes, logImplicits, qp) |
Should work, since c.Expr[QuasiIO[F]] is <: c.Expr[QuasiPrimitives[F]]
@@ -14,6 +15,58 @@ trait AbstractMacroLogIO[F[_]] { this: AbstractLogIO[F] => | |||
transparent inline final def error(inline message: String): F[Unit] = log(Log.Level.Error, message) | |||
transparent inline final def crit(inline message: String): F[Unit] = log(Log.Level.Crit, message) | |||
|
|||
transparent inline final def logMethod[G[x] >: F[x], A]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default parameters do work in macros on Scala 3, so overloads may be removed here.
transparent inline final def logMethod[G[x] >: F[x], A]( | |
transparent inline final def logMethod[G[x] >: F[x], A]( | |
inline level: Level, | |
inline logTypes: Boolean = false, | |
inline logImplicits: Boolean = false, | |
)(inline function: => A | |
)(using qp: QuasiIO[G] | |
): G[A] = { | |
${ LogMethodMacro.logMethodIO[A, F, G]('level, 'function, 'this, 'logTypes, 'logImplicits, 'qp) } | |
} | |
transparent inline final def logMethodF[G[x] >: F[x], A]( | |
inline level: Level, | |
inline logTypes: Boolean = false, | |
inline logImplicits: Boolean = false, | |
)(inline function: => G[A] | |
)(using qp: QuasiPrimitives[G] | |
): G[A] = { | |
${ LogMethodMacro.logMethodIOF[A, F, G]('level, 'function, 'this, 'logTypes, 'logImplicits, 'qp) } | |
} |
- logMethod test - use default parameters in scala3 macro
def add(x: Int) ... def add(x: Int, y: Int) ...
Fix #2157