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
import CollectionConverters or JavaConverters based on scala version #10154
Conversation
@@ -29,18 +29,23 @@ import com.typesafe.sbt.web.SbtWeb.autoImport._ | |||
import com.typesafe.sbt.web.SbtWeb.autoImport.WebKeys._ | |||
|
|||
object PlaySettings { | |||
|
|||
lazy val converterImport = | |||
if (PlayVersion.scalaVersion >= "2.13.0") "scala.jdk.CollectionConverters._" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlayVersion.scalaVersion
is a String
, so comparing that to 2.13.0
with >=
probably doesn't do what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean scala string comparison? I checked the doc https://www.scala-lang.org/api/2.12.1/scala/collection/immutable/StringOps.html#>=(that:A):Boolean here, or is it the logic issue? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: "2.12.2" >= "2.12.1"
is true, but also "2.12.2" >= "2.12.10"
, so using string comparison to compare versions is dangerous (even if it might happen to work in some situations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool! gotcha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Great work. Thanks @fusuiyi123 |
@Mergifyio backport 2.8.x |
Command
|
import CollectionConverters or JavaConverters based on scala version (bp #10154)
Pull Request Checklist
Helpful things
Fixes
Fixes #9845
Purpose
What does this PR do?
if scala version >=
2.13.0
importscala.jdk.CollectionConverters._
else import
scala.collection.JavaConverters._
Background Context
Why did you take this approach?
References
Are there any relevant issues / PRs / mailing lists discussions?