Skip to content

Commit b6545cc

Browse files
committed
Use -xsource:3
1 parent 437342a commit b6545cc

File tree

21 files changed

+79
-78
lines changed

21 files changed

+79
-78
lines changed

Diff for: analyzer/src/main/scala/com/avsystem/commons/analyzer/AnalyzerPlugin.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final class AnalyzerPlugin(val global: Global) extends Plugin { plugin =>
7575

7676
import global._
7777

78-
def newPhase(prev: Phase) = new StdPhase(prev) {
78+
def newPhase(prev: Phase): StdPhase = new StdPhase(prev) {
7979
def apply(unit: CompilationUnit): Unit =
8080
rules.foreach(rule => if (rule.level != Level.Off) rule.analyze(unit.asInstanceOf[rule.global.CompilationUnit]))
8181
}

Diff for: benchmark/jvm/src/main/scala/com/avsystem/commons/mongo/BsonCodecBenchmark.scala

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.avsystem.commons
22
package mongo
33

4-
import java.nio.ByteBuffer
4+
import com.avsystem.commons.ser.{Nested, Toplevel}
55

6-
import com.avsystem.commons.rpc.akka.serialization.{Nested, Something}
6+
import java.nio.ByteBuffer
77
import org.bson.codecs.{BsonDocumentCodec, DecoderContext, EncoderContext}
88
import org.bson.io.BasicOutputBuffer
99
import org.bson.{BsonArray, BsonBinaryReader, BsonBinaryWriter, BsonDocument, BsonInt32, BsonString}
@@ -18,11 +18,11 @@ class BsonCodecBenchmark {
1818

1919
import BsonCodecBenchmark._
2020

21-
private val something = Something(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol")
21+
private val something = Toplevel(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol")
2222
private val doc = somethingCodec.toDocument(something)
2323
private val bytes = binaryEncode(something)
2424

25-
def binaryEncode(something: Something): Array[Byte] = {
25+
def binaryEncode(something: Toplevel): Array[Byte] = {
2626
val output = new BasicOutputBuffer()
2727
val writer = new BsonBinaryWriter(output)
2828
val doc = somethingCodec.toDocument(something)
@@ -36,7 +36,7 @@ class BsonCodecBenchmark {
3636
}
3737

3838
@Benchmark
39-
def binaryDecoding(): Something = {
39+
def binaryDecoding(): Toplevel = {
4040
val reader = new BsonBinaryReader(ByteBuffer.wrap(bytes))
4141
val doc = bsonDocumentCodec.decode(reader, DecoderContext.builder().build())
4242
somethingCodec.fromDocument(new Doc(doc))
@@ -48,7 +48,7 @@ class BsonCodecBenchmark {
4848
}
4949

5050
@Benchmark
51-
def decoding(): Something = {
51+
def decoding(): Toplevel = {
5252
somethingCodec.fromDocument(doc)
5353
}
5454
}
@@ -76,13 +76,13 @@ object BsonCodecBenchmark {
7676

7777
val nestedKey: DocKey[Nested, BsonDocument] = nestedCodec.bsonCodec.key("nested")
7878

79-
val somethingCodec = new DocumentCodec[Something] {
80-
override def toDocument(t: Something): Doc = Doc()
79+
val somethingCodec = new DocumentCodec[Toplevel] {
80+
override def toDocument(t: Toplevel): Doc = Doc()
8181
.put(intKey, t.int)
8282
.put(nestedKey, t.nested)
8383
.put(strKey, t.str)
8484

85-
override def fromDocument(doc: Doc): Something = Something(
85+
override def fromDocument(doc: Doc): Toplevel = Toplevel(
8686
int = doc.require(intKey),
8787
nested = doc.require(nestedKey),
8888
str = doc.require(strKey)

Diff for: benchmark/jvm/src/main/scala/com/avsystem/commons/mongo/BsonInputOutputBenchmark.scala

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.avsystem.commons
22
package mongo
33

4+
import com.avsystem.commons.ser.{Nested, Toplevel}
5+
46
import java.io.StringWriter
57
import java.nio.ByteBuffer
6-
7-
import com.avsystem.commons.rpc.akka.serialization.{Nested, Something}
88
import org.bson.io.BasicOutputBuffer
99
import org.bson.json.{JsonReader, JsonWriter}
1010
import org.bson.{BsonBinaryReader, BsonBinaryWriter, BsonDocument, BsonDocumentReader, BsonDocumentWriter, BsonReader, BsonValue, BsonWriter}
@@ -16,29 +16,29 @@ import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Measurement,
1616
@BenchmarkMode(Array(Mode.Throughput))
1717
@State(Scope.Thread)
1818
class BsonInputOutputBenchmark {
19-
private val something = Something(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol")
19+
private val something = Toplevel(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol")
2020
private val bytes = binaryEncode(something)
2121
private val doc = documentEncode(something)
2222
private val json = jsonEncode(something)
2323

24-
def write(something: Something, bsonWriter: BsonWriter): Unit = {
24+
def write(something: Toplevel, bsonWriter: BsonWriter): Unit = {
2525
val output = new BsonWriterOutput(bsonWriter)
26-
Something.codec.write(output, something)
26+
Toplevel.codec.write(output, something)
2727
}
2828

29-
def binaryEncode(something: Something): Array[Byte] = {
29+
def binaryEncode(something: Toplevel): Array[Byte] = {
3030
val bsonOutput = new BasicOutputBuffer()
3131
write(something, new BsonBinaryWriter(bsonOutput))
3232
bsonOutput.toByteArray
3333
}
3434

35-
def documentEncode(something: Something): BsonDocument = {
35+
def documentEncode(something: Toplevel): BsonDocument = {
3636
val doc = new BsonDocument()
3737
write(something, new BsonDocumentWriter(doc))
3838
doc
3939
}
4040

41-
def jsonEncode(something: Something): String = {
41+
def jsonEncode(something: Toplevel): String = {
4242
val stringWriter = new StringWriter()
4343
write(something, new JsonWriter(stringWriter))
4444
stringWriter.toString
@@ -64,23 +64,23 @@ class BsonInputOutputBenchmark {
6464
BsonValueOutput.write(something)
6565
}
6666

67-
def read(bsonReader: BsonReader): Something = {
67+
def read(bsonReader: BsonReader): Toplevel = {
6868
val input = new BsonReaderInput(bsonReader)
69-
Something.codec.read(input)
69+
Toplevel.codec.read(input)
7070
}
7171

7272
@Benchmark
73-
def binaryDecoding(): Something = {
73+
def binaryDecoding(): Toplevel = {
7474
read(new BsonBinaryReader(ByteBuffer.wrap(bytes)))
7575
}
7676

7777
@Benchmark
78-
def documentDecoding(): Something = {
78+
def documentDecoding(): Toplevel = {
7979
read(new BsonDocumentReader(doc))
8080
}
8181

8282
@Benchmark
83-
def jsonDecoding(): Something = {
83+
def jsonDecoding(): Toplevel = {
8484
read(new JsonReader(json))
8585
}
8686
}

Diff for: core/src/main/scala/com/avsystem/commons/serialization/SimpleValueInputOutput.scala

+27-27
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ class SimpleValueOutput(
5151
def this(consumer: Any => Unit) =
5252
this(consumer, new MHashMap[String, Any], new ListBuffer[Any])
5353

54-
def writeNull(): Unit = consumer(null)
55-
def writeBoolean(boolean: Boolean): Unit = consumer(boolean)
56-
def writeString(str: String): Unit = consumer(str)
57-
def writeInt(int: Int): Unit = consumer(int)
58-
def writeLong(long: Long): Unit = consumer(long)
59-
def writeDouble(double: Double): Unit = consumer(double)
60-
def writeBigInt(bigInt: BigInt): Unit = consumer(bigInt)
61-
def writeBigDecimal(bigDecimal: BigDecimal): Unit = consumer(bigDecimal)
62-
def writeBinary(binary: Array[Byte]): Unit = consumer(binary)
54+
override def writeNull(): Unit = consumer(null)
55+
override def writeBoolean(boolean: Boolean): Unit = consumer(boolean)
56+
override def writeString(str: String): Unit = consumer(str)
57+
override def writeInt(int: Int): Unit = consumer(int)
58+
override def writeLong(long: Long): Unit = consumer(long)
59+
override def writeDouble(double: Double): Unit = consumer(double)
60+
override def writeBigInt(bigInt: BigInt): Unit = consumer(bigInt)
61+
override def writeBigDecimal(bigDecimal: BigDecimal): Unit = consumer(bigDecimal)
62+
override def writeBinary(binary: Array[Byte]): Unit = consumer(binary)
6363

6464
def writeList(): ListOutput = new ListOutput {
6565
private val buffer = newListRepr
6666
override def declareSize(size: Int): Unit = buffer.sizeHint(size)
67-
def writeElement() = new SimpleValueOutput(buffer += _, newObjectRepr, newListRepr)
68-
def finish(): Unit = consumer(buffer.result())
67+
override def writeElement(): SimpleValueOutput = new SimpleValueOutput(buffer += _, newObjectRepr, newListRepr)
68+
override def finish(): Unit = consumer(buffer.result())
6969
}
7070

7171
def writeObject(): ObjectOutput = new ObjectOutput {
7272
private val result = newObjectRepr
7373
override def declareSize(size: Int): Unit = result.sizeHint(size)
74-
def writeField(key: String) = new SimpleValueOutput(v => result += ((key, v)), newObjectRepr, newListRepr)
75-
def finish(): Unit = consumer(result)
74+
override def writeField(key: String): SimpleValueOutput = new SimpleValueOutput(v => result += ((key, v)), newObjectRepr, newListRepr)
75+
override def finish(): Unit = consumer(result)
7676
}
7777
}
7878

@@ -95,15 +95,15 @@ class SimpleValueInput(value: Any) extends InputAndSimpleInput {
9595
case _ => throw new ReadFailure(s"Expected ${classTag[B].runtimeClass} but got ${value.getClass}")
9696
}
9797

98-
def readNull(): Boolean = value == null
99-
def readBoolean(): Boolean = doReadUnboxed[Boolean, JBoolean]
100-
def readString(): String = doRead[String]
101-
def readInt(): Int = doReadUnboxed[Int, JInteger]
102-
def readLong(): Long = doReadUnboxed[Long, JLong]
103-
def readDouble(): Double = doReadUnboxed[Double, JDouble]
104-
def readBigInt(): BigInt = doRead[JBigInteger]
105-
def readBigDecimal(): BigDecimal = doRead[JBigDecimal]
106-
def readBinary(): Array[Byte] = doRead[Array[Byte]]
98+
override def readNull(): Boolean = value == null
99+
override def readBoolean(): Boolean = doReadUnboxed[Boolean, JBoolean]
100+
override def readString(): String = doRead[String]
101+
override def readInt(): Int = doReadUnboxed[Int, JInteger]
102+
override def readLong(): Long = doReadUnboxed[Long, JLong]
103+
override def readDouble(): Double = doReadUnboxed[Double, JDouble]
104+
override def readBigInt(): BigInt = doRead[JBigInteger]
105+
override def readBigDecimal(): BigDecimal = doRead[JBigDecimal]
106+
override def readBinary(): Array[Byte] = doRead[Array[Byte]]
107107

108108
def readObject(): ObjectInput =
109109
new ObjectInput {
@@ -112,22 +112,22 @@ class SimpleValueInput(value: Any) extends InputAndSimpleInput {
112112
case (k, v) => new SimpleValueFieldInput(k, v)
113113
}
114114
override def knownSize: Int = if(map.isEmpty) 0 else map.knownSize
115-
def nextField(): SimpleValueFieldInput = it.next()
115+
override def nextField(): SimpleValueFieldInput = it.next()
116116
override def peekField(name: String): Opt[SimpleValueFieldInput] =
117117
map.get(name).map(new SimpleValueFieldInput(name, _)).toOpt // values may be null!
118-
def hasNext: Boolean = it.hasNext
118+
override def hasNext: Boolean = it.hasNext
119119
}
120120

121121
def readList(): ListInput =
122122
new ListInput {
123123
private val inputSeq: BSeq[Any] = doRead[BSeq[Any]]
124124
private val it = inputSeq.iterator.map(new SimpleValueInput(_))
125125
override def knownSize: Int = if(inputSeq.isEmpty) 0 else inputSeq.knownSize
126-
def nextElement(): SimpleValueInput = it.next()
127-
def hasNext: Boolean = it.hasNext
126+
override def nextElement(): SimpleValueInput = it.next()
127+
override def hasNext: Boolean = it.hasNext
128128
}
129129

130-
def skip(): Unit = ()
130+
override def skip(): Unit = ()
131131
}
132132

133133
class SimpleValueFieldInput(val fieldName: String, value: Any)

Diff for: core/src/test/scala/com/avsystem/commons/concurrent/ObservableExtensionsTest.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
1616
private implicit val scheduler: Scheduler = Scheduler(RunNowEC)
1717

1818
test("headOptL") {
19-
forAll { ints: List[Int] =>
19+
forAll { (ints: List[Int]) =>
2020
Observable.fromIterable(ints).headOptL.runToFuture.futureValue shouldBe ints.headOpt
2121
}
2222
}
@@ -26,7 +26,7 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
2626
}
2727

2828
test("findOptL") {
29-
forAll { ints: List[Int] =>
29+
forAll { (ints: List[Int]) =>
3030
Observable.fromIterable(ints).findOptL(_ > 1).runToFuture.futureValue shouldBe ints.findOpt(_ > 1)
3131
}
3232
}
@@ -38,13 +38,13 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
3838
}
3939

4040
test("distinct") {
41-
forAll { ints: List[Int] =>
41+
forAll { (ints: List[Int]) =>
4242
Observable.fromIterable(ints).distinct.toListL.runToFuture.futureValue shouldBe ints.distinct
4343
}
4444
}
4545

4646
test("distinctBy") {
47-
forAll { ints: List[Int] =>
47+
forAll { (ints: List[Int]) =>
4848
val f: Int => Int = _ % 256
4949

5050
Observable.fromIterable(ints).distinctBy(f).toListL.runToFuture.futureValue shouldBe
@@ -53,20 +53,20 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
5353
}
5454

5555
test("sortedL") {
56-
forAll { ints: List[Int] =>
56+
forAll { (ints: List[Int]) =>
5757
Observable.fromIterable(ints).sortedL.runToFuture.futureValue shouldBe ints.sorted
5858
}
5959
}
6060

6161
test("sortedByL") {
62-
forAll { ints: List[Int] =>
62+
forAll { (ints: List[Int]) =>
6363
val f: Int => Int = _ % 256
6464
Observable.fromIterable(ints).sortedByL(f).runToFuture.futureValue shouldBe ints.sortBy(f)
6565
}
6666
}
6767

6868
test("toL") {
69-
forAll { ints: List[(Int, Int)] =>
69+
forAll { (ints: List[(Int, Int)]) =>
7070
def testFactory[T](factory: Factory[(Int, Int), T])(implicit position: Position) =
7171
Observable.fromIterable(ints).toL(factory).runToFuture.futureValue shouldBe factory.fromSpecific(ints)
7272

@@ -100,7 +100,7 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
100100
}
101101

102102
test("mkMapL") {
103-
forAll { ints: List[Int] =>
103+
forAll { (ints: List[Int]) =>
104104
Observable.fromIterable(ints).mkMapL(_ % 3, _ + 2).runToFuture.futureValue shouldBe ints.mkMap(_ % 3, _ + 2)
105105
}
106106
}

Diff for: core/src/test/scala/com/avsystem/commons/concurrent/TaskExtensionsTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TaskExtensionsTest extends AnyFunSuite with Matchers with ScalaCheckDriven
2424
}
2525

2626
test("traverseMap") {
27-
forAll { data: List[(String, Int)] =>
27+
forAll { (data: List[(String, Int)]) =>
2828
val map = data.toMap
2929
val expected = map.view.map({ case (key, value) => (key + key, value + 2) }).toMap
3030
val result = Task.traverseMap(map)({ case (key, value) => Task((key + key, value + 2)) }).runToFuture.futureValue
@@ -33,7 +33,7 @@ class TaskExtensionsTest extends AnyFunSuite with Matchers with ScalaCheckDriven
3333
}
3434

3535
test("traverseMapValues") {
36-
forAll { data: List[(String, Int)] =>
36+
forAll { (data: List[(String, Int)]) =>
3737
val map = data.toMap
3838
val expected = map.view.mapValues(value => value + 2).toMap
3939
val result = Task.traverseMapValues(map)({ case (key, value) => Task(value + 2) }).runToFuture.futureValue

Diff for: core/src/test/scala/com/avsystem/commons/serialization/IsoInstantTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IsoInstantTest extends AnyFunSuite with ScalaCheckPropertyChecks {
2626

2727
test("roundtrip") {
2828
val genTstamp = Gen.choose[Long](-(1L << 50), 1L << 50)
29-
forAll(genTstamp) { l: Long =>
29+
forAll(genTstamp) { (l: Long) =>
3030
assert(IsoInstant.parse(IsoInstant.format(l)) == l)
3131
}
3232
}

Diff for: core/src/test/scala/com/avsystem/commons/serialization/json/JsonStringInputOutputTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class JsonStringInputOutputTest extends AnyFunSuite with SerializationTestUtils
205205
}
206206

207207
test("serialize all types") {
208-
forAll { item: CompleteItem =>
208+
forAll { (item: CompleteItem) =>
209209
val serialized = write(item)
210210
val deserialized = read[CompleteItem](serialized)
211211

@@ -363,7 +363,7 @@ class JsonStringInputOutputTest extends AnyFunSuite with SerializationTestUtils
363363
Gen.sized(sz => sized(math.min(sz, 1)))
364364
}
365365

366-
forAll { dncc: DeepNestedTestCC =>
366+
forAll { (dncc: DeepNestedTestCC) =>
367367
val serialized = write(dncc)
368368
val deserialized = read[DeepNestedTestCC](serialized)
369369

Diff for: jetty/src/test/scala/com/avsystem/commons/jetty/rpc/JettyRPCFrameworkTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class JettyRPCFrameworkTest extends AnyFunSuite with ScalaFutures with Matchers
5353
val impl: SomeApi = new SomeApi {
5454
override def keks: Future[Long] = Future.successful(keksResult)
5555
override def isTop(keks: Long): Future[Boolean] = Future.successful(keks == Int.MaxValue)
56-
override val topper = new TopperImpl("%s", topKeksResult)
56+
override val topper: TopperImpl = new TopperImpl("%s", topKeksResult)
5757
override def differentTopper(helloPattern: String): Topper = new TopperImpl(helloPattern, topKeksResult)
5858
override def erroneousKeks: Future[Int] = Future.failed(new RuntimeException("cannot into"))
5959
}

Diff for: mongo/jvm/src/test/scala-2.13/com/avsystem/commons/mongo/typed/PolyDataWithCustomImplicits.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ case class CustomWrappy(value: String)
88

99
object CustomImplicits {
1010
implicit val customWrappyCodec: GenCodec[CustomWrappy] =
11-
GenCodec.transformed[CustomWrappy, String](_.value, CustomWrappy)
11+
GenCodec.transformed[CustomWrappy, String](_.value, CustomWrappy.apply)
1212
}
1313

1414
abstract class CustomPolyDataCompanion[D[_]](

Diff for: mongo/jvm/src/test/scala/com/avsystem/commons/mongo/BigDecimalEncodingTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
66

77
class BigDecimalEncodingTest extends AnyFunSuite with ScalaCheckPropertyChecks {
88
test("BigDecimal BSON encoding") {
9-
forAll { value: BigDecimal =>
9+
forAll { (value: BigDecimal) =>
1010
assert(value == BsonInput.bigDecimalFromBytes(BsonOutput.bigDecimalBytes(value)))
1111
}
1212
}

Diff for: mongo/jvm/src/test/scala/com/avsystem/commons/mongo/Decimal128UtilsTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
88

99
class Decimal128UtilsTest extends AnyFunSuite with ScalaCheckPropertyChecks {
1010
test("Decimal128Utils.fromBigDecimal is equivalent to new Decimal128") {
11-
forAll(Arbitrary.arbitrary[BigDecimal]) { bd: BigDecimal =>
11+
forAll(Arbitrary.arbitrary[BigDecimal]) { (bd: BigDecimal) =>
1212
val usingUtils = Decimal128Utils.fromBigDecimal(bd)
1313
val usingConstructor = try new Decimal128(bd.bigDecimal).opt catch {
1414
case _: NumberFormatException => Opt.Empty

Diff for: project/Commons.scala

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ object Commons extends ProjectGroup("commons") {
134134
"-language:experimental.macros",
135135
"-language:higherKinds",
136136
"-Xfatal-warnings",
137+
"-Xsource:3",
137138
"-Xlint:-missing-interpolator,-adapted-args,-unused,_",
138139
"-Ycache-plugin-class-loader:last-modified",
139140
"-Ycache-macro-class-loader:last-modified",

0 commit comments

Comments
 (0)