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 setting #1624

Merged
merged 1 commit into from
Dec 31, 2023
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
4 changes: 3 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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/.*",
Expand All @@ -15,3 +15,5 @@ fileOverride {
runner.dialect = scala3
}
}

rewrite.scala3.convertToNewSyntax = true
8 changes: 4 additions & 4 deletions proptest/src/test/scala/SchemaGenerators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package scalapb.grpc

trait AbstractService {
def serviceCompanion: ServiceCompanion[_]
def serviceCompanion: ServiceCompanion[?]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down Expand Up @@ -207,25 +207,25 @@ 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."
)
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."
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions scalapb-runtime/src/main/scala/scalapb/StructUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down