-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
non-reflective abstractions for Java codegen Contracts #13724
Conversation
…va-codegen-contract-abstract-methods
CHANGELOG_BEGIN - [daml codegen js] Generated templates have types, inherited methods, and a new static ``COMPANION`` that enable writing more template-generic utilities directly in Java. See `issue #13724 <https://github.com/digital-asset/daml/pull/13724>`__. CHANGELOG_END
...port/java/bindings/src/main/java/com/daml/ledger/javaapi/data/codegen/ContractCompanion.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a blocker to make sure a few important points don't go unaddressed:
- If a client changes a Daml model, upgrades to a new version where this PR got merged and re-generates code purely with the intent of generating code for the changed Daml models, will existing client code cease to compile, raise compilation warnings or change runtime behavior?
- How does this feature interact with the decoder class? Is there a change in approach enabled by this change?
- This adds a new feature and/or changes the way in which an existing feature can be changed: is this sufficiently documented to enable users to start using this independently after going through the documentation?
@stefanobaghino-da Their code may fail
No.
Not in this PR.
Yes, discussed in #13768.
A user who is motivated to build the kinds of template-generic functions this PR enables should find all they need to know in the type signatures, with the understanding that they are just like the static methods of the same signature. If we were happy with the documentation of |
Please add this consideration to the change log so that the release coordinator can be aware of this. It's very important that we minimize the impact of changes and give a clear explanation on how to migrate if there is an impact. I'll remove my blocker in light of your replies. Thanks. |
Concerns addressed in #13724 (comment)
CHANGELOG_BEGIN - [daml codegen js] Generated templates have types, inherited methods, and a new static ``COMPANION`` that enable writing more template-generic utilities directly in Java. New classes ``Contract``, ``ContractWithKey``, and ``ContractCompanion``, have been introduced; if you are importing ``com.daml.ledger.javaapi.data.codegen.*`` and have imported classes with these names from any other package, these references will stop working; use individual imports instead. See `issue #13724 <https://github.com/digital-asset/daml/pull/13724>`__. CHANGELOG_END
…va-codegen-contract-abstract-methods
- suggested by @ray-roestenburg-da; thanks
Fixes #13471.
readActiveContractKeys
andreadActiveContractPayloads
are simple examples of functions that would not have been possible to write before.ContractId
andContract
COMPANION
as a now-and-future home for well-typed abstractions over things that are currently just static methodsEta-expanding static methods into functions works for many use cases. But it doesn't really let us build stuff on top of those methods once, without "infectious codegen". An example is the new
fromCreatedEvent
: this method is now hand-written, with only static forwarding shims codegenned.Other things can usefully be moved into
ContractCompanion
and its signature and hierarchy usefully expanded.fromValue
is a really good candidate. But this PR is doing quite enough.Contract
vsContractWithKey
more likeContractCompanion.WithoutKey
vsContractCompanion.WithKey
?ContractCompanion
TemplateCompanion
instead, as with Scala codegen?