Skip to content

Wrong overload resolution on org.slf4j.Logger's method #8401

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

Closed
ohze opened this issue Feb 28, 2020 · 3 comments
Closed

Wrong overload resolution on org.slf4j.Logger's method #8401

ohze opened this issue Feb 28, 2020 · 3 comments

Comments

@ohze
Copy link

ohze commented Feb 28, 2020

minimized code

  • project/plugins.sbt
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.0")
  • buid.sbt
scalaVersion := "0.22.0-RC1" // compile successfully with "2.13.1"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.30"
  • src/main/scala/Main.scala
import org.slf4j.{Logger, LoggerFactory}

object Main {
  def main(args: Array[String]): Unit = {
    val logger: Logger = LoggerFactory.getLogger("main")
    logger.error("{}{}{}", 1, 2, 3) // error here
  }
}

Compilation output

[error] -- [E134] Type Mismatch Error: /dotty-example/src/main/scala/Main.scala:6:11 
[error] 6 |    logger.error("{}{}{}", 1, 2, 3) // error here
[error]   |    ^^^^^^^^^^^^
[error]   |None of the overloaded alternatives of method error in trait Logger with types
[error]   | (x$0: org.slf4j.Marker, x$1: String, x$2: Throwable): Unit
[error]   | (x$0: org.slf4j.Marker, x$1: String, x$2: Object*): Unit
[error]   | (x$0: org.slf4j.Marker, x$1: String, x$2: Any, x$3: Any): Unit
[error]   | (x$0: org.slf4j.Marker, x$1: String, x$2: Any): Unit
[error]   | (x$0: org.slf4j.Marker, x$1: String): Unit
[error]   | (x$0: String, x$1: Throwable): Unit
[error]   | (x$0: String, x$1: Object*): Unit
[error]   | (x$0: String, x$1: Any, x$2: Any): Unit
[error]   | (x$0: String, x$1: Any): Unit
[error]   | (x$0: String): Unit
[error]   |match arguments (("{}{}{}" : String), (1 : Int), (2 : Int), (3 : Int))
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

expectation

Compile successfully and choose this method in Logger.java:

public void error(String format, Object... arguments);

Note: Change scalaVersion := "2.13.1" in build.sbt => compile successfully

@ohze ohze added the itype:bug label Feb 28, 2020
@smarter
Copy link
Member

smarter commented Feb 29, 2020

[error] | (x$0: String, x$1: Object*): Unit

This should be Any*.

@smarter smarter self-assigned this Mar 1, 2020
@giabao
Copy link

giabao commented May 14, 2020

Maybe fixed in #8718
Related to #8977

@smarter
Copy link
Member

smarter commented May 22, 2020

#8718 doesn't fix it. I believe #8977 is the same issue as this one, so I'll close this one in favor of #8977 since it doesn't rely on an external library.

@smarter smarter closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants