Fix multi-model, mixin member apply bug #2378
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.
On first load, via sources, there's a
DefineShape
LoadOperation
with anApplyMixin
modifier. There's also a pending@apply
statement in theLoaderTraitMap
. When the source is assembled, that's fully resolved, the mixin is merged into the shape, then traits applied to mixed content are applied. This is a valid source model that has the trait applied to the mixed member.The import is then broken out into
LoadOperation
s to be assembled. The shape'sLoadOperations
already exist in the map and a newDefineShape
load operation is added that also has theApplyMixin
modifier. The first, already fully mixed applied and built - the second, unmixed and unapplied.When we go to
applyTraitsToNonMixinsInShapeMap
on the import pass, we detect if any of the load operations thatDefineShape
contain the member where the trait is applied and add it. However, because we have twoLoadOperations
- one with the member and one without - we apply the trait to the shape that was already mixed and applied. We do not add it to the secondLoadOperation
, because it does not have the member. But, because we applied it somewhere, the trait is no longer unclaimed. When then later resolving theApplyMixin
modifier, the trait is not applied since it has been claimed elsewhere. When building the second shape and comparing it to the first, the trait is then missing, failing out due to a conflict.This is resolved by sending traits for missing members directly in to the
ApplyMixin
modifier and merging them when we apply the mixin.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.