Closed S11001001 closed 2 years ago
Since we are renaming and we can still break: prepending unsafe
to a method that could throw is not a common pattern in Java. I propose to:
UnimplementedInterfaceException
which can be used to report information about the errorunsafeFromIfc(...)
into fromInterface(...) throws UnimplementedInterfaceException
@stefanobaghino-da unsafeFromInterface
does not exist in cases where a template doesn't implement an interface, so there is never cause to throw such an exception. This is "unsafe" because we are coercing from interface-contract-ID to template-contract-ID, which we cannot check locally.
@stefanobaghino-da
unsafeFromInterface
does not exist in cases where a template doesn't implement an interface, so there is never cause to throw such an exception. This is "unsafe" because we are coercing from interface-contract-ID to template-contract-ID, which we cannot check locally.
Does that throw an exception? Under what circumstances?
Does that throw an exception? Under what circumstances?
No, it doesn't.
Foo.ContractId z = // ...
var bcid = Bar.ContractId.unsafeFromInterface(
z.toInterface(some.SharedIface.INTERFACE));
bcid.exerciseSomeBarChoice(...); // submitting this exercise will fail
I see, thanks!
Design from https://github.com/digital-asset/daml/issues/13668#issuecomment-1106899636 . For this part:
codegen.InterfaceCompanion
INTERFACE
final subclass ofInterfaceCompanion
as static inner class of each interface, package-private ctor, singleton instance also namedINTERFACE
.toIfc()
with.toInterface(pkg.Ifc.INTERFACE marker)
.unsafeFromIfc(...)
to.unsafeFromInterface(...)