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

import CollectionConverters or JavaConverters based on scala version #10154

Merged
merged 1 commit into from Apr 15, 2020

Conversation

fusuiyi123
Copy link
Contributor

Pull Request Checklist

Helpful things

Fixes

Fixes #9845

Purpose

What does this PR do?
if scala version >= 2.13.0 import scala.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?

@@ -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._"
Copy link
Member

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.

Copy link
Contributor Author

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!

Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool! gotcha.

Copy link
Member

@ignasi35 ignasi35 left a comment

Choose a reason for hiding this comment

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

LGTM

@ignasi35
Copy link
Member

Great work. Thanks @fusuiyi123

@mergify mergify bot merged commit bfb66a7 into playframework:master Apr 15, 2020
@mkurz
Copy link
Member

mkurz commented Apr 15, 2020

@Mergifyio backport 2.8.x

@mergify
Copy link
Contributor

mergify bot commented Apr 15, 2020

Command backport 2.8.x: success

Backports have been created

mergify bot added a commit that referenced this pull request Apr 15, 2020
import CollectionConverters or JavaConverters based on scala version (bp #10154)
@fusuiyi123 fusuiyi123 deleted the java-import branch April 17, 2020 04:14
@ignasi35 ignasi35 added this to the Play 2.8.2 milestone May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Play-twirl support imports deprecated API (scala 2.13)
4 participants