diff --git a/.scalafmt.conf b/.scalafmt.conf index 509943959..016fe924a 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -2,7 +2,7 @@ version = 3.7.14 style = defaultWithAlign maxColumn = 100 assumeStandardLibraryStripMargin = true -runner.dialect = scala213source3 +runner.dialect = scala213 project.excludeFilters = [ "scalapb-runtime/src/main/js-native/com/google/protobuf/.*", @@ -15,3 +15,5 @@ fileOverride { runner.dialect = scala3 } } + +rewrite.scala3.convertToNewSyntax = true diff --git a/proptest/src/test/scala/SchemaGenerators.scala b/proptest/src/test/scala/SchemaGenerators.scala index db7e508f4..5d3881ee4 100644 --- a/proptest/src/test/scala/SchemaGenerators.scala +++ b/proptest/src/test/scala/SchemaGenerators.scala @@ -235,11 +235,11 @@ object SchemaGenerators { jarForClass[scalapb.grpc.Grpc.type].getPath, jarForClass[com.google.protobuf.Message].getPath, jarForClass[io.grpc.Channel].getPath, - jarForClass[io.grpc.stub.AbstractStub[_]].getPath, + jarForClass[io.grpc.stub.AbstractStub[?]].getPath, jarForClass[io.grpc.protobuf.ProtoFileDescriptorSupplier].getPath, - jarForClass[com.google.common.util.concurrent.ListenableFuture[_]].getPath(), + jarForClass[com.google.common.util.concurrent.ListenableFuture[?]].getPath(), jarForClass[javax.annotation.Nullable].getPath(), - jarForClass[scalapb.lenses.Lens[_, _]].getPath(), + jarForClass[scalapb.lenses.Lens[?, ?]].getPath(), rootDir.toString() ) val scalaFiles = getFileTree(rootDir) @@ -256,7 +256,7 @@ object SchemaGenerators { } type CompanionWithJavaSupport[A <: GeneratedMessage] = - GeneratedMessageCompanion[A] with JavaProtoSupport[A, _] + GeneratedMessageCompanion[A] with JavaProtoSupport[A, ?] case class CompiledSchema(rootNode: RootNode, rootDir: File) { lazy val classLoader = diff --git a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/AbstractService.scala b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/AbstractService.scala index 0fe3c4e19..27f7f203d 100644 --- a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/AbstractService.scala +++ b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/AbstractService.scala @@ -1,5 +1,5 @@ package scalapb.grpc trait AbstractService { - def serviceCompanion: ServiceCompanion[_] + def serviceCompanion: ServiceCompanion[?] } diff --git a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/Marshaller.scala b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/Marshaller.scala index 4e6d1547d..c0f05423c 100644 --- a/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/Marshaller.scala +++ b/scalapb-runtime-grpc/src/main/scala/scalapb/grpc/Marshaller.scala @@ -9,7 +9,7 @@ class Marshaller[T <: GeneratedMessage](companion: GeneratedMessageCompanion[T]) override def stream(t: T): InputStream = new ProtoInputStream[T](t) override def parse(inputStream: InputStream): T = inputStream match { - case pis: ProtoInputStream[_] => pis.message.asInstanceOf[T] + case pis: ProtoInputStream[?] => pis.message.asInstanceOf[T] case _ => companion.parseFrom(inputStream) } } diff --git a/scalapb-runtime-grpc/src/test/scala/scalapb/grpc/GrpcSpec.scala b/scalapb-runtime-grpc/src/test/scala/scalapb/grpc/GrpcSpec.scala index 6e5110bfa..5ad59b144 100644 --- a/scalapb-runtime-grpc/src/test/scala/scalapb/grpc/GrpcSpec.scala +++ b/scalapb-runtime-grpc/src/test/scala/scalapb/grpc/GrpcSpec.scala @@ -10,7 +10,7 @@ import munit.FunSuite class GrpcSpec extends FunSuite { test("Complete observer should wrap an exception as a StatusException on failure") { - val observer = mock(classOf[StreamObserver[_]]) + val observer = mock(classOf[StreamObserver[?]]) Grpc.completeObserver(observer)(Failure(new RuntimeException("Error!"))) diff --git a/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala b/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala index f2710737c..d1b471cb8 100644 --- a/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala +++ b/scalapb-runtime/src/main/scala/scalapb/GeneratedMessageCompanion.scala @@ -109,7 +109,7 @@ trait GeneratedMessage extends Any with Product with Serializable { (f, getField(f)) }.toMap) - def companion: GeneratedMessageCompanion[_] + def companion: GeneratedMessageCompanion[?] /** Serializes the message and returns a byte array containing its raw bytes */ final def toByteArray: Array[Byte] = { @@ -207,15 +207,15 @@ trait GeneratedMessageCompanion[A <: GeneratedMessage] extends Serializable { // Companion object of all nested messages. That is, all messages that are defined directly inside this // message. - def nestedMessagesCompanions: Seq[GeneratedMessageCompanion[_ <: GeneratedMessage]] + def nestedMessagesCompanions: Seq[GeneratedMessageCompanion[? <: GeneratedMessage]] def messageReads: _root_.scalapb.descriptors.Reads[A] - def messageCompanionForFieldNumber(field: Int): GeneratedMessageCompanion[_] + def messageCompanionForFieldNumber(field: Int): GeneratedMessageCompanion[?] def messageCompanionForField( field: JavaDescriptors.FieldDescriptor - ): GeneratedMessageCompanion[_] = { + ): GeneratedMessageCompanion[?] = { require( field.getContainingType() == javaDescriptor, "FieldDescriptor does not match message type." @@ -223,9 +223,9 @@ trait GeneratedMessageCompanion[A <: GeneratedMessage] extends Serializable { messageCompanionForFieldNumber(field.getNumber()) } - def enumCompanionForFieldNumber(field: Int): GeneratedEnumCompanion[_] + def enumCompanionForFieldNumber(field: Int): GeneratedEnumCompanion[?] - def enumCompanionForField(field: JavaDescriptors.FieldDescriptor): GeneratedEnumCompanion[_] = { + def enumCompanionForField(field: JavaDescriptors.FieldDescriptor): GeneratedEnumCompanion[?] = { require( field.getContainingType() == javaDescriptor, "FieldDescriptor does not match message type." @@ -257,7 +257,7 @@ abstract class GeneratedFileObject { def dependencies: Seq[GeneratedFileObject] // Companion object of all top-level messages - def messagesCompanions: Seq[GeneratedMessageCompanion[_ <: GeneratedMessage]] + def messagesCompanions: Seq[GeneratedMessageCompanion[? <: GeneratedMessage]] } trait GeneratedSealedOneof extends Any with Product with Serializable { diff --git a/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala b/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala index 3b16f001b..97f33fa97 100644 --- a/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala +++ b/scalapb-runtime/src/main/scala/scalapb/StructUtils.scala @@ -23,7 +23,7 @@ object StructUtils { private def structMapToFDMap( structFields: Map[String, Value] - )(implicit companion: GeneratedMessageCompanion[_]): Either[StructParsingError, PMessage] = { + )(implicit companion: GeneratedMessageCompanion[?]): Either[StructParsingError, PMessage] = { val fieldDescriptorToPValue = companion.scalaDescriptor.fields.map { fd => structFields .get(fd.name) @@ -35,7 +35,7 @@ object StructUtils { } private def fromValue(fd: FieldDescriptor)(value: Value)(implicit - companion: GeneratedMessageCompanion[_] + companion: GeneratedMessageCompanion[?] ): Either[StructParsingError, PValue] = (value.kind, fd.scalaType) match { case (Kind.NumberValue(v), ScalaType.Int) if v.isValidInt => Right(PInt(v.toInt)) diff --git a/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala b/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala index e0c9ee91f..64eefd395 100644 --- a/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala +++ b/scalapb-runtime/src/main/scala/scalapb/textformat/AstUtils.scala @@ -65,7 +65,7 @@ private[scalapb] object AstUtils { checkBigInt(p, isSigned = false, isLong = true).map(t => PLong(t.longValue)) private def parseUnsafe( - v: GeneratedMessageCompanion[_], + v: GeneratedMessageCompanion[?], ast: TMessage ): Either[AstError, PMessage] = { def parseDouble(p: TPrimitive): Either[AstError, PDouble] = p match {