-
Notifications
You must be signed in to change notification settings - Fork 256
[compiler] misc scala 2.13 deprecation fixes #15137
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
base: main
Are you sure you want to change the base?
Conversation
daf99a1 to
22a2e36
Compare
22a2e36 to
d9e6787
Compare
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.
Fantastic. We can now replace BatchClient.paginated with LazyList.unfold for great good.
| /** An abstraction for building an {@code Array} of known size. Guarantees a left-to-right | ||
| * traversal | ||
| * | ||
| * @param xs | ||
| * the thing to iterate over | ||
| * @param size | ||
| * the size of array to allocate | ||
| * @param key | ||
| * given the source value and its source index, yield the target index | ||
| * @param combine | ||
| * given the target value, the target index, the source value, and the source index, compute | ||
| * the new target value | ||
| * @tparam A | ||
| * @tparam B | ||
| */ | ||
| def coalesce[A, B: ClassTag]( | ||
| xs: GenTraversableOnce[A] | ||
| )( | ||
| size: Int, | ||
| key: (A, Int) => Int, | ||
| z: B, | ||
| )( | ||
| combine: (B, A) => B | ||
| ): Array[B] = { | ||
| val a = Array.fill(size)(z) | ||
|
|
||
| for ((x, idx) <- xs.toIterator.zipWithIndex) { | ||
| val k = key(x, idx) | ||
| a(k) = combine(a(k), x) | ||
| } | ||
|
|
||
| a | ||
| } | ||
|
|
||
| def mapSameElements[K, V](l: Map[K, V], r: Map[K, V], valueEq: (V, V) => Boolean): Boolean = { | ||
| def entryMismatchMessage(failures: TraversableOnce[(K, V, V)]): String = { | ||
| require(failures.nonEmpty) | ||
| val newline = System.lineSeparator() | ||
| val sb = new StringBuilder | ||
| sb ++= "The maps do not have the same entries:" + newline | ||
| for (failure <- failures) | ||
| sb ++= s" At key ${failure._1}, the left map has ${failure._2} and the right map has ${failure._3}" + newline | ||
| sb ++= s" The left map is: $l" + newline | ||
| sb ++= s" The right map is: $r" + newline | ||
| sb.result() | ||
| } | ||
|
|
||
| if (l.keySet != r.keySet) { | ||
| println( | ||
| s"""The maps do not have the same keys. | ||
| | These keys are unique to the left-hand map: ${l.keySet -- r.keySet} | ||
| | These keys are unique to the right-hand map: ${r.keySet -- l.keySet} | ||
| | The left map is: $l | ||
| | The right map is: $r | ||
| """.stripMargin | ||
| ) | ||
| false | ||
| } else { | ||
| val fs = Array.newBuilder[(K, V, V)] | ||
| for ((k, lv) <- l) { | ||
| val rv = r(k) | ||
| if (!valueEq(lv, rv)) | ||
| fs += ((k, lv, rv)) | ||
| } | ||
| val failures = fs.result() | ||
|
|
||
| if (!failures.isEmpty) { | ||
| println(entryMismatchMessage(failures)) | ||
| false | ||
| } else { | ||
| true | ||
| } | ||
| } | ||
| } | ||
|
|
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.
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.
🎉

Change Description
The changes are summarized by the removed warning silencers in
build.mill.Security Assessment