Skip to content

Commit

Permalink
Merge pull request #482 from AVSystem/scala2-13
Browse files Browse the repository at this point in the history
Drop Scala 2.12 support
  • Loading branch information
ddworak authored Aug 31, 2023
2 parents 59ea63b + 8cd076b commit bf51ea8
Show file tree
Hide file tree
Showing 51 changed files with 46 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.11, 2.12.18]
scala: [2.13.11]
java: [temurin@11, temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AVSystem Commons Library for Scala

[![Build Status](https://travis-ci.org/AVSystem/scala-commons.svg?branch=master)](https://travis-ci.org/AVSystem/scala-commons)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.avsystem.commons/commons-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.avsystem.commons/commons-core_2.12)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.avsystem.commons/commons-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.avsystem.commons/commons-core_2.13)

**[API reference](http://avsystem.github.io/scala-commons/api/com/avsystem/commons/index.html)**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body>
<div id="body">Loading...</div>
<script type="text/javascript" src="target/scala-2.12/commons-benchmark-jsdeps.min.js"></script>
<script type="text/javascript" src="target/scala-2.12/commons-benchmark-opt.js"></script>
<script type="text/javascript" src="target/scala-2.13/commons-benchmark-jsdeps.min.js"></script>
<script type="text/javascript" src="target/scala-2.13/commons-benchmark-opt.js"></script>
</body>
</html>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.avsystem.commons
package jiop

import java.util.DoubleSummaryStatistics

import scala.collection.compat._
import scala.collection.Factory

final class ScalaJDoubleStream(private val jStream: JDoubleStream) extends AnyVal {
def asJava: JDoubleStream = jStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.avsystem.commons
package jiop

import java.util.IntSummaryStatistics

import scala.collection.compat._
import scala.collection.Factory

final class ScalaJIntStream(private val jStream: JIntStream) extends AnyVal {
def asJava: JIntStream = jStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.avsystem.commons
package jiop

import java.util.LongSummaryStatistics

import scala.collection.compat._
import scala.collection.Factory

final class ScalaJLongStream(private val jStream: JLongStream) extends AnyVal {
def asJava: JLongStream = jStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.avsystem.commons
package jiop

import scala.annotation.unchecked.{uncheckedVariance => uV}
import scala.collection.compat._
import scala.collection.Factory

final class ScalaJStream[+A](private val jStream: JStream[A@uV]) extends AnyVal {
def asJava[B >: A]: JStream[B] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.avsystem.commons
package jiop

import java.util.stream.{Collectors, DoubleStream, IntStream, LongStream}

import com.avsystem.commons.jiop.GuavaInterop._
import com.google.common.util.concurrent.{MoreExecutors, SettableFuture}
import org.scalatest.funsuite.AnyFunSuite

import scala.collection.compat._
import java.util.stream.{Collectors, DoubleStream, IntStream, LongStream}
import scala.concurrent.Await
import scala.concurrent.duration.Duration

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 2 additions & 20 deletions core/src/main/scala/com/avsystem/commons/SharedExtensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.avsystem.commons

import com.avsystem.commons.concurrent.RunNowEC
import com.avsystem.commons.misc._
import scala.annotation.nowarn

import scala.annotation.tailrec
import scala.collection.compat._
import scala.collection.{AbstractIterator, mutable}
import scala.annotation.{nowarn, tailrec}
import scala.collection.{AbstractIterator, BuildFrom, Factory, mutable}

trait SharedExtensions {

Expand Down Expand Up @@ -536,19 +534,6 @@ object SharedExtensionsUtils extends SharedExtensions {
class IterableOnceOps[C[X] <: IterableOnce[X], A](private val coll: C[A]) extends AnyVal {
private def it: Iterator[A] = coll.iterator

/**
* Provided as a Scala 2.12 "backport" of Scala 2.13 regular method.
* In Scala 2.13 this extension method is always be hidden by an actual method available on `IterableOnce`.
*/
def knownSize: Int = coll match {
case c: BIterable[_] if c.isEmpty => 0
case is: BIndexedSeq[_] => is.size
case _: IListMap[_, _] => -1
case m: BMap[_, _] => m.size
case s: BSet[_] => s.size
case _ => -1
}

def toSized[To](fac: Factory[A, To], sizeHint: Int): To = {
val b = fac.newBuilder
b.sizeHint(sizeHint)
Expand Down Expand Up @@ -748,9 +733,6 @@ object SharedExtensionsUtils extends SharedExtensions {
}

def distinct: Iterator[A] = distinctBy(identity)

//overloaded to avoid eager iterator consumption in 2.12
def flatCollect[B](f: PartialFunction[A, IterableOnce[B]]): Iterator[B] = it.collect(f).flatten
}

object IteratorCompanionOps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.avsystem.commons
package collection

import scala.collection.compat.{immutable => scci}
import scala.collection.{immutable => sci, mutable => scm}
import scala.{collection => sc}

Expand Down Expand Up @@ -37,8 +36,8 @@ trait CollectionAliases {

type MArraySeq[A] = scm.ArraySeq[A]
final def MArraySeq: scm.ArraySeq.type = scm.ArraySeq
type IArraySeq[+A] = scci.ArraySeq[A]
final def IArraySeq: scci.ArraySeq.type = scci.ArraySeq
type IArraySeq[+A] = sci.ArraySeq[A]
final def IArraySeq: sci.ArraySeq.type = sci.ArraySeq

type BLinearSeq[+A] = sc.LinearSeq[A]
final def BLinearSeq: sc.LinearSeq.type = sc.LinearSeq
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.avsystem.commons
package collection

import scala.collection.compat._

final class MutableStack[T] {
private[this] var ssize: Int = 0
private[this] var stack = List.empty[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.avsystem.commons.concurrent.ObservableExtensions.ObservableOps
import monix.eval.Task
import monix.reactive.Observable

import scala.collection.Factory
import scala.util.Sorting

trait ObservableExtensions {
Expand All @@ -14,8 +15,6 @@ trait ObservableExtensions {
object ObservableExtensions extends ObservableExtensions {
final class ObservableOps[T](private val obs: Observable[T]) extends AnyVal {

import scala.collection.compat._

/** Creates a [[monix.eval.Task Task]] that upon execution
* will signal the first generated element of the source observable.
*
Expand Down Expand Up @@ -51,7 +50,7 @@ object ObservableExtensions extends ObservableExtensions {
.toL(Array)
.map { arr =>
Sorting.stableSort(arr)
immutable.ArraySeq.unsafeWrapArray(arr)
IArraySeq.unsafeWrapArray(arr)
}

/** Given a function that returns a key for each element emitted by the source Observable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.avsystem.commons
package jiop

import java.{lang => jl, util => ju}

import scala.collection.compat._
import scala.collection.Factory

trait JCollectionUtils extends JFactories {
type JIterator[T] = ju.Iterator[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package jiop

import com.avsystem.commons.collection.{CrossBuilder, CrossFactory}

import scala.collection.compat._
import scala.collection.mutable

trait JFactory[-Elem, +To] extends CrossFactory[Elem, To] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rpc

import com.avsystem.commons.macros.misc.MiscMacros

import scala.collection.compat._
import scala.collection.Factory

class InvalidRpcCall(msg: String, cause: Throwable = null)
extends RuntimeException(msg, cause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.avsystem.commons.misc.{Bytes, Timestamp}

import java.util.UUID
import scala.annotation.{implicitNotFound, tailrec}
import scala.collection.compat._
import scala.collection.Factory

/**
* Type class for types that can be serialized to [[Output]] (format-agnostic "output stream") and deserialized
Expand Down Expand Up @@ -511,7 +511,6 @@ object GenCodec extends RecursiveAutoCodecs with TupleGenCodecs {

// these are covered by the generic `seqCodec` and `setCodec` but making them explicit may be easier
// for the compiler and also make IntelliJ less confused
// https://github.com/scala/bug/issues/11027 - only for Scala 2.12
implicit def bseqCodec[T: GenCodec]: GenCodec[BSeq[T]] = seqCodec[BSeq, T](GenCodec[T], implicitly[Factory[T, List[T]]])
implicit def iseqCodec[T: GenCodec]: GenCodec[ISeq[T]] = seqCodec[ISeq, T](GenCodec[T], implicitly[Factory[T, List[T]]])
implicit def mseqCodec[T: GenCodec]: GenCodec[MSeq[T]] = seqCodec[MSeq, T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.avsystem.commons.jiop.JFactory
import com.avsystem.commons.serialization.GenCodec.OOOFieldsObjectCodec
import com.avsystem.commons.serialization._

import scala.collection.compat._
import scala.collection.Factory

trait CborOptimizedCodecs {
/**
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks

import scala.collection.compat._
import scala.collection.Factory

class ObservableExtensionsTest extends AnyFunSuite with Matchers
with ScalaCheckDrivenPropertyChecks with ObservableExtensions with ScalaFutures {
Expand Down Expand Up @@ -56,7 +56,7 @@ class ObservableExtensionsTest extends AnyFunSuite with Matchers
testFactory(Seq)
testFactory(Vector)
testFactory(Iterable)
testFactory(immutable.LazyList)
testFactory(LazyList)
testFactory(IHashMap)
testFactory(IListMap)
testFactory(ITreeMap)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private[commons] trait MacroSymbols extends MacroCommons {
final def RpcUtils = q"$RpcPackage.RpcUtils"
final def OptionLikeCls = tq"$MetaPackage.OptionLike"
final def AutoOptionalParamCls = tq"$MetaPackage.AutoOptionalParam"
final def FactoryCls = tq"$CollectionPkg.compat.Factory"
final def FactoryCls = tq"$CollectionPkg.Factory"
final lazy val RpcArityAT: Type = staticType(tq"$MetaPackage.SymbolArity")
final lazy val SingleArityAT: Type = staticType(tq"$MetaPackage.single")
final lazy val OptionalArityAT: Type = staticType(tq"$MetaPackage.optional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ final class MiscMacros(ctx: blackbox.Context) extends AbstractMacroCommons(ctx)
val elems = au.params.indices.map(i => q"$resName.${TermName(s"_${i + 1}")}")
q"""
val $resName = $unapplyRes.get
$CollectionPkg.compat.immutable.ArraySeq.unsafeWrapArray($ArrayObj[$ScalaPkg.Any](..$elems))
$CollectionPkg.immutable.ArraySeq.unsafeWrapArray($ArrayObj[$ScalaPkg.Any](..$elems))
"""
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.avsystem.commons
package mongo

import java.time.Instant

import org.bson.types.ObjectId
import org.bson.{BsonArray, BsonBinary, BsonBoolean, BsonDateTime, BsonDocument, BsonDouble, BsonInt32, BsonInt64, BsonObjectId, BsonString, BsonValue}
import org.bson._

import _root_.scala.collection.compat._
import java.time.Instant
import _root_.scala.collection.Factory
import _root_.scala.language.higherKinds

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package mongo

import com.mongodb.client.model.{Filters => F}
import org.bson.conversions.Bson
import org.bson.{BsonArray, BsonDateTime, BsonDouble, BsonInt32, BsonInt64, BsonString, BsonValue}
import org.bson._

import _root_.scala.collection.compat._
import _root_.scala.collection.Factory

/**
* @author MKej
Expand Down
Loading

0 comments on commit bf51ea8

Please sign in to comment.