Skip to content

Upgrade 2.13 #162

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

Merged
merged 4 commits into from
May 28, 2019
Merged

Upgrade 2.13 #162

merged 4 commits into from
May 28, 2019

Conversation

adriaanm
Copy link
Contributor

Upgrade to 2.13.0-RC2 (note: there's a temporary hack to use RC1 artifacts for mockit-scala).

Also clarify (hopefully correctly) use of varargs (not really related to the 2.13 upgrade, but somehow it broke). /cc @szeiger, maybe you have an idea why? (something to do with the switch to immutable seq for varargs?)

adriaanm added 3 commits May 24, 2019 11:08
Given an overload with options like `(a: A, x: T)` and `(a: A, xs: T*)`,
you'll get the first alternative when supplying two arguments:

```
scala> object O { def o(x: Int, y: String) = "1"; def o(x: Int, y: String*) = "multi" }
defined object O

scala> O.o(1, "a")
res0: String = 1
```

This is true on 2.12 and 2.13. I don't understand what the original code was testing,
so I hope I fixed it correctly...
@szeiger
Copy link

szeiger commented May 24, 2019

I can't imagine any reason for needing this forceVarargs method. What problem did you run into? It works fine for me with the original List or Array in the tests.

@adriaanm
Copy link
Contributor Author

--- i/src/test/scala/com/typesafe/scalalogging/LoggerSpec.scala
+++ w/src/test/scala/com/typesafe/scalalogging/LoggerSpec.scala
@@ -92,7 +92,7 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar with Varargs {
       val f = fixture(_.isErrorEnabled, isEnabled = true)
       import f._
       logger.error(msg, arg1)
-      verify(underlying).error(msg, arg1)
+      verify(underlying).error(msg, forceVarargs(arg1): _*)
       logger.error(msg, arg1, arg2)
       verify(underlying).error(msg, forceVarargs(arg1, arg2): _*)
       logger.error(msg, arg1, arg2, arg3)
$  ;++2.13.0-RC2;testOnly com.typesafe.scalalogging.LoggerSpec
<snip>

[info] Calling error with a message and parameters
[info] - should call the underlying logger's error method if the error level is enabled *** FAILED ***
[info]   org.mockito.exceptions.verification.WantedButNotInvoked: Wanted but not invoked:
[info] logger.error("msg", "arg1");
[info] -> at com.typesafe.scalalogging.LoggerSpec.$anonfun$new$17(LoggerSpec.scala:95)
[info] 
[info] However, there were exactly 2 interactions with this mock:
[info] logger.isErrorEnabled();
[info] -> at com.typesafe.scalalogging.LoggerSpec.$anonfun$new$17(LoggerSpec.scala:94)
[info] 
[info] logger.error("msg", "arg1");
[info] -> at com.typesafe.scalalogging.LoggerSpec.$anonfun$new$17(LoggerSpec.scala:94)
[info]   at com.typesafe.scalalogging.LoggerSpec.$anonfun$new$17(LoggerSpec.scala:95)
[info]   at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[info]   at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
[info]   at org.scalatest.WordSpecLike$$anon$3.apply(WordSpecLike.scala:1075)
[info]   at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
[info]   at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)

@adriaanm
Copy link
Contributor Author

same failure if I use the original List(arg1): _* or scala.Seq

@adriaanm
Copy link
Contributor Author

adriaanm commented May 24, 2019

It looks like it was trying to assert that the varargs method would be chosen when you call logger.error(msg, arg1), which is not true for 2.12 nor 2.13 (see the example repl session in c093147)

@adriaanm
Copy link
Contributor Author

This is on:

$ java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

@szeiger
Copy link

szeiger commented May 24, 2019

It looks like it was trying to assert that the varargs method would be chosen when you call logger.error(msg, arg1), which is not true fro 2.12 nor 2.13

This looks correct. The single-arg method is as specific as the varargs method but not vice versa, so it has a higher weight in overload resolution.

@dwijnand
Copy link

@adriaanm
Copy link
Contributor Author

As far as I can see, this PR is good to go.

Copy link

@octonato octonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a deprecation warning coming from 2.13.

[warn] /Users/renato/GitHub/lightbend/scala-logging/PR-162/src/main/scala/com/typesafe/scalalogging/LoggerMacro.scala:298:30: method treatEscapes in object StringContext is deprecated (since 2.13.0): use processEscapes
[warn]           .map(StringContext.treatEscapes)

Maybe worth fixing it on this PR. Other than that, we would like to push this forward because it's blocking Kafka, Alpakka and Lagom.

@dwijnand
Copy link

@analytically do you have cycles to merge and cut a release with this, please?

@analytically analytically merged commit d01ffc6 into master May 28, 2019
@analytically
Copy link
Collaborator

scala-logging_2.13.0-RC2-3.9.2 has been released

@dwijnand
Copy link

Thanks so much @analytically

@dejan2609
Copy link
Contributor

Version upgrades for Scala-2.13.0-RC3: #165 (I will try to print, sign, scan and send individual CLA asap).

@analytically
Copy link
Collaborator

Published scala-logging_2.13.0-RC3-3.9.2

@SethTisue
Copy link
Collaborator

SethTisue commented Jun 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants