diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index 0248a42c39ef..929e805fca20 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -370,17 +370,17 @@ object Ordering extends LowPriorityOrderingImplicits { /** `Ordering`s for `Float`s. * - * The behavior of the comparison operations provided by default (implicit) - * ordering on `Float` has changed in 2.10.0 and 2.13.0. - * Prior to Scala 2.10.0, the `Ordering` instance used the semantics + * The behavior of the comparison operations provided by the default (implicit) + * ordering on `Float` changed in 2.10.0 and 2.13.0. + * Prior to Scala 2.10.0, the `Ordering` instance used semantics * consistent with `java.lang.Float.compare`. * - * Scala 2.10.0 changed the implementation of `lt`, `equiv`, `min` etc to be - * IEEE 754 compliant, while keeping `compare` method NOT compliant, - * creating an internally inconsistent instance. IEEE 754 specified that - * `0.0F == -0.0F`. In addition, all comparisons with `Float.NaN` must return + * Scala 2.10.0 changed the implementation of `lt`, `equiv`, `min`, etc., to be + * IEEE 754 compliant, while keeping the `compare` method NOT compliant, + * creating an internally inconsistent instance. IEEE 754 specifies that + * `0.0F == -0.0F`. In addition, it requires all comparisons with `Float.NaN` return * `false` thus `0.0F < Float.NaN`, `0.0F > Float.NaN`, and - * `Float.NaN == Float.NaN` all yield `false`, analogous to `None`. + * `Float.NaN == Float.NaN` all yield `false`, analogous `None` in `flatMap`. * * Recognizing the limitation of the IEEE 754 semantics in terms of ordering, * Scala 2.13.0 created two instances: `Ordering.Float.IeeeOrdering`, which retains @@ -454,26 +454,27 @@ object Ordering extends LowPriorityOrderingImplicits { implicit object IeeeOrdering extends IeeeOrdering } @migration( - " The new ordering does not affect the sorting, placing NaN at the end.\n" + - " However, methods such as `lt`, `min`, and `equiv` now match `compare`\n" + - " instead of having IEEE 754 behavior for -0.0F and NaN.\n" + - " Import Ordering.Float.IeeeOrdering to retain the previous behavior.\n" + - " See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Float$.html", "2.13.0") + " The default implicit ordering for floats now maintains consistency\n" + + " between its `compare` method and its `lt`, `min`, `equiv`, etc., methods,\n" + + " which means nonconforming to IEEE 754's behavior for -0.0F and NaN.\n" + + " The sort order of floats remains the same, however, with NaN at the end.\n" + + " Import Ordering.Float.IeeeOrdering to recover the previous behavior.\n" + + " See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Float$.html.", "2.13.0") implicit object DeprecatedFloatOrdering extends Float.TotalOrdering /** `Ordering`s for `Double`s. * - * The behavior of the comparison operations provided by default (implicit) - * ordering on `Double` has changed in 2.10.0 and 2.13.0. - * Prior to Scala 2.10.0, the `Ordering` instance used the semantics + * The behavior of the comparison operations provided by the default (implicit) + * ordering on `Double` changed in 2.10.0 and 2.13.0. + * Prior to Scala 2.10.0, the `Ordering` instance used semantics * consistent with `java.lang.Double.compare`. * - * Scala 2.10.0 changed the implementation of `lt`, `equiv`, `min` etc to be - * IEEE 754 compliant, while keeping `compare` method NOT compliant, - * creating an internally inconsistent instance. IEEE 754 specified that - * `0.0 == -0.0`. In addition, all comparisons with `Double.NaN` must return + * Scala 2.10.0 changed the implementation of `lt`, `equiv`, `min`, etc., to be + * IEEE 754 compliant, while keeping the `compare` method NOT compliant, + * creating an internally inconsistent instance. IEEE 754 specifies that + * `0.0 == -0.0`. In addition, it requires all comparisons with `Double.NaN` return * `false` thus `0.0 < Double.NaN`, `0.0 > Double.NaN`, and - * `Double.NaN == Double.NaN` all yield `false`, analogous to `None`. + * `Double.NaN == Double.NaN` all yield `false`, analogous `None` in `flatMap`. * * Recognizing the limitation of the IEEE 754 semantics in terms of ordering, * Scala 2.13.0 created two instances: `Ordering.Double.IeeeOrdering`, which retains @@ -547,10 +548,11 @@ object Ordering extends LowPriorityOrderingImplicits { implicit object IeeeOrdering extends IeeeOrdering } @migration( - " The new ordering does not affect the sorting, placing NaN at the end.\n" + - " However, methods such as `lt`, `min`, and `equiv` now match `compare`\n" + - " instead of having IEEE 754 behavior for -0.0 and NaN.\n" + - " Import Ordering.Double.IeeeOrdering to retain the previous behavior.\n" + + " The default implicit ordering for doubles now maintains consistency\n" + + " between its `compare` method and its `lt`, `min`, `equiv`, etc., methods,\n" + + " which means nonconforming to IEEE 754's behavior for -0.0 and NaN.\n" + + " The sort order of doubles remains the same, however, with NaN at the end.\n" + + " Import Ordering.Double.IeeeOrdering to recover the previous behavior.\n" + " See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Double$.html.", "2.13.0") implicit object DeprecatedDoubleOrdering extends Double.TotalOrdering diff --git a/test/files/neg/ordering-migration.check b/test/files/neg/ordering-migration.check index dcc0102a9aa4..ef74061c367c 100644 --- a/test/files/neg/ordering-migration.check +++ b/test/files/neg/ordering-migration.check @@ -1,24 +1,27 @@ ordering-migration.scala:3: warning: object DeprecatedFloatOrdering in object Ordering has changed semantics in version 2.13.0: - The new ordering does not affect the sorting, placing NaN at the end. - However, methods such as `lt`, `min`, and `equiv` now match `compare` - instead of having IEEE 754 behavior for -0.0F and NaN. - Import Ordering.Float.IeeeOrdering to retain the previous behavior. - See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Float$.html + The default implicit ordering for floats now maintains consistency + between its `compare` method and its `lt`, `min`, `equiv`, etc., methods, + which means nonconforming to IEEE 754's behavior for -0.0F and NaN. + The sort order of floats remains the same, however, with NaN at the end. + Import Ordering.Float.IeeeOrdering to recover the previous behavior. + See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Float$.html. val f = Ordering[Float] ^ ordering-migration.scala:4: warning: object DeprecatedDoubleOrdering in object Ordering has changed semantics in version 2.13.0: - The new ordering does not affect the sorting, placing NaN at the end. - However, methods such as `lt`, `min`, and `equiv` now match `compare` - instead of having IEEE 754 behavior for -0.0 and NaN. - Import Ordering.Double.IeeeOrdering to retain the previous behavior. + The default implicit ordering for doubles now maintains consistency + between its `compare` method and its `lt`, `min`, `equiv`, etc., methods, + which means nonconforming to IEEE 754's behavior for -0.0 and NaN. + The sort order of doubles remains the same, however, with NaN at the end. + Import Ordering.Double.IeeeOrdering to recover the previous behavior. See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Double$.html. val d = Ordering[Double] ^ ordering-migration.scala:7: warning: object DeprecatedDoubleOrdering in object Ordering has changed semantics in version 2.13.0: - The new ordering does not affect the sorting, placing NaN at the end. - However, methods such as `lt`, `min`, and `equiv` now match `compare` - instead of having IEEE 754 behavior for -0.0 and NaN. - Import Ordering.Double.IeeeOrdering to retain the previous behavior. + The default implicit ordering for doubles now maintains consistency + between its `compare` method and its `lt`, `min`, `equiv`, etc., methods, + which means nonconforming to IEEE 754's behavior for -0.0 and NaN. + The sort order of doubles remains the same, however, with NaN at the end. + Import Ordering.Double.IeeeOrdering to recover the previous behavior. See also https://www.scala-lang.org/api/current/scala/math/Ordering$$Double$.html. list.sorted ^