Skip to content

Commit

Permalink
Update scalafmt to 3.5.1. (digital-asset#13584)
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
nicu-da authored Apr 28, 2022
1 parent 0404aa2 commit a792de3
Show file tree
Hide file tree
Showing 127 changed files with 288 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.0.6
version = 3.5.1

project.git = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ object DecodeMain extends App {
println(s"parseFrom in ${toMillis(t0, t1)}ms, decoded in ${toMillis(t1, t2)}ms.")

// Wait a while to allow for running e.g. jmap -heap etc.
//val pid = Integer.parseInt(new File("/proc/self").getCanonicalFile.getName)
//println(s"sleeping 5s, pid is $pid.")
//Thread.sleep(5000)
// val pid = Integer.parseInt(new File("/proc/self").getCanonicalFile.getName)
// println(s"sleeping 5s, pid is $pid.")
// Thread.sleep(5000)

System.gc()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class DecodeV1Spec
def toDecimalProto(s: String): DamlLf1.Expr =
DamlLf1.Expr.newBuilder().setPrimLit(DamlLf1.PrimLit.newBuilder().setDecimalStr(s)).build()

//def toNumericProto(s: String): DamlLf1.Expr =
// def toNumericProto(s: String): DamlLf1.Expr =
// DamlLf1.Expr.newBuilder().setPrimLit(DamlLf1.PrimLit.newBuilder().setNumeric(s)).build()

def toNumericProto(id: Int): DamlLf1.Expr =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ private final class ConcatenableMatchingStringModule(
val c = s(i).toInt
if (c > 0x7f || disallowedChar(c))
throw new IllegalArgumentException(s"""non expected character 0x${s(
i
).toInt.toHexString} in $description "$s"""")
i
).toInt.toHexString} in $description "$s"""")
i += 1
}
s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

package com.daml.lf

import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.{Arbitrary, Gen}
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class RefTest extends AnyFreeSpec with Matchers with EitherValues {
DottedName.fromSegments(List.fill(500)(s1)) shouldBe a[Right[_, _]] // length = 999
DottedName.fromSegments(List.fill(501)(s1)) shouldBe a[Left[_, _]] // length = 1001
DottedName.fromSegments(List.fill(5000)(s1)) shouldBe a[Left[_, _]] // length = 5002
DottedName.fromSegments(List(s499, s500)) shouldBe a[Right[_, _]] //length = 1000
DottedName.fromSegments(List(s500, s500)) shouldBe a[Left[_, _]] //length = 1001
DottedName.fromSegments(List(s499, s500)) shouldBe a[Right[_, _]] // length = 1000
DottedName.fromSegments(List(s500, s500)) shouldBe a[Left[_, _]] // length = 1001
DottedName.fromSegments(List(s1000)) shouldBe a[Right[_, _]] // length = 1000
DottedName.fromSegments(List(s1000, s1)) shouldBe a[Left[_, _]] // length = 1002
DottedName.fromSegments(List(s1, s1000)) shouldBe a[Left[_, _]] // length = 1002
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Engine(val config: EngineConfig = Engine.StableConfig) {
submissionTime: Time.Timestamp,
submissionSeed: crypto.Hash,
)(implicit loggingContext: LoggingContext): Result[Unit] = {
//reinterpret
// reinterpret
for {
result <- replay(
submitters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ class EngineTest
}

fetchNodes.foreach { case (_, n) =>
val nid = NodeId(0) //we must use node-0 so the constructed tx is normalized
val nid = NodeId(0) // we must use node-0 so the constructed tx is normalized
val fetchTx = VersionedTransaction(n.version, Map(nid -> n), ImmArray(nid))
val Right((reinterpreted, _)) =
suffixLenientEngine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ object PlaySpeedy {

val examples = List(
(
"sub", //11-33
"sub", // 11-33
-22,
subtract2(num(11), num(33)),
),
Expand All @@ -121,7 +121,7 @@ object PlaySpeedy {
subtract2(subtract2(num(1), num(3)), subtract2(num(5), num(10))),
),
(
"subF", //88-55
"subF", // 88-55
33,
SEApp(subtract, List(num(88), num(55))),
),
Expand All @@ -131,7 +131,7 @@ object PlaySpeedy {
SEApp(thrice, List(decrement, num(0))),
),
(
"thrice-thrice", //thrice thrice (\x -> x - 1) 0
"thrice-thrice", // thrice thrice (\x -> x - 1) 0
-27,
SEApp(thrice, List(thrice, decrement, num(0))),
),
Expand All @@ -151,7 +151,7 @@ object PlaySpeedy {
mkVar(1),
),
),
), //100
), // 100
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ object ScenarioLedger {
richTransaction: RichTransaction,
)

//----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Enriching transactions with disclosure information
//----------------------------------------------------------------------------
// ----------------------------------------------------------------------------

def collectCoids(value: VersionedValue): Set[ContractId] =
collectCoids(value.unversioned)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private[lf] object Anf {
}

private[this] def expandMultiLet(rhss: List[source.SExpr], body: source.SExpr): source.SExpr = {
//loop over rhss in reverse order
// loop over rhss in reverse order
@tailrec
def loop(acc: source.SExpr, xs: List[source.SExpr]): source.SExpr = {
xs match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private[lf] final class Compiler(

@throws[PackageNotFound]
@throws[CompilationError]
def unsafeCompileModule( //called by scenario-service
def unsafeCompileModule( // called by scenario-service
pkgId: PackageId,
module: Module,
): Iterable[(t.SDefinitionRef, SDefinition)] = compileModule(pkgId, module)
Expand Down Expand Up @@ -594,7 +594,7 @@ private[lf] final class Compiler(
@nowarn("msg=parameter value tokenPos in method compileFetchBody is never used")
private[this] def compileFetchBody(env: Env, tmplId: Identifier, tmpl: Template)(
cidPos: Position,
mbKey: Option[Position], //defined for byKey operation
mbKey: Option[Position], // defined for byKey operation
tokenPos: Position,
) =
let(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ private[lf] final class PhaseOne(
val env1 = env0.pushExprVar(binder)
body match {
case eLet1: ELet =>
compileELet(env1, eLet1, bounds) //recursive call in compileExp is stack-safe
compileELet(env1, eLet1, bounds) // recursive call in compileExp is stack-safe
case _ =>
compileExp(env1, body) {
case SELet(bounds1, body1) =>
Expand Down Expand Up @@ -792,7 +792,7 @@ private[lf] final class PhaseOne(
exp match {
case EApp(fun, arg) =>
compileExp(env, arg) { arg =>
compileAppsX(env, fun, arg :: args) //recursive call in compileExp is stack-safe
compileAppsX(env, fun, arg :: args) // recursive call in compileExp is stack-safe
}
case ETyApp(fun, arg) =>
compileApps(env, fun, translateType(env, arg).fold(args)(_ :: args))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ private[lf] object Pretty {
s"node $id (${nc.templateId}) has no controllers"
case ma: FailedAuthorization.CreateMissingAuthorization =>
s"node $id (${ma.templateId}) requires authorizers ${ma.requiredParties
.mkString(",")}, but only ${ma.authorizingParties.mkString(",")} were given"
.mkString(",")}, but only ${ma.authorizingParties.mkString(",")} were given"
case ma: FailedAuthorization.FetchMissingAuthorization =>
s"node $id requires one of the stakeholders ${ma.stakeholders} of the fetched contract to be an authorizer, but authorizers were ${ma.authorizingParties}"
case ma: FailedAuthorization.ExerciseMissingAuthorization =>
s"node $id (${ma.templateId}) requires authorizers ${ma.requiredParties
.mkString(",")}, but only ${ma.authorizingParties.mkString(",")} were given"
.mkString(",")}, but only ${ma.authorizingParties.mkString(",")} were given"
case ns: FailedAuthorization.NoSignatories =>
s"node $id (${ns.templateId}) has no signatories"
case nlbk: FailedAuthorization.LookupByKeyMissingAuthorization =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ private[lf] object SBuiltin {
opt match {
case None =>
onLedger.ptx = onLedger.ptx.abortTry
unwindToHandler(machine, excep) //re-throw
unwindToHandler(machine, excep) // re-throw
case Some(handler) =>
onLedger.ptx = onLedger.ptx.rollbackTry(excep)
machine.enterApplication(handler, Array(SEValue(SToken)))
Expand Down Expand Up @@ -1862,7 +1862,7 @@ private[lf] object SBuiltin {
SCaseAlt(
SCPPrimCon(Ast.PCTrue), // True ->
SEAppAtomicGeneral(
SEBuiltin(SBEqualList), //single recursive occurrence
SEBuiltin(SBEqualList), // single recursive occurrence
Array(
SELocA(0), // f
SELocS(2), // yss
Expand Down Expand Up @@ -1906,7 +1906,7 @@ private[lf] object SBuiltin {
machine.returnValue = SInt64(42L)
}

//TODO: move this into the speedy compiler code
// TODO: move this into the speedy compiler code
private val mapping: Map[String, compileTime.SExpr] =
List(
"ANSWER" -> SBExperimentalAnswer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ object SExpr {
i += 1
}
val v = builtin.executePure(actuals)
machine.pushEnv(v) //use pushEnv not env.add so instrumentation is updated
machine.pushEnv(v) // use pushEnv not env.add so instrumentation is updated
machine.ctrl = body
}
}
Expand All @@ -278,7 +278,7 @@ object SExpr {
}
builtin.compute(actuals) match {
case Some(value) =>
machine.pushEnv(value) //use pushEnv not env.add so instrumentation is updated
machine.pushEnv(value) // use pushEnv not env.add so instrumentation is updated
machine.ctrl = body
case None =>
unwindToHandler(machine, builtin.buildException(actuals))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private[lf] object Speedy {
SVisibleToStakeholders.fromSubmitters(committers, readAs)
}
private[lf] def finish: PartialTransaction.Result = ptx.finish
private[lf] def ptxInternal: PartialTransaction = ptx //deprecated
private[lf] def ptxInternal: PartialTransaction = ptx // deprecated
private[lf] def incompleteTransaction: IncompleteTransaction = ptx.finishIncomplete

private[speedy] def updateCachedContracts(cid: V.ContractId, contract: CachedContract): Unit = {
Expand Down Expand Up @@ -482,7 +482,7 @@ private[lf] object Speedy {
case serr: SError =>
SResultError(serr)
case ex: RuntimeException =>
SResultError(SErrorCrash(NameOf.qualifiedNameOfCurrentFunc, s"exception: $ex")) //stop
SResultError(SErrorCrash(NameOf.qualifiedNameOfCurrentFunc, s"exception: $ex")) // stop
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ private[lf] object NormalizeRollbacks {
}
}
}
//pass 1
// pass 1
traverseNodeIds(rootsOriginal.toList) { norms =>
//pass 2
// pass 2
pushNorms(initialState, norms.toList) { (finalState, roots) =>
Land(
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ private[speedy] case class PartialTransaction(
ec.parent.addActionChild(nodeId, exerciseNode.version min context.minChildVersion),
nodes = nodes.updated(nodeId, exerciseNode),
actionNodeSeeds =
actionNodeSeeds :+ actionNodeSeed, //(NC) pushed by 'beginExercises'; why push again?
actionNodeSeeds :+ actionNodeSeed, // (NC) pushed by 'beginExercises'; why push again?
)
case _ =>
InternalError.runtimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class ExceptionTest extends AnyWordSpec with Inside with Matchers with TableDriv
implicit val defaultParserParameters: ParserParameters[this.type] = {
ParserParameters(
defaultPackageId = oldPid,
languageVersion = LanguageVersion.v1_11, //version pre-dating exceptions
languageVersion = LanguageVersion.v1_11, // version pre-dating exceptions
)
}
p"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

package com.daml.lf.speedy

import com.daml.lf.data.ImmArray
import com.daml.lf.data.Ref._
import com.daml.lf.data.Ref.PackageId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ class RollbackTest extends AnyWordSpec with Matchers with TableDrivenPropertyChe

object RollbackTest {

sealed trait Tree //minimal transaction tree, for purposes of writing test expectation
final case class C(x: Long) extends Tree //Create Node
final case class X(x: List[Tree]) extends Tree //Exercise Node
final case class R(x: List[Tree]) extends Tree //Rollback Node
sealed trait Tree // minimal transaction tree, for purposes of writing test expectation
final case class C(x: Long) extends Tree // Create Node
final case class X(x: List[Tree]) extends Tree // Exercise Node
final case class R(x: List[Tree]) extends Tree // Rollback Node

private def shapeOfTransaction(tx: SubmittedTransaction): List[Tree] = {
def trees(nid: NodeId): List[Tree] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sealed abstract class LanguageMajorVersion(val pretty: String, minorAscending: N
} else {
val supportedVersions = acceptedVersions.map(v => s"$this.${v.identifier}")
Left(s"LF $this.$minorVersion unsupported. Supported LF versions are ${supportedVersions
.mkString(",")}")
.mkString(",")}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ object Repl {
(false, state)
case success: ScenarioRunner.ScenarioSuccess =>
// NOTE(JM): cannot print this, output used in tests.
//println(s"done in ${diff.formatted("%.2f")}ms, ${steps} steps")
// println(s"done in ${diff.formatted("%.2f")}ms, ${steps} steps")
println(prettyLedger(success.ledger).render(128))
(true, state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class ScenarioRunner(
var steps = 0
var finalValue: SValue = null
while (finalValue == null) {
//machine.print(steps)
// machine.print(steps)
steps += 1 // this counts the number of external `Need` interactions
val res: SResult = machine.run()
res match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object ValueGenerators {
import TransactionVersion.minExceptions
import TransactionVersion.minInterfaces

//generate decimal values
// generate decimal values
def numGen(scale: Numeric.Scale): Gen[Numeric] = {
val num = for {
integerPart <- Gen.listOfN(Numeric.maxPrecision - scale, Gen.choose(1, 9)).map(_.mkString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ final case class Transaction(
val node1 = nodes(nid1)
val node2 = other.nodes(nid2)
node1 match {
case nr1: Node.Rollback => //TODO: can this be Node.Rollback ?
case nr1: Node.Rollback => // TODO: can this be Node.Rollback ?
node2 match {
case nr2: Node.Rollback => //TODO: and here
case nr2: Node.Rollback => // TODO: and here
val blankedNr1: Node.Rollback =
nr1.copy(children = ImmArray.Empty)
val blankedNr2: Node.Rollback =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ object TransactionCoder {
nodeId: NodeId,
node: Node,
disableVersionCheck: Boolean =
false, //true allows encoding of bad protos (for testing of decode checks)
false, // true allows encoding of bad protos (for testing of decode checks)
): Either[EncodeError, TransactionOuterClass.Node] = {

val nodeBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object TransactionVersion {
private[lf] val minNodeVersion = V11
private[lf] val minNoVersionValue = V12
private[lf] val minTypeErasure = V12
//nothing was added in V13, so there are no vals: "minSomething = V13"
// nothing was added in V13, so there are no vals: "minSomething = V13"
private[lf] val minExceptions = V14
private[lf] val minByKey = V14
private[lf] val minInterfaces = VDev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ class TransactionCoderSpec
txVersion,
NodeId(0),
normalizedNode,
disableVersionCheck = true, //so the bad proto can be created
disableVersionCheck = true, // so the bad proto can be created
)
val result =
TransactionCoder
Expand Down Expand Up @@ -713,7 +713,7 @@ class TransactionCoderSpec
v2,
NodeId(0),
normalizedNode,
disableVersionCheck = true, //so the bad proto can be created
disableVersionCheck = true, // so the bad proto can be created
)
val result =
TransactionCoder
Expand Down Expand Up @@ -892,7 +892,7 @@ class TransactionCoderSpec

private[this] def normalizeNode(node: Node) =
node match {
case rb: Node.Rollback => rb //nothing to normalize
case rb: Node.Rollback => rb // nothing to normalize
case exe: Node.Exercise => normalizeExe(exe)
case fetch: Node.Fetch => normalizeFetch(fetch)
case create: Node.Create => normalizeCreate(create)
Expand Down
Loading

0 comments on commit a792de3

Please sign in to comment.