Skip to content

Conversation

seidewitz
Copy link
Member

This PR resolves an anomaly in the resolution of the name of a redefined feature due to certain forms of diamond specialization. This anomaly was because the name resolution algorithm (in org.omg.kerml.xtext.scoping.KerMLScope) traverses the specialization hierarchy without using the derived property computation of inherited memberships, but it was not updated when the inherited membership computation was revised to handle multiply inherited redefinitions per the specification.

Problem

Consider the following KerML model:

classifier A {
    feature f;
}

classifier B specializes A {
    feature redefines f {
	      feature g;
    }
}

classifier C specializes A, B {
    feature subsets f {
	      feature redefines g; // ERROR: Couldn't resolve reference to Feature 'g'.
    }
}

Previously, this model generated the indicated error, because the name resolution algorithm traversed specializations in order, stopping if it found a resolution for the name. Thus, since C specializes A before B, the feature f inherited by C was A::f, which does not include the nested feature g. But, if the order of the specialized types was changed from A, B to B, A, then the error would go away, because B::f was now inherited instead.

Fix

In order to remove the dependency on the order of specializations, the name resolution algorithm was updated to traverse all specializations of a type, not stopping if a resolution is found. Instead, each time a potentially resolving element is found, it is compared to the previously found resolution (if any), and if the new element is a feature that directly or indirectly redefines the old element, then the new element replaces the old one as the found resolution. Note that this means that, if there are multiple features found none of which redefine another (i.e., conflicting inherited features), the resolution algorithm still returns the first one.

Due to previous optimizations in the computation of redefined features, the update in this PR seems to have no cause no degradation in performance.

@seidewitz seidewitz added this to the 2025-08 milestone Sep 2, 2025
@seidewitz seidewitz self-assigned this Sep 2, 2025
@seidewitz seidewitz added the bug Something isn't working label Sep 2, 2025
@seidewitz seidewitz merged commit e0ac5a2 into master Sep 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants