daml/language-support
Stephen Compall 4c1b4842f4
generic exerciseArchive for Java codegen (#17113)
* exerciseArchive(Archive) was skipped before by the flattening rules
  because Archive is defined in a separate package. By flattening across
  packages in this PR, Archive is now a valid candidate.

* The new Exercises.Archive interface is a superinterface of most
  generated exercise* method sets, and therefore generated ContractIds,
  CreateAnds, and ByKeys, giving a LUB to different contract types that
  contains the exerciseArchive method.

  - This is most, not all, because the Daml-LF rules determine what
    codegen ought to do, and Daml-LF does not mandate an Archive method
    of any kind, never mind one in the exact shape that we happen to
    generate.

  - If an Archive is present, and it has an empty record as its
    parameter and Unit as its result type, then we can safely assume
    that the exerciseArchive method is sensible to include in the type.

  - However, this still excludes the generic ContractId type, because
    generic ContractId does not have enough data to generate a
    Daml-LF-correct Archive command given the unknowns mentioned
    above. So we simply exclude it from the type instead of guessing the
    argument and hoping the guess is close enough. That's why the
    Exercises.Archive type is available to users who want access to the
    method, which is a supertype of codegenned contract IDs among other
    things mentioned above:

      SimpleTemplate.ContractId cid = new SimpleTemplate.ContractId("id"); 
      Exercises.Archive<?> wideCid = cid; 
      assertEquals( 
       wideCid.exerciseArchive().commands(),
       cid.exerciseArchive(new Archive()).commands());
2023-07-18 09:52:16 -04:00
..
codegen-common Upgrade toxiproxy-java, circe, spray-json, spray-json-derived-codecs versions. (#15949) 2023-01-24 17:05:57 +00:00
codegen-main bump copyright (#16002) 2023-01-04 18:21:15 +01:00
hs/bindings canton: allow depending on arbitrary sha (#16926) 2023-06-01 15:06:35 +00:00
java generic exerciseArchive for Java codegen (#17113) 2023-07-18 09:52:16 -04:00
scala Clean up ledger dependencies (#16894) 2023-05-23 13:44:17 +00:00
ts Move CatonFixture in its own bazel module (#16824) 2023-05-10 23:15:26 +00:00