corda / samples

This repository has been deprecated. Please use the links in the README to access the new repositories.
98 stars 150 forks source link

[CORDA-3082] Fix a build issue relating to a type inference limitation #55

Closed JamesHR3 closed 5 years ago

JamesHR3 commented 5 years ago

A change introduced by https://r3-cev.atlassian.net/browse/CID-878 has exposed a type inference limitation in the compiler that is unfortunately hit by one of our samples. CID-878 introduces a Destination interface that is implemented by both AnonymousParty and Party. Both of these subclass AbstractParty. The sample in question uses a variable that is conditionally one of AnonymousParty or Party, depending on whether a flag is set. This variable is only used as an AbstractParty. Without the extra Destination interface, the compiler can infer this with no further annotation, however the addition of this interface confuses the compiler and causes it to treat the variable as Any - which then breaks when an attempt is made to use it as an AbstractParty.

This fix adds just enough type annotations to convince the compiler that the variable is in fact an AbstractParty.

gendal commented 5 years ago

Hi James - is this predominantly a special case unique to the sample? Or a sign that this change may break a nontrivial number of apps out there in the wild? (I think I saw some discussion on Slack but asking here for posterity)

anthonykeenan commented 5 years ago

We don't believe it is a special case, @shamsasari had to make several changes to the samples in Corda to make them compile after the change, I suspect while not an API break in the 'traditional' sense, it will confuse our users, if we can mitigate it (relatively simply) within Corda then that might be a better solution.

JamesHR3 commented 5 years ago

It's not a special case in the sense that it's something an app developer might reasonably want to do - allow someone to decide whether they want to be anonymous, and to use either AnonymousParty or Party accordingly. I think what makes this tricky is that whether an app developer hits the problem depends entirely on how the app developer structures their code. It's plausible therefore that someone could hit this in the wild.

gendal commented 5 years ago

ok - thanks... sounds like we need to fix the feature then if we're breaking legitimate apps :(

anthonykeenan commented 5 years ago

Closing as this as fix to be done in Corda

JamesHR3 commented 5 years ago

Re-opening following the conversation on CORDA-3082.