Add type parameter to MergingRun to limit possible merge types #573
+162
−81
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.
Description
This is just a phantom type parameter, the
Merge
inside still stores a generalMergeType
which is not statically guaranteed to be part of the restricted type. We can also go all the way, but then we get the type parameter andIsMergeType
constraints in a lot of places, e.g. onMerge.steps
and theNoThunks
instances (which get quite a bit more cumbersome). So I decided against it for now, but I'm happy to revisit that choice.Snapshots can always encode the full
MergeType
. At first I decided to do the partial conversion infromSnapIncomingRun
, potentially throwing an exception (first commit). Later I switched it to failing indecodeVersioned
, which makes the serialisation code less mechanical, but seems to fit into our error handling better. I'm open to both solutions, so let me know if you have a preference.