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

ST6RI-751 References to result parameters, subject parameters and objectives do not always resolve correctly #552

Merged
merged 5 commits into from
Mar 17, 2024

Conversation

seidewitz
Copy link
Member

@seidewitz seidewitz commented Mar 16, 2024

Currently, there are three cases in which elements are still being physically added to the parse tree (rather than cached in adapters like is done for implicit relationships), when they are not declared explicitly in a model: result parameters for expressions, subject parameters for requirements and cases and objectives for cases. This is not actually called for in the specifications, but is still necessary in order for implied redefinitions to be added correctly in the case of multiple specializations.

For example, in the following model:

analysis def A {
    subject s;
    objective o;
    return r;
}
part context {
    part p {
        s = a.s;
        o = a.o;
        r = a.r;
    }
    analysis a : A {
      // subject added that redefines s.
      // objective added that redefines o.
      // return parameter added that redefines r.
    }
}

subject, objective and result features are added to the parse tree for the analysis case usage a. These features implicitly redefine the corresponding features s, o and r from the analysis case definition A. Because of these redefinitions, the references to s, o and r within part usage p should resolve to the features of the usage a.

This PR fixes a bug that could result in these references incorrectly resolving to the features of the definition A when the declaration of a is lexically after the declaration of p. It also moves utility methods related to subjects and objectives out of class TypeUtil into the SysML-specific class UsageUtil.

- Also updated TypeUtil::getResultParameterOf to add a result parameter
as necessary and then always return the owned result parameter.
- Refactored the adding of return parameters into this mechanism.
- Updated KerMLScope name resolution to ensure additional members are
added before searching the owned memberships of a namespace.
@seidewitz seidewitz requested a review from himi March 16, 2024 18:29
@seidewitz seidewitz self-assigned this Mar 16, 2024
@seidewitz seidewitz added this to the 2024-03 milestone Mar 16, 2024
Copy link
Member

@himi himi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I confirmed all of the feature chains properly redefine the features in a in your example.

@seidewitz seidewitz merged commit fa4900c into master Mar 17, 2024
2 checks passed
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