Fix interface method calls #40
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Interface method calls must be treated specially since they may transition.
Previously, interface method calls would trigger runtime ownership violations in state machines that make use of state contexts, if the called method triggers a transition.
More generally, if an interface method call transitions, we should not continue to execute the handler that called the method for the same reasons that we determined simple transition statements should terminate a handler. Namely, because the state machine will be in an inconsistent state (i.e. no longer the state that the handler exists in), and because it opens up the door for double transitions.
The current solution resolves the ownership issue and conservatively terminates the current handler after any interface method call.
It would be possible to adopt a more liberal approach by tracking the execution of a handler more precisely, but this would require embedding some logic in the generated code and would make handlers harder to reason about.
This PR also fixes a naming issue related to interface method calls, and adds several tests of interface method calls.