Closed S11001001 closed 2 years ago
static forwarder on the codegenned ContractId classes
I am making ContractId
A static forwarder in Scala is some generated code (for convenience) that provides Java users access to methods on a Scala object. this makes it possible for Java users to just call SomeObject.foo
on class SomeObject
where foo is a static method, instead of going through SomeObject$.MODULE$.foo
(I think that is what @S11001001 is referring to, though conceptually).
So in this case the generated ContractId
class should get a static method that calls the ContractCompanion utility method.
Thanks, based on your information, I believe the "static forwarder" is referring to this
In Scala codegen,
ContractId[T] = T.ContractId
. However, in Java codegen,T.ContractId <: ContractId<T>
but not vice versa, which means that(cidT: ContractId<T>).exerciseX(...)
doesn't work, and((T.ContractId) cidT)
can fail too.illTyped
, and that a decoded-from-ValueContractId<T>
may not even beinstanceof T.ContractId
ContractId<T> => T.ContractId
utility forContractCompanion
, with a static forwarder on the codegennedContractId
classesIt's also possible that we can get
((T.ContractId) cidT)
to work, but would require a significant redesign of the decoder path. #14313Example
fromValue
illustrating the problem: