Skip to content
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

From v3.6.0 logging message cannot be compiled properly #191

Open
Opalo opened this issue Oct 18, 2019 · 0 comments · May be fixed by #433
Open

From v3.6.0 logging message cannot be compiled properly #191

Opalo opened this issue Oct 18, 2019 · 0 comments · May be fixed by #433
Assignees
Labels

Comments

@Opalo
Copy link

Opalo commented Oct 18, 2019

Hi,

With the following piece of code:

logger.info(s"Message with id=${msg.getId}, submittedAt=${msg.getSubmittedAt} will be dropped.")

I'm getting the compiler error:

[ERROR] <CUT>/src/main/scala/<CUT>/SubscriberWithScheduling.scala:36: error: no `: _*' annotation allowed here
[INFO] (such annotations are only allowed in arguments to *-parameters)
[INFO]           logger.info(s"Message with id=${msg.getId}, submittedAt=${msg.getSubmittedAt} will be dropped.")
[INFO]    

It works with v. 3.5.0.
What's the problem?

jxnu-liguobin pushed a commit that referenced this issue Feb 29, 2024
After wrapping varargs, the user code fails to compile.

In Scala 2, there were no inline parameters, and the subtype of args was obtained during compilation. However, this approach may not always be accurate.

Regarding #191

There is an issue with obtaining inline parameters in Scala 3.

To address this, we recursively obtain the actual value of inline parameters. This necessitates the ongoing use of inlining in the parameters of the wrapper function. For instance:

```scala
class LogWrapper(val underlying: Logger) {
    inline def info(message: String, inline args: AnyRef*): Unit = underlying.info(message, args: _*)
}
```
This ensures compatibility and accurate handling of inline parameters in both Scala 2 and Scala 3.
jxnu-liguobin added a commit that referenced this issue Feb 29, 2024
After wrapping varargs, the user code fails to compile.

In Scala 2, there were no inline parameters, and the subtype of args was obtained during compilation. However, this approach may not always be accurate.

Regarding #191

There is an issue with obtaining inline parameters in Scala 3.

To address this, we recursively obtain the actual value of inline parameters. This necessitates the ongoing use of inlining in the parameters of the wrapper function. For instance:

```scala
class LogWrapper(val underlying: Logger) {
    inline def info(message: String, inline args: AnyRef*): Unit = underlying.info(message, args: _*)
}
```
This ensures compatibility and accurate handling of inline parameters in both Scala 2 and Scala 3.
@jxnu-liguobin jxnu-liguobin linked a pull request Feb 29, 2024 that will close this issue
@jxnu-liguobin jxnu-liguobin linked a pull request Feb 29, 2024 that will close this issue
@jxnu-liguobin jxnu-liguobin self-assigned this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants