replace custom toOptional in interface library with scala-library method (#14487)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Stephen Compall 2022-07-21 13:12:21 -04:00 committed by GitHub
parent 8d93efdd12
commit 67b47c6dff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -31,6 +31,7 @@ import com.daml.lf.data.Ref
import com.daml.nonempty.NonEmpty
import scala.jdk.CollectionConverters._
import scala.jdk.OptionConverters._
case class DefDataType[+RF, +VF](typeVars: ImmArraySeq[Ref.Name], dataType: DataType[RF, VF]) {
def bimap[C, D](f: RF => C, g: VF => D): DefDataType[C, D] =
@ -211,7 +212,7 @@ final case class DefTemplate[+Ty](
copy(tChoices = r))
}
def getKey: j.Optional[_ <: Ty] = toOptional(key)
def getKey: j.Optional[_ <: Ty] = key.toJava
private[iface] def extendWithInterface[OTy >: Ty](
ifaceName: Ref.TypeConName,
@ -304,7 +305,7 @@ sealed abstract class TemplateChoices[+Ty] extends Product with Serializable {
final def getResolvedChoices
: j.Map[Ref.ChoiceName, _ <: j.Map[j.Optional[Ref.TypeConName], _ <: TemplateChoice[Ty]]] =
resolvedChoices.transform((_, m) => m.forgetNE.mapKeys(toOptional).asJava).asJava
resolvedChoices.transform((_, m) => m.forgetNE.mapKeys(_.toJava).asJava).asJava
/** Coerce to [[Resolved]] based on the environment `astInterfaces`, or fail
* with the choices that could not be resolved.

View File

@ -3,9 +3,7 @@
package com.daml.lf
import java.{util => j}
import com.daml.lf.data.Ref
import data.Ref
// Types to be used internally
package object iface {
@ -19,7 +17,4 @@ package object iface {
private[iface] def lfprintln(
@deprecated("shut up unused arguments warning", "") s: => String
): Unit = ()
private[iface] def toOptional[A](o: Option[A]): j.Optional[A] =
o.fold(j.Optional.empty[A])(j.Optional.of)
}