LF: rename language Interface to PackageInterface (#10938)

To avoid confusion with the new Daml concept of Interface.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Remy 2021-09-20 21:04:14 +02:00 committed by GitHub
parent 054c6abb63
commit 5dc15c6911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 76 additions and 76 deletions

View File

@ -227,7 +227,7 @@ class ReplService(
val (pkgId, pkg) = archive.ArchiveDecoder.assertFromByteString(req.getPackage)
val newSignatures = signatures.updated(pkgId, AstUtil.toSignature(pkg))
val newCompiledDefinitions = compiledDefinitions ++
new Compiler(new language.Interface(newSignatures), compilerConfig)
new Compiler(new language.PackageInterface(newSignatures), compilerConfig)
.unsafeCompilePackage(pkgId, pkg)
signatures = newSignatures
compiledDefinitions = newCompiledDefinitions
@ -257,7 +257,7 @@ class ReplService(
}
val signatures = this.signatures.updated(homePackageId, AstUtil.toSignature(pkg))
val interface = new language.Interface(signatures)
val interface = new language.PackageInterface(signatures)
val defs =
new Compiler(interface, compilerConfig).unsafeCompilePackage(homePackageId, pkg)
val compiledPackages =

View File

@ -99,7 +99,7 @@ class Context(val contextId: Context.ContextId, languageVersion: LanguageVersion
if (unloadPackages.nonEmpty || newPackages.nonEmpty) {
val invalidPackages = unloadModules ++ newPackages.keys
val newExtSignature = extSignatures -- unloadPackages ++ AstUtil.toSignatures(newPackages)
val interface = new language.Interface(newExtSignature)
val interface = new language.PackageInterface(newExtSignature)
val newExtDefns = extDefns.view.filterKeys(sdef => !invalidPackages(sdef.packageId)) ++
assertRight(Compiler.compilePackages(interface, newPackages, compilerConfig))
// we update only if we manage to compile the new packages
@ -112,7 +112,7 @@ class Context(val contextId: Context.ContextId, languageVersion: LanguageVersion
newModules
}
val interface = new language.Interface(this.allSignatures)
val interface = new language.PackageInterface(this.allSignatures)
val compiler = new Compiler(interface, compilerConfig)
modulesToCompile.foreach { mod =>

View File

@ -9,7 +9,7 @@ import java.nio.file.Paths
import com.daml.lf.archive.{Dar, DarWriter}
import com.daml.lf.data.Ref
import com.daml.lf.data.Ref.PackageId
import com.daml.lf.language.{Ast, Interface, LanguageVersion}
import com.daml.lf.language.{Ast, PackageInterface, LanguageVersion}
import com.daml.lf.testing.parser.{ParserParameters, parseModules}
import com.daml.lf.validation.Validation
import com.daml.SdkVersion
@ -71,7 +71,7 @@ private[daml] object DamlLfEncoder extends App {
val pkg =
Ast.Package(modules, Set.empty[PackageId], parserParameters.languageVersion, metadata)
val pkgs = Interface(Map(pkgId -> pkg))
val pkgs = PackageInterface(Map(pkgId -> pkg))
Validation.checkPackage(pkgs, pkgId, pkg).left.foreach(e => error(e.pretty))

View File

@ -192,7 +192,7 @@ object EncodeV1Spec {
private def validate(pkgId: PackageId, pkg: Package): Unit =
Validation
.checkPackage(language.Interface(Map(pkgId -> pkg)), pkgId, pkg)
.checkPackage(language.PackageInterface(Map(pkgId -> pkg)), pkgId, pkg)
.left
.foreach(e => sys.error(e.toString))

View File

@ -9,7 +9,7 @@ import java.util.concurrent.ConcurrentHashMap
import com.daml.lf.data.Ref.PackageId
import com.daml.lf.engine.ConcurrentCompiledPackages.AddPackageState
import com.daml.lf.language.Ast.{Package, PackageSignature}
import com.daml.lf.language.{Interface, Util => AstUtil}
import com.daml.lf.language.{PackageInterface, Util => AstUtil}
import com.daml.lf.speedy.Compiler
import com.daml.nameof.NameOf
@ -30,7 +30,7 @@ private[lf] final class ConcurrentCompiledPackages(compilerConfig: Compiler.Conf
new ConcurrentHashMap()
override def packageIds: scala.collection.Set[PackageId] = signatures.keySet
override def interface: Interface = new Interface(signatures)
override def interface: PackageInterface = new PackageInterface(signatures)
override def getDefinition(dref: speedy.SExpr.SDefinitionRef): Option[speedy.SDefinition] =
Option(definitionsByReference.get(dref))
@ -99,7 +99,7 @@ private[lf] final class ConcurrentCompiledPackages(compilerConfig: Compiler.Conf
if (!signatures.contains(pkgId)) {
val pkgSignature = AstUtil.toSignature(pkg)
val extendedSignatures =
new language.Interface(Map(pkgId -> pkgSignature) orElse signatures)
new language.PackageInterface(Map(pkgId -> pkgSignature) orElse signatures)
// Compile the speedy definitions for this package.
val defns =

View File

@ -15,7 +15,7 @@ import com.daml.lf.transaction.{SubmittedTransaction, Transaction => Tx}
import com.daml.lf.transaction.Node._
import java.nio.file.Files
import com.daml.lf.language.{Interface, LanguageVersion, LookupError, StablePackages}
import com.daml.lf.language.{PackageInterface, LanguageVersion, LookupError, StablePackages}
import com.daml.lf.validation.Validation
import com.daml.nameof.NameOf
@ -456,7 +456,7 @@ class Engine(val config: EngineConfig = Engine.StableConfig) {
pkgIds = pkgs.keySet
missingDeps = pkgs.valuesIterator.flatMap(_.directDeps).toSet.filterNot(pkgIds)
_ <- Either.cond(missingDeps.isEmpty, (), Error.Package.SelfConsistency(pkgIds, missingDeps))
interface = Interface(pkgs)
interface = PackageInterface(pkgs)
_ <- {
pkgs.iterator
// we trust already loaded packages

View File

@ -12,7 +12,7 @@ import com.daml.lf.value.Value
import scala.annotation.tailrec
private[lf] final class CommandPreprocessor(
interface: language.Interface,
interface: language.PackageInterface,
// See Preprocessor scala doc for more details about the following flags.
forbidV0ContractId: Boolean,
requireV1ContractIdSuffix: Boolean,

View File

@ -15,7 +15,7 @@ import com.daml.lf.value.Value._
import scala.annotation.tailrec
private[engine] final class ValueTranslator(
interface: language.Interface,
interface: language.PackageInterface,
// See Preprocessor scala doc for more details about the following flags.
forbidV0ContractId: Boolean,
requireV1ContractIdSuffix: Boolean,

View File

@ -69,7 +69,7 @@ class EngineTest
"daml-lf/tests/BasicTests.dar"
)
val basicTestsSignatures = language.Interface(Map(basicTestsPkgId -> basicTestsPkg))
val basicTestsSignatures = language.PackageInterface(Map(basicTestsPkgId -> basicTestsPkg))
val withKeyTemplate = "BasicTests:WithKey"
val BasicTests_WithKey = Identifier(basicTestsPkgId, withKeyTemplate)
@ -289,7 +289,7 @@ class EngineTest
}
val let = Time.Timestamp.now()
val submissionSeed = hash("multi-party create command")
val submissionSeed = hash("multi-party create command2")
def interpretResult(
templateId: String,

View File

@ -5,7 +5,7 @@ package com.daml.lf
package speedy
package explore
import com.daml.lf.language.Interface
import com.daml.lf.language.PackageInterface
import com.daml.lf.speedy.SExpr._
import com.daml.lf.speedy.SValue._
import com.daml.lf.speedy.SResult._
@ -25,7 +25,7 @@ object PlaySpeedy {
def main(args0: List[String]) = {
val config: Config = parseArgs(args0)
val compiler: Compiler = new Compiler(Interface.Empty, compilerConfig)
val compiler: Compiler = new Compiler(PackageInterface.Empty, compilerConfig)
val names: List[String] = config.names match {
case Nil => examples.toList.map(_._1)

View File

@ -5,7 +5,7 @@ package com.daml.lf
import com.daml.lf.data.Ref.PackageId
import com.daml.lf.language.Ast.{Package, PackageSignature}
import com.daml.lf.language.{Interface, Util}
import com.daml.lf.language.{PackageInterface, Util}
import com.daml.lf.speedy.SExpr.SDefinitionRef
import com.daml.lf.speedy.{Compiler, SDefinition}
@ -17,7 +17,7 @@ private[lf] abstract class CompiledPackages(
) {
def getDefinition(dref: SDefinitionRef): Option[SDefinition]
def packageIds: scala.collection.Set[PackageId]
def interface: Interface
def interface: PackageInterface
def definitions: PartialFunction[SDefinitionRef, SDefinition] =
Function.unlift(this.getDefinition)
@ -29,7 +29,7 @@ private[lf] abstract class CompiledPackages(
*/
private[lf] final class PureCompiledPackages(
val packageIds: Set[PackageId],
val interface: Interface,
val interface: PackageInterface,
val defns: Map[SDefinitionRef, SDefinition],
compilerConfig: Compiler.Config,
) extends CompiledPackages(compilerConfig) {
@ -46,14 +46,14 @@ private[lf] object PureCompiledPackages {
defns: Map[SDefinitionRef, SDefinition],
compilerConfig: Compiler.Config,
): PureCompiledPackages =
new PureCompiledPackages(packages.keySet, new Interface(packages), defns, compilerConfig)
new PureCompiledPackages(packages.keySet, new PackageInterface(packages), defns, compilerConfig)
def build(
packages: Map[PackageId, Package],
compilerConfig: Compiler.Config = Compiler.Config.Default,
): Either[String, PureCompiledPackages] = {
Compiler
.compilePackages(Interface(packages), packages, compilerConfig)
.compilePackages(PackageInterface(packages), packages, compilerConfig)
.map(apply(Util.toSignatures(packages), _, compilerConfig))
}

View File

@ -8,7 +8,7 @@ import java.util
import com.daml.lf.data.Ref._
import com.daml.lf.data.{ImmArray, Numeric, Ref, Struct, Time}
import com.daml.lf.language.Ast._
import com.daml.lf.language.{LanguageVersion, LookupError, Interface, StablePackages}
import com.daml.lf.language.{LanguageVersion, LookupError, PackageInterface, StablePackages}
import com.daml.lf.speedy.Anf.flattenToAnf
import com.daml.lf.speedy.Profile.LabelModule
import com.daml.lf.speedy.SBuiltin._
@ -105,7 +105,7 @@ private[lf] object Compiler {
* they transitively reference are in the [[packages]] in the compiler.
*/
def compilePackages(
interface: Interface,
interface: PackageInterface,
packages: Map[PackageId, Package],
compilerConfig: Compiler.Config,
): Either[String, Map[SDefinitionRef, SDefinition]] = {
@ -136,7 +136,7 @@ private[lf] object Compiler {
}
private[lf] final class Compiler(
interface: Interface,
interface: PackageInterface,
config: Compiler.Config,
) {

View File

@ -8,7 +8,7 @@ import com.daml.lf.data.Ref
import com.daml.lf.data.Ref.{PackageId, Party}
import com.daml.lf.interpretation.{Error => IE}
import com.daml.lf.language.Ast._
import com.daml.lf.language.{LanguageVersion, Interface}
import com.daml.lf.language.{LanguageVersion, PackageInterface}
import com.daml.lf.speedy.Compiler.FullStackTrace
import com.daml.lf.speedy.SResult.{SResultError, SResultFinalValue}
import com.daml.lf.speedy.SError.SErrorDamlException
@ -539,7 +539,7 @@ class ExceptionTest extends AnyWordSpec with Matchers with TableDrivenPropertyCh
private def typeAndCompile(pkg: Package): PureCompiledPackages = {
import defaultParserParameters.defaultPackageId
val rawPkgs = Map(defaultPackageId -> pkg)
Validation.checkPackage(Interface(rawPkgs), defaultPackageId, pkg)
Validation.checkPackage(PackageInterface(rawPkgs), defaultPackageId, pkg)
val compilerConfig = Compiler.Config.Dev.copy(stacktracing = FullStackTrace)
PureCompiledPackages.assertBuild(rawPkgs, compilerConfig)
}

View File

@ -8,7 +8,7 @@ import com.daml.lf.data.ImmArray
import com.daml.lf.data.Ref
import com.daml.lf.data.Ref.Party
import com.daml.lf.language.Ast.{Package, Expr, PrimLit, PLParty, EPrimLit, EApp}
import com.daml.lf.language.{LanguageVersion, Interface}
import com.daml.lf.language.{LanguageVersion, PackageInterface}
import com.daml.lf.speedy.Compiler.FullStackTrace
import com.daml.lf.speedy.PartialTransaction.{CompleteTransaction, IncompleteTransaction, LeafNode}
import com.daml.lf.speedy.SResult.SResultFinalValue
@ -38,7 +38,7 @@ class ExceptionTest extends AnyWordSpec with Matchers with TableDrivenPropertyCh
private def typeAndCompile(pkg: Package): PureCompiledPackages = {
import defaultParserParameters.defaultPackageId
val rawPkgs = Map(defaultPackageId -> pkg)
Validation.checkPackage(Interface(rawPkgs), defaultPackageId, pkg)
Validation.checkPackage(PackageInterface(rawPkgs), defaultPackageId, pkg)
val compilerConfig = Compiler.Config.Dev.copy(stacktracing = FullStackTrace)
PureCompiledPackages.assertBuild(rawPkgs, compilerConfig)
}

View File

@ -517,7 +517,7 @@ object SpeedyTest {
private def typeAndCompile(pkg: Package): PureCompiledPackages = {
import defaultParserParameters.defaultPackageId
val rawPkgs = Map(defaultPackageId -> pkg)
Validation.checkPackage(language.Interface(rawPkgs), defaultPackageId, pkg)
Validation.checkPackage(language.PackageInterface(rawPkgs), defaultPackageId, pkg)
val compilerConfig = Compiler.Config.Default.copy(stacktracing = FullStackTrace)
PureCompiledPackages.assertBuild(rawPkgs, compilerConfig)
}

View File

@ -105,7 +105,7 @@ class TailCallTest extends AnyWordSpec with Matchers with TableDrivenPropertyChe
import defaultParserParameters.defaultPackageId
val rawPkgs = Map(defaultPackageId -> pkg)
Validation.checkPackage(
language.Interface(rawPkgs),
language.PackageInterface(rawPkgs),
defaultParserParameters.defaultPackageId,
pkg,
)

View File

@ -7,9 +7,9 @@ package language
import com.daml.lf.data.Ref._
import com.daml.lf.language.Ast._
private[lf] class Interface(signatures: PartialFunction[PackageId, PackageSignature]) {
private[lf] class PackageInterface(signatures: PartialFunction[PackageId, PackageSignature]) {
import Interface._
import PackageInterface._
private[this] def lookupPackage(
pkgId: PackageId,
@ -263,12 +263,12 @@ private[lf] class Interface(signatures: PartialFunction[PackageId, PackageSignat
}
object Interface {
object PackageInterface {
val Empty = new Interface(PartialFunction.empty)
val Empty = new PackageInterface(PartialFunction.empty)
def apply(packages: Map[PackageId, Package]): Interface =
new Interface(Util.toSignatures(packages))
def apply(packages: Map[PackageId, Package]): PackageInterface =
new PackageInterface(Util.toSignatures(packages))
case class DataRecordInfo(
dataType: DDataType,

View File

@ -16,7 +16,7 @@ import com.daml.lf.speedy.SResult._
import com.daml.lf.speedy.SExpr.LfDefRef
import com.daml.lf.validation.Validation
import com.daml.lf.testing.parser
import com.daml.lf.language.{Interface, LanguageVersion => LV}
import com.daml.lf.language.{PackageInterface, LanguageVersion => LV}
import java.io.{File, PrintWriter, StringWriter}
import java.nio.file.{Path, Paths}
import java.io.PrintStream
@ -156,7 +156,7 @@ object Repl {
def cmdValidate(state: State): (Boolean, State) = {
val (validationResults, validationTime) = time(state.packages.map { case (pkgId, pkg) =>
Validation.checkPackage(Interface(state.packages), pkgId, pkg)
Validation.checkPackage(PackageInterface(state.packages), pkgId, pkg)
})
System.err.println(s"${state.packages.size} package(s) validated in $validationTime ms.")
validationResults collectFirst { case Left(e) =>
@ -428,7 +428,7 @@ object Repl {
def speedyCompile(state: State, args: Seq[String]): Unit = {
val defs = assertRight(
Compiler.compilePackages(
Interface(state.packages),
PackageInterface(state.packages),
state.packages,
state.scenarioRunner.compilerConfig,
)

View File

@ -12,7 +12,7 @@ import scala.Ordering.Implicits.infixOrderingOps
private[validation] object DependencyVersion {
@throws[ValidationError]
def checkPackage(interface: language.Interface, pkgId: PackageId, pkg: Package): Unit =
def checkPackage(interface: language.PackageInterface, pkgId: PackageId, pkg: Package): Unit =
for {
depPkgId <- pkg.directDeps
depPkg = Util.handleLookup(NoContext, interface.lookupPackage(depPkgId))

View File

@ -5,7 +5,7 @@ package com.daml.lf.validation
import com.daml.lf.data.Ref.PackageId
import com.daml.lf.language.Ast._
import com.daml.lf.language.Interface
import com.daml.lf.language.PackageInterface
import com.daml.lf.validation.iterable.ExprIterable
private[validation] object PartyLiterals {
@ -13,7 +13,7 @@ private[validation] object PartyLiterals {
import Util.handleLookup
@throws[EForbiddenPartyLiterals]
def checkModule(interface: Interface, pkgId: PackageId, module: Module): Unit = {
def checkModule(interface: PackageInterface, pkgId: PackageId, module: Module): Unit = {
module.definitions.foreach {
case (defName, DValue(typ @ _, noPartyLiterals, body, isTest @ _)) =>
def context = ContextDefValue(pkgId, module.name, defName)
@ -29,7 +29,7 @@ private[validation] object PartyLiterals {
}
}
private def checkExpr(interface: Interface, context: => Context, expr: Expr): Unit =
private def checkExpr(interface: PackageInterface, context: => Context, expr: Expr): Unit =
expr match {
case EPrimLit(party: PLParty) =>
throw EForbiddenPartyLiterals(context, PartyLiteral(party.value))

View File

@ -6,7 +6,7 @@ package com.daml.lf.validation
import com.daml.lf.data.ImmArray
import com.daml.lf.data.Ref.{Identifier, PackageId, QualifiedName}
import com.daml.lf.language.Ast._
import com.daml.lf.language.{LanguageVersion, Interface}
import com.daml.lf.language.{LanguageVersion, PackageInterface}
private[validation] object Serializability {
@ -14,7 +14,7 @@ private[validation] object Serializability {
case class Env(
languageVersion: LanguageVersion,
interface: Interface,
interface: PackageInterface,
ctx: Context,
requirement: SerializabilityRequirement,
typeToSerialize: Type,
@ -99,7 +99,7 @@ private[validation] object Serializability {
def checkDataType(
version: LanguageVersion,
interface: Interface,
interface: PackageInterface,
tyCon: TTyCon,
params: ImmArray[(TypeVarName, Kind)],
dataCons: DataCons,
@ -126,7 +126,7 @@ private[validation] object Serializability {
// in particular choice argument types and choice return types are of kind KStar
def checkTemplate(
version: LanguageVersion,
interface: Interface,
interface: PackageInterface,
tyCon: TTyCon,
template: Template,
): Unit = {
@ -141,14 +141,14 @@ private[validation] object Serializability {
def checkException(
version: LanguageVersion,
interface: Interface,
interface: PackageInterface,
tyCon: TTyCon,
): Unit = {
val context = ContextDefException(tyCon.tycon)
Env(version, interface, context, SRExceptionArg, tyCon).checkType()
}
def checkModule(interface: Interface, pkgId: PackageId, module: Module): Unit = {
def checkModule(interface: PackageInterface, pkgId: PackageId, module: Module): Unit = {
val version = handleLookup(NoContext, interface.lookupPackage(pkgId)).languageVersion
module.definitions.foreach {
case (defName, DDataType(serializable, params, dataCons)) =>

View File

@ -7,7 +7,7 @@ import com.daml.lf.data.{ImmArray, Numeric, Struct}
import com.daml.lf.data.Ref._
import com.daml.lf.language.Ast._
import com.daml.lf.language.Util._
import com.daml.lf.language.{LanguageVersion, Interface}
import com.daml.lf.language.{LanguageVersion, PackageInterface}
import com.daml.lf.validation.AlphaEquiv._
import com.daml.lf.validation.Util._
import com.daml.lf.validation.iterable.TypeIterable
@ -256,7 +256,7 @@ private[validation] object Typing {
case PCUnit => TUnit
}
def checkModule(interface: Interface, pkgId: PackageId, mod: Module): Unit = {
def checkModule(interface: PackageInterface, pkgId: PackageId, mod: Module): Unit = {
val langVersion = handleLookup(NoContext, interface.lookupPackage(pkgId)).languageVersion
mod.definitions.foreach {
case (dfnName, DDataType(_, params, cons)) =>
@ -314,7 +314,7 @@ private[validation] object Typing {
case class Env(
languageVersion: LanguageVersion,
interface: Interface,
interface: PackageInterface,
ctx: Context,
tVars: Map[TypeVarName, Kind] = Map.empty,
eVars: Map[ExprVarName, Type] = Map.empty,

View File

@ -6,7 +6,7 @@ package validation
import com.daml.lf.data.Ref.PackageId
import com.daml.lf.language.Ast._
import com.daml.lf.language.Interface
import com.daml.lf.language.PackageInterface
object Validation {
@ -19,19 +19,19 @@ object Validation {
def checkPackages(pkgs: Map[PackageId, Package]): Either[ValidationError, Unit] =
runSafely {
val interface = Interface(pkgs)
val interface = PackageInterface(pkgs)
pkgs.foreach { case (pkgId, pkg) => unsafeCheckPackage(interface, pkgId, pkg) }
}
def checkPackage(
interface: Interface,
interface: PackageInterface,
pkgId: PackageId,
pkg: Package,
): Either[ValidationError, Unit] =
runSafely(unsafeCheckPackage(interface, pkgId, pkg))
private def unsafeCheckPackage(
interface: Interface,
interface: PackageInterface,
pkgId: PackageId,
pkg: Package,
): Unit = {
@ -42,14 +42,14 @@ object Validation {
}
private[lf] def checkModule(
interface: Interface,
interface: PackageInterface,
pkgId: PackageId,
module: Module,
): Either[ValidationError, Unit] =
runSafely(unsafeCheckModule(interface, pkgId, module))
private def unsafeCheckModule(
interface: Interface,
interface: PackageInterface,
pkgId: PackageId,
mod: Module,
): Unit = {

View File

@ -71,13 +71,13 @@ class DependencyVersionSpec extends AnyWordSpec with TableDrivenPropertyChecks w
forEvery(negativeTestCases) { pkgs =>
pkgs.foreach { case (pkgId, pkg) =>
DependencyVersion.checkPackage(language.Interface(pkgs), pkgId, pkg)
DependencyVersion.checkPackage(language.PackageInterface(pkgs), pkgId, pkg)
}
}
forEvery(postiveTestCase) { case ((pkgdId, _), pkgs) =>
an[EModuleVersionDependencies] should be thrownBy
DependencyVersion.checkPackage(language.Interface(pkgs), pkgdId, pkgs(pkgdId))
DependencyVersion.checkPackage(language.PackageInterface(pkgs), pkgdId, pkgs(pkgdId))
}
}

View File

@ -145,7 +145,7 @@ class PartyLiteralsSpec extends AnyWordSpec with TableDrivenPropertyChecks with
"PositiveTestCase8",
)
val interface = language.Interface(Map(defaultPackageId -> pkg))
val interface = language.PackageInterface(Map(defaultPackageId -> pkg))
checkModule(
interface,

View File

@ -348,7 +348,7 @@ class SerializabilitySpec extends AnyWordSpec with TableDrivenPropertyChecks wit
"""
private val defaultInterface = interface(defaultPkg)
private def interface(pkg: Package) = language.Interface(Map(defaultPackageId -> pkg))
private def interface(pkg: Package) = language.PackageInterface(Map(defaultPackageId -> pkg))
private def check(pkg: Package, modName: String): Unit = {
val w = interface(pkg)

View File

@ -5,7 +5,7 @@ package com.daml.lf.validation
import com.daml.lf.data.Ref.DottedName
import com.daml.lf.language.Ast._
import com.daml.lf.language.{Interface, LookupError, Reference, LanguageVersion => LV}
import com.daml.lf.language.{PackageInterface, LookupError, Reference, LanguageVersion => LV}
import com.daml.lf.testing.parser.Implicits._
import com.daml.lf.testing.parser.{defaultLanguageVersion, defaultPackageId}
import com.daml.lf.validation.SpecUtil._
@ -1045,7 +1045,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
)
def checkModule(pkg: Package, modName: String) = Typing.checkModule(
Interface(Map(defaultPackageId -> pkg)),
PackageInterface(Map(defaultPackageId -> pkg)),
defaultPackageId,
pkg.modules(DottedName.assertFromString(modName)),
)
@ -1115,7 +1115,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
"""
def checkModule(pkg: Package, modName: String) = Typing.checkModule(
Interface(Map(defaultPackageId -> pkg)),
PackageInterface(Map(defaultPackageId -> pkg)),
defaultPackageId,
pkg.modules(DottedName.assertFromString(modName)),
)
@ -1144,7 +1144,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
"""
val mod = pkg.modules(DottedName.assertFromString("TypeVarShadowing2"))
Typing.checkModule(Interface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
Typing.checkModule(PackageInterface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
}
"expand type synonyms correctly" in {
@ -1208,7 +1208,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
def checkModule(mod: Module) = {
val pkg = Package.apply(List(mod), List.empty, defaultLanguageVersion, None)
Typing.checkModule(Interface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
Typing.checkModule(PackageInterface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
}
val negativeTestCases = Table(
@ -1230,7 +1230,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
def checkModule(mod: Module) = {
val pkg = Package.apply(List(mod), List.empty, defaultLanguageVersion, None)
Typing.checkModule(Interface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
Typing.checkModule(PackageInterface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
}
val negativeTestCases = Table(
@ -1252,7 +1252,7 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
def checkModule(mod: Module) = {
val pkg = Package.apply(List(mod), List.empty, defaultLanguageVersion, None)
Typing.checkModule(Interface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
Typing.checkModule(PackageInterface(Map(defaultPackageId -> pkg)), defaultPackageId, mod)
}
val negativeTestCases = Table(
@ -1324,6 +1324,6 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher
"""
private val env =
Typing.Env(LV.default, Interface(Map(defaultPackageId -> pkg)), NoContext)
Typing.Env(LV.default, PackageInterface(Map(defaultPackageId -> pkg)), NoContext)
}

View File

@ -30,7 +30,7 @@ import com.daml.lf.engine.script.ledgerinteraction.{
import com.daml.lf.iface.EnvironmentInterface
import com.daml.lf.iface.reader.InterfaceReader
import com.daml.lf.language.Ast._
import com.daml.lf.language.{Interface, LanguageVersion}
import com.daml.lf.language.{PackageInterface, LanguageVersion}
import com.daml.lf.interpretation.{Error => IE}
import com.daml.lf.speedy.SBuiltin.SBToAny
import com.daml.lf.speedy.SExpr._
@ -352,7 +352,7 @@ private[lf] class Runner(
override def getDefinition(dref: SDefinitionRef): Option[SDefinition] =
fromLedgerValue.andThen(Some(_)).applyOrElse(dref, compiledPackages.getDefinition)
// FIXME: avoid override of non abstract method
override def interface: Interface = compiledPackages.interface
override def interface: PackageInterface = compiledPackages.interface
override def packageIds: collection.Set[PackageId] = compiledPackages.packageIds
// FIXME: avoid override of non abstract method
override def definitions: PartialFunction[SDefinitionRef, SDefinition] =

View File

@ -13,7 +13,7 @@ import com.google.protobuf.ByteString
import scala.jdk.CollectionConverters._
import scala.Ordering.Implicits._
final class TypedValueExtractor(interface: language.Interface) {
final class TypedValueExtractor(interface: language.PackageInterface) {
private[this] def handleLookup[X](lookup: => Either[language.LookupError, X]) =
lookup match {

View File

@ -16,7 +16,7 @@ private[replay] final class Adapter(
pkgLangVersion: Ref.PackageId => LanguageVersion,
) {
private val interface = com.daml.lf.language.Interface(packages)
private val interface = com.daml.lf.language.PackageInterface(packages)
def adapt(tx: Tx.Transaction): SubmittedTransaction =
tx.foldWithPathState(TxBuilder(pkgLangVersion), Option.empty[NodeId])(