mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
LF: Test scala interface type checking (#11833)
CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
5f52f00afb
commit
86da6e8eef
@ -340,7 +340,7 @@ private[parser] class ExprParser[P](parserParameters: ParserParameters[P]) {
|
||||
)
|
||||
|
||||
private lazy val eCallInterface: Parser[ECallInterface] =
|
||||
`icall` ~! `@` ~> fullIdentifier ~ id ~ expr0 ^^ { case ifaceId ~ name ~ body =>
|
||||
`call_method` ~! `@` ~> fullIdentifier ~ id ~ expr0 ^^ { case ifaceId ~ name ~ body =>
|
||||
ECallInterface(interfaceId = ifaceId, methodName = name, value = body)
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ private[parser] object Lexer extends RegexParsers {
|
||||
"catch" -> `catch`,
|
||||
"to_interface" -> `to_interface`,
|
||||
"from_interface" -> `from_interface`,
|
||||
"icall" -> `icall`,
|
||||
"call_method" -> `call_method`,
|
||||
)
|
||||
|
||||
val token: Parser[Token] =
|
||||
|
@ -53,7 +53,7 @@ private[parser] object Token {
|
||||
case object `catch` extends Token
|
||||
case object `to_interface` extends Token
|
||||
case object `from_interface` extends Token
|
||||
case object `icall` extends Token
|
||||
case object `call_method` extends Token
|
||||
|
||||
final case class Id(s: String) extends Token
|
||||
final case class ContractId(s: String) extends Token
|
||||
|
@ -332,9 +332,9 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
|
||||
EFromAnyException(E, e"anyException"),
|
||||
"throw @Unit @Mod:E exception" ->
|
||||
EThrow(TUnit, E, e"exception"),
|
||||
"icall @Mod:I method body" ->
|
||||
"call_method @Mod:I method body" ->
|
||||
ECallInterface(I.tycon, n"method", e"body"),
|
||||
"icall @'-pkgId-':Mod:I method body" ->
|
||||
"call_method @'-pkgId-':Mod:I method body" ->
|
||||
ECallInterface(I.tycon, n"method", e"body"),
|
||||
"to_interface @Mod:T @Mod:I body" ->
|
||||
EToInterface(T.tycon, I.tycon, e"body"),
|
||||
@ -762,10 +762,10 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
|
||||
method asParty: Party;
|
||||
method getName: Text;
|
||||
choice Sleep (self) (u:Unit) : ContractId Mod:Person
|
||||
, controllers Cons @Party [icall @Mod:Person asParty this] (Nil @Party)
|
||||
, controllers Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)
|
||||
to upure @(ContractId Mod:Person) self;
|
||||
choice @nonConsuming Nap (self) (i : Int64): Int64
|
||||
, controllers Cons @Party [icall @Mod:Person asParty this] (Nil @Party)
|
||||
, controllers Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)
|
||||
, observers Nil @Party
|
||||
to upure @Int64 i;
|
||||
} ;
|
||||
@ -785,7 +785,7 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
|
||||
n"Sleep" -> TemplateChoice(
|
||||
name = n"Sleep",
|
||||
consuming = true,
|
||||
controllers = e"Cons @Party [icall @Mod:Person asParty this] (Nil @Party)",
|
||||
controllers = e"Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)",
|
||||
choiceObservers = None,
|
||||
selfBinder = n"self",
|
||||
argBinder = n"u" -> TUnit,
|
||||
@ -795,7 +795,7 @@ class ParsersSpec extends AnyWordSpec with ScalaCheckPropertyChecks with Matcher
|
||||
n"Nap" -> TemplateChoice(
|
||||
name = n"Nap",
|
||||
consuming = false,
|
||||
controllers = e"Cons @Party [icall @Mod:Person asParty this] (Nil @Party)",
|
||||
controllers = e"Cons @Party [call_method @Mod:Person asParty this] (Nil @Party)",
|
||||
choiceObservers = Some(e"Nil @Party"),
|
||||
selfBinder = n"self",
|
||||
argBinder = n"i" -> TInt64,
|
||||
|
@ -456,12 +456,10 @@ private[validation] object Typing {
|
||||
def checkDefIface(ifaceName: TypeConName, iface: DefInterface): Unit =
|
||||
iface match {
|
||||
case DefInterface(param, fixedChoices, methods, precond) =>
|
||||
fixedChoices.values.foreach(
|
||||
introExprVar(param, TTyCon(ifaceName)).checkChoice(ifaceName, _)
|
||||
)
|
||||
methods.values.foreach(checkIfaceMethod)
|
||||
val env = introExprVar(param, TTyCon(ifaceName))
|
||||
env.checkExpr(precond, TBool)
|
||||
methods.values.foreach(checkIfaceMethod)
|
||||
fixedChoices.values.foreach(env.checkChoice(ifaceName, _))
|
||||
}
|
||||
|
||||
def checkIfaceMethod(method: InterfaceMethod): Unit = {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,20 +44,21 @@
|
||||
- ensure expression forms have the correct type: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L107)
|
||||
- ill-formed create command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L133)
|
||||
- ill-formed create-and-exercise command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L154)
|
||||
- ill-formed exception definitions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1054)
|
||||
- ill-formed exception definitions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1409)
|
||||
- ill-formed exercise command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L138)
|
||||
- ill-formed exercise-by-key command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L145)
|
||||
- ill-formed expressions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L408)
|
||||
- ill-formed expressions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L422)
|
||||
- ill-formed fetch command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L167)
|
||||
- ill-formed fetch-by-key command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L170)
|
||||
- ill-formed interfaces are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1302)
|
||||
- ill-formed kinds are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L19)
|
||||
- ill-formed lookup command is rejected: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L175)
|
||||
- ill-formed records are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1196)
|
||||
- ill-formed templates are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L815)
|
||||
- ill-formed type synonyms applications are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1175)
|
||||
- ill-formed type synonyms definitions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1242)
|
||||
- ill-formed records are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1551)
|
||||
- ill-formed templates are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L930)
|
||||
- ill-formed type synonyms applications are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1530)
|
||||
- ill-formed type synonyms definitions are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1597)
|
||||
- ill-formed types are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L99)
|
||||
- ill-formed variants are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1219)
|
||||
- ill-formed variants are rejected: [TypingSpec.scala](daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala#L1574)
|
||||
- well formed create command is accepted: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L79)
|
||||
- well formed create-and-exercise command is accepted: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L98)
|
||||
- well formed exercise command is accepted: [CommandPreprocessorSpec.scala](daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/CommandPreprocessorSpec.scala#L84)
|
||||
|
Loading…
Reference in New Issue
Block a user