Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-model, mixin member apply bug #2378

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

kstich
Copy link
Contributor

@kstich kstich commented Aug 23, 2024

On first load, via sources, there's a DefineShape LoadOperation with an ApplyMixin modifier. There's also a pending @apply statement in the LoaderTraitMap. 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 LoadOperations to be assembled. The shape's LoadOperations already exist in the map and a new DefineShape load operation is added that also has the ApplyMixin 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 that DefineShape contain the member where the trait is applied and add it. However, because we have two LoadOperations - 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 second LoadOperation, because it does not have the member. But, because we applied it somewhere, the trait is no longer unclaimed. When then later resolving the ApplyMixin 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.

@kstich kstich requested a review from a team as a code owner August 23, 2024 15:56
@kstich kstich force-pushed the mixin_apply_double_build_fix branch from c23c172 to 90713dc Compare August 23, 2024 19:13
On first load, via sources, there's a `DefineShape` `LoadOperation`
with an `ApplyMixin` modifier. There's also a pending `@apply`
statement in the `LoaderTraitMap`. 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's `LoadOperations` already exist in the map and a new
`DefineShape` load operation is added that also has the `ApplyMixin`
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 that `DefineShape` contain
the member where the trait is applied and add it. However, because
we have **two** `LoadOperations` - 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 second `LoadOperation`, because it
does not have the member. But, because we applied it somewhere, the
trait is no longer unclaimed. When then later resolving the
`ApplyMixin` 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 apply the mixin.
@kstich kstich force-pushed the mixin_apply_double_build_fix branch from 90713dc to b810ef8 Compare August 23, 2024 19:58
@kstich kstich merged commit 5752a2b into main Aug 26, 2024
14 checks passed
@kstich kstich deleted the mixin_apply_double_build_fix branch August 26, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants