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

Update .scalafmt.conf. enforce new syntax #1070

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ fileOverride {
project.excludeFilters = [
"scalafix/*"
]
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.newSyntax.control = false
2 changes: 1 addition & 1 deletion bench/src/main/scala/org/scalacheck/bench/GenBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.scalacheck.bench

import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*

import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Gen
Expand Down
8 changes: 4 additions & 4 deletions core/js/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package org.scalacheck
import scala.annotation.nowarn
import scala.scalajs.reflect.Reflect

import Test._
import Test.*

private[scalacheck] object Platform {

Expand All @@ -35,13 +35,13 @@ private[scalacheck] object Platform {
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef = {
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[?]])(args: Seq[AnyRef]): AnyRef = {
Reflect
.lookupInstantiatableClass(name)
.getOrElse(throw new ClassNotFoundException(name))
.getConstructor(paramTypes: _*)
.getConstructor(paramTypes*)
.getOrElse(throw new NoSuchMethodError(paramTypes.mkString("<init>(", ",", ")")))
.newInstance(args: _*)
.newInstance(args*)
.asInstanceOf[AnyRef]
}

Expand Down
8 changes: 4 additions & 4 deletions core/jvm/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.scalacheck

import scala.annotation.nowarn

import Test._
import Test.*

private[scalacheck] object Platform {

Expand All @@ -22,7 +22,7 @@ private[scalacheck] object Platform {
workerFun: Int => Result,
stop: () => Unit
): Result = {
import params._
import params.*

def mergeResults(r1: Result, r2: Result): Result = {
val Result(st1, s1, d1, fm1, _) = r1
Expand All @@ -41,7 +41,7 @@ private[scalacheck] object Platform {

if (workers < 2) workerFun(0)
else {
import concurrent._
import concurrent.*
val tp = java.util.concurrent.Executors.newFixedThreadPool(workers)
implicit val ec: ExecutionContextExecutor = ExecutionContext.fromExecutor(tp)
try {
Expand All @@ -65,7 +65,7 @@ private[scalacheck] object Platform {
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[?]])(args: Seq[AnyRef]): AnyRef =
if (args.nonEmpty) ???
else Class.forName(name, true, loader).getDeclaredConstructor().newInstance().asInstanceOf[AnyRef]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ package org.scalacheck

import java.util.concurrent.TimeUnit

import Prop._
import Arbitrary._
import Prop.*
import Arbitrary.*

object ArbitrarySpecification extends Properties("Arbitrary") {
val genOptionUnits =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

package org.scalacheck

import java.time._
import java.time.*
import java.time.temporal.ChronoUnit
import java.util.Date
import scala.util.Failure
import scala.util.Success
import scala.util.Try

import Gen._
import Gen.*

object ChooseSpecification extends Properties("Choose") with time.OrderingVersionSpecific {

Expand All @@ -29,7 +29,7 @@ object ChooseSpecification extends Properties("Choose") with time.OrderingVersio
import O.mkOrderingOps
Try(choose(l, h)) match {
case Success(g) => Prop.forAll(g) { x => l <= x && x <= h }
case Failure(_: Choose.IllegalBoundsError[_]) => l > h
case Failure(_: Choose.IllegalBoundsError[?]) => l > h
case Failure(e) => throw e
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import org.scalacheck.GenSpecification.arbSeed
import org.scalacheck.Prop.forAll
import org.scalacheck.rng.Seed

import java.time._
import java.time.*
import java.util.UUID
import scala.collection.immutable.SortedMap
import scala.collection.immutable.SortedSet
import scala.concurrent.duration.Duration
import scala.concurrent.duration.FiniteDuration
import scala.util.Try
import ScalaVersionSpecific._
import ScalaVersionSpecific.*

object CogenSpecification extends Properties("Cogen") {

Expand Down
10 changes: 5 additions & 5 deletions core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import scala.util.Success
import scala.util.Try

import rng.Seed
import Gen._
import Gen.*
import Prop.{forAll, forAllNoShrink, someFailing, noneFailing, sizedProp, secure, propBoolean}
import Arbitrary._
import Shrink._
import Arbitrary.*
import Shrink.*

object GenSpecification extends Properties("Gen") with GenSpecificationVersionSpecific {

Expand Down Expand Up @@ -56,7 +56,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
}

property("frequency 3") = forAll(choose(1, 100000)) { n =>
forAll(frequency(List.fill(n)((1, const(0))): _*)) { _ == 0 }
forAll(frequency(List.fill(n)((1, const(0)))*)) { _ == 0 }
}

property("frequency 4") =
Expand Down Expand Up @@ -263,7 +263,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
val lst = x :: y :: rest
forAll(choose(-1, 2 * lst.length)) { n =>
val gs = rest.map(Gen.const)
Try(pick(n, Gen.const(x), Gen.const(y), gs: _*)) match {
Try(pick(n, Gen.const(x), Gen.const(y), gs*)) match {
case Success(g) =>
forAll(g) { m => m.length == n && m.forall(lst.contains) }
case Failure(_) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.apache.commons.lang3.SerializationUtils

import java.io.Serializable

import util.SerializableCanBuildFroms._
import util.SerializableCanBuildFroms.*

object SerializabilitySpecification extends Properties("Serializability") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object ShrinkSpecificationJVM extends Properties("Shrink JVM") {
property("xmap vector from list") = forAll { (v: Vector[Int]) =>
(!v.isEmpty && v != Vector(0)) ==> {
val vs = shrinkClosure(v)
Vector(vs: _*).toString |: (vs.contains(Vector.empty) && vs.contains(Vector(0)))
Vector(vs*).toString |: (vs.contains(Vector.empty) && vs.contains(Vector(0)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

package org.scalacheck

import Gen._
import Prop._
import Test._
import Arbitrary._
import Gen.*
import Prop.*
import Test.*
import Arbitrary.*

object TestSpecification extends Properties("Test") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package org.scalacheck.commands

import org.scalacheck._
import org.scalacheck.*

object CommandsSpecification extends Properties("Commands") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.scalacheck.Prop.AnyOperators
import org.scalacheck.Prop.forAll

import java.util.HashMap
import scala.collection.JavaConverters._
import scala.collection.JavaConverters.*
import scala.collection.immutable.IntMap

object IntMapSpec extends org.scalacheck.Properties("IntMap") {
Expand All @@ -28,7 +28,7 @@ object IntMapSpec extends org.scalacheck.Properties("IntMap") {
/** Create an IntMap and a HashMap with the same contents */
private def createMaps(l: List[Int]) = {
val mappings = for (n <- l) yield (n, new Object)
val im = IntMap(mappings: _*)
val im = IntMap(mappings*)
val hm = new HashMap[Int, Any]
for ((n, x) <- mappings) hm.put(n, x)
(hm, im)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package org.scalacheck.example

import org.scalacheck._
import org.scalacheck.*

object StringUtils extends Properties("Examples.StringUtils") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

package org.scalacheck.time

import org.scalacheck.Prop._
import org.scalacheck.Shrink._
import org.scalacheck._
import org.scalacheck.Prop.*
import org.scalacheck.Shrink.*
import org.scalacheck.*

import java.time._
import java.time.*

object ShrinkSpecification extends Properties("time.Shrink") {
property("shrink[Duration]") = forAll { (n: Duration) =>
Expand Down
8 changes: 4 additions & 4 deletions core/native/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package org.scalacheck
import scala.annotation.nowarn
import scala.scalanative.reflect.Reflect

import Test._
import Test.*

private[scalacheck] object Platform {

Expand All @@ -35,13 +35,13 @@ private[scalacheck] object Platform {
}

@nowarn("msg=is never used")
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef = {
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[?]])(args: Seq[AnyRef]): AnyRef = {
Reflect
.lookupInstantiatableClass(name)
.getOrElse(throw new ClassNotFoundException(name))
.getConstructor(paramTypes: _*)
.getConstructor(paramTypes*)
.getOrElse(throw new NoSuchMethodError(paramTypes.mkString("<init>(", ",", ")")))
.newInstance(args: _*)
.newInstance(args*)
.asInstanceOf[AnyRef]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.scalacheck.util

import java.util.{ArrayList, HashMap}

import collection.{Map => _, _}
import collection.{Map as _, *}
import generic.CanBuildFrom
import scala.collection.mutable.Builder

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.scalacheck.util

import java.util.{ArrayList, HashMap}
import scala.collection.mutable.Builder
import scala.collection.{Map => _, _}
import scala.collection.{Map as _, *}

private[util] trait BuildableVersionSpecific {

Expand Down
6 changes: 3 additions & 3 deletions core/shared/src/main/scala/org/scalacheck/Arbitrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.util.Try

import concurrent.Future
import util.Buildable
import util.SerializableCanBuildFroms._
import util.SerializableCanBuildFroms.*

/** Define an arbitrary generator for properties
*
Expand Down Expand Up @@ -236,7 +236,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {

/** Arbitrary BigDecimal */
implicit lazy val arbBigDecimal: Arbitrary[BigDecimal] = {
import java.math.MathContext, MathContext._
import java.math.MathContext, MathContext.*

val genMathContext0: Gen[MathContext] =
oneOf(DECIMAL32, DECIMAL64, DECIMAL128)
Expand Down Expand Up @@ -316,7 +316,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {

/** Generates an arbitrary property */
implicit lazy val arbProp: Arbitrary[Prop] = {
import Prop._
import Prop.*
val undecidedOrPassed = forAll { (b: Boolean) =>
b ==> true
}
Expand Down
20 changes: 10 additions & 10 deletions core/shared/src/main/scala/org/scalacheck/Gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.scalacheck

import java.math.BigInteger
import java.math.{BigDecimal => JavaDecimal}
import java.math.{BigDecimal as JavaDecimal}
import java.util.Calendar
import java.util.UUID
import scala.annotation.tailrec
Expand All @@ -21,8 +21,8 @@ import scala.concurrent.duration.FiniteDuration

import rng.Seed
import util.Buildable
import util.SerializableCanBuildFroms._
import ScalaVersionSpecific._
import util.SerializableCanBuildFroms.*
import ScalaVersionSpecific.*

/** A generator produces values for [[Prop]]s
*
Expand Down Expand Up @@ -1061,7 +1061,7 @@ object Gen extends GenArities with GenVersionSpecific {

/** A generator that picks a random number of elements from a list */
def someOf[T](g1: Gen[T], g2: Gen[T], gs: Gen[T]*) =
choose(0, gs.length + 2).flatMap(pick(_, g1, g2, gs: _*))
choose(0, gs.length + 2).flatMap(pick(_, g1, g2, gs*))

/** A generator that picks at least one element from a list */
def atLeastOne[T](l: Iterable[T]) = {
Expand All @@ -1071,7 +1071,7 @@ object Gen extends GenArities with GenVersionSpecific {

/** A generator that picks at least one element from a list */
def atLeastOne[T](g1: Gen[T], g2: Gen[T], gs: Gen[T]*) =
choose(1, gs.length + 2).flatMap(pick(_, g1, g2, gs: _*))
choose(1, gs.length + 2).flatMap(pick(_, g1, g2, gs*))

/** A generator that randomly picks a given number of elements from a list
*
Expand Down Expand Up @@ -1385,9 +1385,9 @@ object Gen extends GenArities with GenVersionSpecific {
/** Generates positive numbers of uniform distribution, with an upper bound of the generation size parameter.
*/
def posNum[T](implicit num: Numeric[T], c: Choose[T]): Gen[T] = {
import num._
import num.*
num match {
case _: Fractional[_] => sized(n => c.choose(zero, max(fromInt(n), one)).suchThat(_ != zero))
case _: Fractional[?] => sized(n => c.choose(zero, max(fromInt(n), one)).suchThat(_ != zero))
case _ => sized(n => c.choose(one, max(fromInt(n), one)))
}
}
Expand All @@ -1405,14 +1405,14 @@ object Gen extends GenArities with GenVersionSpecific {
num: Numeric[T],
c: Choose[T]
): Gen[T] = {
import num._
import num.*
val basics = List(minT, maxT, zero, one, -one)
val basicsAndSpecials = for {
t <- specials ++ basics if t >= minT && t <= maxT
} yield (1, const(t))
val other = (basicsAndSpecials.length, c.choose(minT, maxT))
val allGens = basicsAndSpecials :+ other
frequency(allGens: _*)
frequency(allGens*)
}

//// Misc Generators ////
Expand All @@ -1428,7 +1428,7 @@ object Gen extends GenArities with GenVersionSpecific {
)

lazy val calendar: Gen[Calendar] = { // FIXME: Remove lazy
import Calendar._
import Calendar.*

def adjust(c: Calendar)(f: Calendar => Unit): Calendar = { f(c); c }

Expand Down
Loading