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

Remove some unecessary implictly with Factory #12559

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import Value._
import com.daml.scalautil.Statement.discard

import scala.annotation.tailrec
import scala.collection.Factory
import scala.collection.immutable

/** An in-memory representation of a ledger for scenarios */
Expand Down Expand Up @@ -308,8 +307,7 @@ object ScenarioLedger {
/** Collect all contract ids appearing in a value
*/
def collectCoids(value: Value): Set[ContractId] = {
val coids =
implicitly[Factory[ContractId, Set[ContractId]]].newBuilder
val coids = Set.newBuilder[ContractId]
def collect(v: Value): Unit =
v match {
case ValueRecord(tycon @ _, fs) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.daml.scalautil.Statement.discard
import com.daml.nameof.NameOf

import scala.jdk.CollectionConverters._
import scala.collection.Factory
import scala.collection.immutable.TreeMap
import scala.util.hashing.MurmurHash3

Expand Down Expand Up @@ -228,9 +227,7 @@ object SValue {
def apply(isTextMap: Boolean, entries: Iterator[(SValue, SValue)]): SMap = {
SMap(
isTextMap,
implicitly[Factory[(SValue, SValue), TreeMap[SValue, SValue]]].fromSpecific(entries.map {
case p @ (k, _) => comparable(k); p
}),
entries.map { case p @ (k, _) => comparable(k); p }.to(TreeMap),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import iface.{
Variant,
PrimType => PT,
}
import scala.collection.Factory
import scalaz.{@@, Order, Ordering, Tag}
import scalaz.syntax.bitraverse._
import scalaz.syntax.traverse._
Expand Down Expand Up @@ -243,10 +242,7 @@ object TypedValueGenerators {
override def inj(hl: Inj) =
ValueRecord(
Some(name),
implicitly[
Factory[(Some[Ref.Name], Value), ImmArray[(Some[Ref.Name], Value)]]
]
.fromSpecific(lfvFieldNames zip spec.injRec(hl)),
(lfvFieldNames zip spec.injRec(hl)).to(ImmArray),
)
override def prj = {
case ValueRecord(_, fields) if fields.length == spec.t.length =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.daml.ledger.api.v1.{event => evv1}
import scalaz.{Monoid, \/, \/-}
import scalaz.syntax.tag._

import scala.collection.Factory
import scala.runtime.AbstractFunction1

private[daml] final case class InsertDeleteStep[+D, +C](
Expand Down Expand Up @@ -40,7 +39,7 @@ private[daml] final case class InsertDeleteStep[+D, +C](
def partitionMapPreservingIds[LC, CC](
f: C => (LC \/ CC)
): (Inserts[LC], InsertDeleteStep[D, CC]) = {
val (_, lcs, step) = partitionBimap(\/-(_), f)(implicitly[Factory[Unit, List[Unit]]])
val (_, lcs, step) = partitionBimap(\/-(_), f)(List)
(lcs, step)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ class WebSocketService(
.fromLedgerApi(ce)
.liftErr(ServerError)
.flatMap(_.traverse(apiValueToLfValue).liftErr(ServerError)),
)(implicitly[Factory[ServerError, Seq[ServerError]]])
)(Seq)
StepAndErrors(
errors ++ aerrors,
dstep mapInserts { inserts: Vector[domain.ActiveContract[LfV]] =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.daml.ledger.participant.state.kvutils.store.{DamlStateKey, DamlStateV
import com.daml.ledger.participant.state.kvutils.{Envelope, Raw}

import scala.collection.SortedMap
import scala.collection.Factory

final class StateSerializationStrategy(keyStrategy: StateKeySerializationStrategy) {
def serializeState(key: DamlStateKey, value: DamlStateValue): Raw.StateEntry =
Expand All @@ -16,8 +15,5 @@ final class StateSerializationStrategy(keyStrategy: StateKeySerializationStrateg
def serializeStateUpdates(
state: Map[DamlStateKey, DamlStateValue]
): SortedMap[Raw.StateKey, Raw.Envelope] =
implicitly[Factory[Raw.StateEntry, SortedMap[Raw.StateKey, Raw.Envelope]]]
.fromSpecific(state.view.map { case (key, value) =>
serializeState(key, value)
})
state.view.map { case (key, value) => serializeState(key, value) }.to(SortedMap)
}