Skip to content

Commit a6e2c8b

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

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,12 @@ private[scalalogging] object LoggerMacro {
276276
case Block(Nil, e) => rec(e)
277277
case Typed(e, _) => rec(e)
278278
case Inlined(_, Nil, e) => rec(e)
279-
// Seq():_*, List():_* e.g.,
280-
case Apply(TypeApply(Select(Ident(_), "apply"), _), List(Typed(Repeated(elems, _),_))) =>
279+
// Seq():_*, List():_* , forceVarargs(1,2):_*e.g.,
280+
case Apply(TypeApply(_, _), 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))
282+
case Ident(name) =>
283+
// todo
284+
None
284285
case _ =>
285286
None
286287
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ class Scala3LoggerSpec extends AnyWordSpec with Matchers with Varargs with Mocki
3434
logger.info("""Hello {}""", forceVarargs(arg5ref):_*)
3535
verify(underlying).info("""Hello {}""", arg5ref)
3636
}
37+
38+
"work when passing a inline value as repeated arguments" in {
39+
val f = fixture(_.isInfoEnabled, isEnabled = true)
40+
import f._
41+
inline def argss = Seq(arg5ref, arg5ref, arg5ref)
42+
logger.info("""Hello {} {} {}""", argss:_*)
43+
verify(underlying).info("""Hello {} {} {}""", Seq(arg5ref, arg5ref, arg5ref):_*)
44+
}
3745
}
3846

3947
private def fixture(p: Underlying => Boolean, isEnabled: Boolean) = new LoggerF(p, isEnabled)

0 commit comments

Comments
 (0)