Skip to content

Commit

Permalink
use foldLeft instead of deprecated /:
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Oct 1, 2024
1 parent 4a9e1ec commit becee6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/src/main/scala/sbt/contraband/JavaCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class JavaCodeGen(
) {
"return super.hashCode(); // Avoid evaluating lazy members in hashCode to avoid circularity."
} else {
val computation = (seed /: allFields) { (acc, f) =>
val computation = allFields.foldLeft(seed) { (acc, f) =>
val h = genJavaHashCode(f, s"${f.name}()", true)
s"37 * ($acc + $h)"
}
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/scala/sbt/contraband/ScalaCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ class ScalaCodeGen(
case _ if allFields exists (_.fieldType.isLazyType) =>
s"super.hashCode // Avoid evaluating lazy members in hashCode to avoid circularity."
case "Scala" =>
(seed /: allFields) { (acc, f) => s"37 * ($acc + ${bq(f.name)}.##)" }
allFields.foldLeft(seed) { (acc, f) => s"37 * ($acc + ${bq(f.name)}.##)" }
case _ =>
(seed /: allFields) { (acc, f) => s"37 * ($acc + ${genJavaHashCode(f, bq(f.name), false)})" }
allFields.foldLeft(seed) { (acc, f) => s"37 * ($acc + ${genJavaHashCode(f, bq(f.name), false)})" }
}

s"""override def hashCode: Int = {
Expand Down

0 comments on commit becee6a

Please sign in to comment.