Skip to content

Commit

Permalink
Fix for varargs
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin committed Mar 1, 2024
1 parent ac2ed10 commit 14db4cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/scala-3/com/typesafe/scalalogging/LoggerMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ private[scalalogging] object LoggerMacro {
// Seq():_*, List():_* e.g.,
case Apply(TypeApply(Select(Ident(_), "apply"), _), List(Typed(Repeated(elems, _),_))) =>
Some(elems.map(map))
// forceVarargs(1,2):_*
case Apply(TypeApply(_, _), List(Typed(Repeated(elems, _),_))) => Some(elems.map(map))
case _ =>
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ class Scala3LoggerSpec extends AnyWordSpec with Matchers with Varargs with Mocki
"work when passing a Seq as repeated arguments" in {
val f = fixture(_.isInfoEnabled, isEnabled = true)
import f._
logger.info("""Hello {}""", Seq(arg5ref)*)
logger.info("""Hello {}""", Seq(arg5ref):_*)
verify(underlying).info("""Hello {}""", arg5ref)
}

"work when passing a fun as repeated arguments" in {
val f = fixture(_.isInfoEnabled, isEnabled = true)
import f._
logger.info("""Hello {}""", forceVarargs(arg5ref):_*)
verify(underlying).info("""Hello {}""", arg5ref)
}
}
Expand Down

0 comments on commit 14db4cb

Please sign in to comment.