Skip to content

Commit

Permalink
Upgrade to Scala 2.13.8 (digital-asset#12506)
Browse files Browse the repository at this point in the history
* Upgrade to Scala 2.13.8

changelog_begin
changelog_end

* Update hash for scala in nixpkgs

* update more hashes for scala upgrade

* Fix most warnings etc.

* Fix remaining errors etc.

* Fix formatting

* Resolve last errors hopefully

* Fix ledger api common build file

* Combine imports & revert accidental change that broke the CI run

* Rename exporting vals to scriptExport & minimize diff

* Remove more wrong changes

* moved warning around
  • Loading branch information
realvictorprm authored Feb 3, 2022
1 parent d9eb585 commit aa45f48
Show file tree
Hide file tree
Showing 36 changed files with 1,121 additions and 1,103 deletions.
2 changes: 1 addition & 1 deletion bazel-java-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def install_java_deps():
"org.seleniumhq.selenium:selenium-java:3.12.0",
"org.slf4j:slf4j-api:1.7.26",
"org.slf4j:slf4j-simple:1.7.26",
"org.typelevel:kind-projector_{}:0.13.0".format(scala_version),
"org.typelevel:kind-projector_{}:0.13.2".format(scala_version),
"org.tpolecat:doobie-core_{}:0.13.4".format(scala_major_version),
"org.tpolecat:doobie-hikari_{}:0.13.4".format(scala_major_version),
"org.tpolecat:doobie-postgres_{}:0.13.4".format(scala_major_version),
Expand Down
16 changes: 8 additions & 8 deletions bazel_tools/scala_version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

# Keep the Scala versions in sync with /nix/nixpkgs.nix and /release/src/Options.hs.

default_scala_version = "2.13.6"
default_scala_version = "2.13.8"

scala_artifacts = {
"2.13.6": {
"2.13.8": {
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.13.6",
"sha256": "310d263d622a3d016913e94ee00b119d270573a5ceaa6b21312d69637fd9eec1",
"artifact": "org.scala-lang:scala-compiler:2.13.8",
"sha256": "b248cb6f390ee8bceb912af3da471146fdf003702a173d750f986b1d4a3362e6",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.13.6",
"sha256": "f19ed732e150d3537794fd3fe42ee18470a3f707efd499ecd05a99e727ff6c8a",
"artifact": "org.scala-lang:scala-library:2.13.8",
"sha256": "a0882b82514190c2bac7d1a459872a75f005fc0f3e88b2bc0390367146e35db7",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.13.6",
"sha256": "f713593809b387c60935bb9a940dfcea53bd0dbf8fdc8d10739a2896f8ac56fa",
"artifact": "org.scala-lang:scala-reflect:2.13.8",
"sha256": "fdfbcc92e87f424578b303bcb47e0f55fee990c4b6da0006c9e75879d1e442e4",
},
},
}
Expand Down
378 changes: 189 additions & 189 deletions compatibility/maven_install.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1200,15 +1200,15 @@ private[archive] class DecodeV1(minor: LV.Minor) {
),
)
case PLF.CaseAlt.SumCase.ENUM =>
val enum = lfCaseAlt.getEnum
val enumeration = lfCaseAlt.getEnum
CPEnum(
tycon = decodeTypeConName(enum.getCon),
tycon = decodeTypeConName(enumeration.getCon),
constructor = handleInternedName(
enum.getConstructorCase,
enumeration.getConstructorCase,
PLF.CaseAlt.Enum.ConstructorCase.CONSTRUCTOR_STR,
enum.getConstructorStr,
enumeration.getConstructorStr,
PLF.CaseAlt.Enum.ConstructorCase.CONSTRUCTOR_INTERNED_STR,
enum.getConstructorInternedStr,
enumeration.getConstructorInternedStr,
"CaseAlt.Enum.constructor.constructor",
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ final class BackStack[+A] private (fq: BQ[A], val length: Int) {
def reverseForeach(f: A => Unit): Unit = this.reverseIterator.foreach(f)

/** O(1) */
def canEqual(that: Any) = that.isInstanceOf[BackStack[A]]
def canEqual(that: Any) = that.isInstanceOf[BackStack[_]]

/** O(n) */
override def equals(that: Any) = that match {
case thatQueue: BackStack[A] => this.reverseIterator sameElements thatQueue.reverseIterator
case thatQueue: BackStack[_] =>
this.reverseIterator sameElements [Any] thatQueue.reverseIterator
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ final class FrontStack[+A] private (fq: FrontStack.FQ[A], val length: Int) {
def foreach(f: A => Unit): Unit = this.iterator.foreach(f)

/** O(1) */
def canEqual(that: Any) = that.isInstanceOf[FrontStack[A]]
def canEqual(that: Any) = that.isInstanceOf[FrontStack[_]]

/** O(n) */
override def equals(that: Any) = that match {
case thatQueue: FrontStack[A] =>
this.length == thatQueue.length && this.iterator.sameElements(thatQueue.iterator)
case thatQueue: FrontStack[_] =>
this.length == thatQueue.length && this.iterator.sameElements[Any](thatQueue.iterator)
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class SortedLookupList[+X] private (entries: ImmArray[(String, X)]) extend

override def equals(obj: Any): Boolean = {
obj match {
case other: SortedLookupList[X] if other canEqual this => other.toImmArray == entries
case other: SortedLookupList[_] if other canEqual this => other.toImmArray == entries
case _ => false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object InterfaceReader {
case dfn: Ast.DataVariant =>
variant(fullName, tyVars, dfn)
case dfn: Ast.DataEnum =>
enum(fullName, tyVars, dfn)
enumeration(fullName, tyVars, dfn)
case Ast.DataInterface =>
\/-(
None
Expand Down Expand Up @@ -210,16 +210,16 @@ object InterfaceReader {
} yield Some(name -> (iface.InterfaceType.Normal(DefDataType(tyVars, Variant(cons))): T))
}

private[reader] def enum[T >: iface.InterfaceType.Normal](
private[reader] def enumeration[T >: iface.InterfaceType.Normal](
name: QualifiedName,
tyVars: ImmArraySeq[Ast.TypeVarName],
enum: Ast.DataEnum,
enumeration: Ast.DataEnum,
): InterfaceReaderError \/ Some[(QualifiedName, T)] =
if (tyVars.isEmpty)
\/-(
Some(
name -> iface.InterfaceType.Normal(
DefDataType(ImmArraySeq.empty, Enum(enum.constructors.toSeq))
DefDataType(ImmArraySeq.empty, Enum(enumeration.constructors.toSeq))
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.scalatest.wordspec.AnyWordSpec
import com.daml.lf.data.ImmArray
import com.daml.lf.data.Ref
import com.daml.lf.transaction.Node
import com.daml.lf.transaction.Transaction.LeafNode
import com.daml.lf.transaction.TransactionVersion
import com.daml.lf.transaction.{NodeId, Transaction}
import com.daml.lf.value.{Value => V}
Expand Down Expand Up @@ -280,7 +279,8 @@ object NormalizeRollbackSpec {
case V.ValueInt64(n) => Create(n)
case _ => sys.error(s"unexpected create.arg: ${create.arg}")
}
case leaf: LeafNode => sys.error(s"Shape.ofTransaction, unexpected leaf: $leaf")
case leaf: Node.LeafOnlyAction =>
sys.error(s"Shape.ofTransaction, unexpected leaf: $leaf")
case node: Node.Exercise => Exercise(node.children.toList.map(ofNid))
case node: Node.Rollback => Rollback(node.children.toList.map(ofNid))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ object Repl {
successes += 1
totalTime += success.duration
totalSteps += success.steps
println(s"ok in ${success.duration.formatted("%.2f")}ms, ${success.steps} steps")
println(f"ok in ${success.duration}%.2f ms, ${success.steps} steps")
}
}
println(
s"\n$successes passed, $failures failed, total time ${totalTime.formatted("%.2f")}ms, total steps $totalSteps."
f"\n$successes passed, $failures failed, total time $totalTime%.2f ms, total steps $totalSteps."
)
(failures == 0, state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ object TypedValueGenerators {
},
)

def enum(
def enumeration(
name: Ref.Identifier,
members: Seq[Ref.Name],
): (DefDataType.FWT, EnumAddend[members.type]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ object ValueCoder {
ValueVariant(id, identifier(variant.getConstructor), go(newNesting, variant.getValue))

case proto.Value.SumCase.ENUM =>
val enum = protoValue.getEnum
val enumeration = protoValue.getEnum
val id =
if (enum.getEnumId == ValueOuterClass.Identifier.getDefaultInstance) None
if (enumeration.getEnumId == ValueOuterClass.Identifier.getDefaultInstance) None
else {
assertUntil(TransactionVersion.minTypeErasure, "enum_id field in message Enum")
decodeIdentifier(enum.getEnumId).fold(
decodeIdentifier(enumeration.getEnumId).fold(
{ err =>
throw Err(err.errorMessage)
},
Expand All @@ -297,7 +297,7 @@ object ValueCoder {
},
)
}
ValueEnum(id, identifier(enum.getValue))
ValueEnum(id, identifier(enumeration.getValue))

case proto.Value.SumCase.RECORD =>
val record = protoValue.getRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ class HashSpec extends AnyWordSpec with Matchers {
VA.contractId.inj(ContractId.V1 assertFromString str)
}

val enumT1 = VA.enum("Color", List("Red", "Green"))._2
val enumT2 = VA.enum("ColorBis", List("Red", "Green"))._2
val enumT1 = VA.enumeration("Color", List("Red", "Green"))._2
val enumT2 = VA.enumeration("ColorBis", List("Red", "Green"))._2

val enums = List(
enumT1.inj(enumT1.get("Red").get),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ object ValueSpec {
: Gen[(Map[Identifier, VA.EnumAddend[Seq[Name]]], Value.LookupVariantEnum)] =
scopeOfEnumsGen flatMap { details =>
(
details transform ((name, members) => VA.enum(name, members)._2),
details transform ((name, members) => VA.enumeration(name, members)._2),
details
.transform((_, members) => members.to(ImmArray))
.lift,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,40 @@ import spray.json._

private[export] object Encode {

def encodeArgs(export: Export): JsObject = {
def encodeArgs(scriptExport: Export): JsObject = {
JsObject(
"parties" -> JsObject(export.partyMap.keys.map { case Party(party) =>
"parties" -> JsObject(scriptExport.partyMap.keys.map { case Party(party) =>
party -> JsString(party)
}.toMap),
"contracts" -> JsObject(export.unknownCids.map { case ContractId(c) =>
"contracts" -> JsObject(scriptExport.unknownCids.map { case ContractId(c) =>
c -> JsString(c)
}.toMap),
)
}

def encodeExport(export: Export): Doc = {
def encodeExport(scriptExport: Export): Doc = {
Doc.intercalate(
Doc.line + Doc.hardLine,
Seq(
encodeModuleHeader(export.moduleRefs),
encodeModuleHeader(scriptExport.moduleRefs),
encodePartyType(),
encodeLookupParty(),
encodeAllocateParties(export.partyMap),
encodeAllocateParties(scriptExport.partyMap),
encodeContractsType(),
encodeLookupContract(),
encodeArgsType(),
encodeTestExport(),
encodeExportActions(export),
) ++ export.missingInstances.map { case (tplId, spec) => encodeMissingInstances(tplId, spec) },
encodeExportActions(scriptExport),
) ++ scriptExport.missingInstances.map { case (tplId, spec) =>
encodeMissingInstances(tplId, spec)
},
)
}

private[export] def encodeMissingInstances(tplId: TemplateId, spec: TemplateInstanceSpec): Doc = {
private[export] def encodeMissingInstances(
tplId: TemplateId,
spec: TemplateInstanceSpec,
): Doc = {
val tplIdDoc = encodeTemplateId(tplId)
def primInstance(name: String, parms: Doc): Doc = {
val cls = Doc.text(s"Has${name.capitalize}")
Expand Down Expand Up @@ -79,20 +84,23 @@ private[export] object Encode {
Doc.stack(Seq(header) ++ tplInstances ++ keyInstances ++ choiceInstances)
}

private def encodeExportActions(export: Export): Doc = {
private def encodeExportActions(scriptExport: Export): Doc = {
Doc.text("-- | The Daml ledger export.") /
Doc.text("export : Args -> Script ()") /
(Doc.text("export Args{parties, contracts} = do") /
stackNonEmpty(
export.partyMap.map(Function.tupled(encodePartyBinding)).toSeq ++ export.actions.map(
encodeAction(
export.partyMap,
export.cidMap,
export.cidRefs,
export.missingInstances.keySet,
_,
)
) :+ Doc.text("pure ()")
scriptExport.partyMap
.map(Function.tupled(encodePartyBinding))
.toSeq ++ scriptExport.actions
.map(
encodeAction(
scriptExport.partyMap,
scriptExport.cidMap,
scriptExport.cidRefs,
scriptExport.missingInstances.keySet,
_,
)
) :+ Doc.text("pure ()")
)).hang(2)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,21 @@ object Export {
setTime: Boolean,
) = {
val missingInstances = Dependencies.templatesMissingInstances(pkgs)
val export = Export.fromTransactionTrees(acs, trees, missingInstances, acsBatchSize, setTime)
val scriptExport =
Export.fromTransactionTrees(acs, trees, missingInstances, acsBatchSize, setTime)

val dir = Files.createDirectories(targetDir)
Files.write(
dir.resolve("Export.daml"),
Encode
.encodeExport(export)
.encodeExport(scriptExport)
.render(80)
.getBytes(StandardCharsets.UTF_8),
)
Files.write(
dir.resolve("args.json"),
Encode
.encodeArgs(export)
.encodeArgs(scriptExport)
.prettyPrint
.getBytes(StandardCharsets.UTF_8),
)
Expand Down Expand Up @@ -187,7 +188,7 @@ object Export {
)
),
"parties" -> Json.fromValues(
export.partyMap.keys.map(p => Json.fromString(Party.unwrap(p)))
scriptExport.partyMap.keys.map(p => Json.fromString(Party.unwrap(p)))
),
"dependencies" -> Json.fromValues(
List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ package com.daml.script.export

import com.daml.ledger.api.refinements.ApiTypes.ContractId
import com.daml.lf.data.Time.Timestamp
import com.daml.script.`export`.TreeUtils.{SetTime, SubmitSimpleSingle}
import com.daml.script.export.TreeUtils.Action
import com.daml.script.export.TreeUtils.{SetTime, SubmitSimpleSingle, Action}
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import com.daml.ledger.api.v1.{value => V}
import com.daml.lf.data.Ref
import com.daml.lf.language.Ast
import com.daml.lf.language.Util._
import com.daml.script.`export`.Dependencies.ChoiceInstanceSpec
import com.daml.script.export.Dependencies.TemplateInstanceSpec
import com.daml.script.export.Dependencies.{ChoiceInstanceSpec, TemplateInstanceSpec}
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

Expand Down
Loading

0 comments on commit aa45f48

Please sign in to comment.