Skip to content

Commit 14db4cb

Browse files
committed
Fix for varargs
1 parent ac2ed10 commit 14db4cb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/scala-3/com/typesafe/scalalogging/LoggerMacro.scala

+2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ private[scalalogging] object LoggerMacro {
279279
// Seq():_*, List():_* e.g.,
280280
case Apply(TypeApply(Select(Ident(_), "apply"), _), List(Typed(Repeated(elems, _),_))) =>
281281
Some(elems.map(map))
282+
// forceVarargs(1,2):_*
283+
case Apply(TypeApply(_, _), List(Typed(Repeated(elems, _),_))) => Some(elems.map(map))
282284
case _ =>
283285
None
284286
}

src/test/scala-3/com/typesafe/scalalogging/Scala3LoggerSpec.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ class Scala3LoggerSpec extends AnyWordSpec with Matchers with Varargs with Mocki
2424
"work when passing a Seq as repeated arguments" in {
2525
val f = fixture(_.isInfoEnabled, isEnabled = true)
2626
import f._
27-
logger.info("""Hello {}""", Seq(arg5ref)*)
27+
logger.info("""Hello {}""", Seq(arg5ref):_*)
28+
verify(underlying).info("""Hello {}""", arg5ref)
29+
}
30+
31+
"work when passing a fun as repeated arguments" in {
32+
val f = fixture(_.isInfoEnabled, isEnabled = true)
33+
import f._
34+
logger.info("""Hello {}""", forceVarargs(arg5ref):_*)
2835
verify(underlying).info("""Hello {}""", arg5ref)
2936
}
3037
}

0 commit comments

Comments
 (0)