Skip to content

Logging Macro Doesn't Support Scala2 + Scala3 Simultaneously #317

Open
@Zeimyth

Description

@Zeimyth

I am working in a Scala project that is in the middle of migrating from Scala 2 to Scala 3. We are trying to perform this migration in piecemeal, but the scala-logging library is currently making it difficult to do so.

In theory, there should be a way to implement Scala macros such that both Scala 2 and Scala 3 dependencies can depend on the library and call the macro code (see https://github.com/scalacenter/mix-macros-scala-2-and-3, an example repo put together to demonstrate how to do this). However, when attempting this with the scala-logging library (see Zeimyth/mix-macros-scala-2-and-3#1), the Scala 2 build gets these errors at compile time:

Main.scala:12:14: Unsupported Scala 3 inline macro method info; found in trait com.typesafe.scalalogging.LoggerImpl.
[error]   logger.info("Hello, World!")
[error]              ^
[error] one error found
[error] (app2 / Compile / compileIncremental) Compilation failed

I am not fluent enough in Scala macros (and certainly not in cross-version Scala macro support) to know exactly why the example repo's macro is supported in both Scala versions but the scala-logging one is not. I think it has to do with the way the example repo is defining a single source file that exposes both macros together: https://github.com/scalacenter/mix-macros-scala-2-and-3/blob/develop/testframework/src/main/scala/testframework/package.scala. Perhaps scala-logging needs something like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions