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

SimpleClassDiagrams diamond inheritance #147

Open
joeriexelmans opened this issue Oct 31, 2022 · 2 comments
Open

SimpleClassDiagrams diamond inheritance #147

joeriexelmans opened this issue Oct 31, 2022 · 2 comments

Comments

@joeriexelmans
Copy link

While multiple inheritance is supported in the SimpleClassDiagrams formalism, creating an instance that has diamond inheritance gives an error "500:constraint (post-create noInheritanceLoops) failed".

image

Is this intended behavior?

  • If so, we must make it explicit that diamond inheritance is not allowed.
  • Otherwise, the constraint checking function should be fixed to allow this.

The constraint checking function is currently as follows:

var mm      = '/Formalisms/__LanguageSyntax__/SimpleClassDiagram/SimpleClassDiagram/',
    nout    = getNeighbors('>',mm+'Class'),
    visited = [];
function dfs(to_visit)
{
    var curr = to_visit.pop();
    if( curr == undefined )
        return true;
    else if( visited.indexOf(curr) > -1 )
        return false;
    else
    {
        visited.push(curr);
        var ntype = (getAttr('$type',curr) == mm+'Class' ? 
                    mm+'Inheritance' : mm+'Class');
        return dfs( to_visit.concat(getNeighbors('>',ntype,curr)) );
    }
}
dfs(nout);
@BentleyJOakes
Copy link
Member

Thanks for the report Joeri.

My concern is that if diamond inheritance was allowed, that AToMPM would be able to correctly handle the inheritance of attributes. Not even the usual problem of resolving conflicts, but also just making sure that all attributes are properly inherited if there is more than one super-class.

Is this a blocker for you? For now, it would be best to create a third class between those two which inherits from AbstractSegment and has the attributes of the others, set manually.

Perhaps in the future we can relax this check and go through the tests to see if anything else needs updating.

@joeriexelmans
Copy link
Author

Not a blocker. I asked my students to think of a workaround :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants