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

Association linking attempts to instantiate abstract class #1160

Closed
TimLethbridge opened this Issue Nov 24, 2017 · 1 comment

Comments

@TimLethbridge
Member

TimLethbridge commented Nov 24, 2017

The following Umple code generates invalid code that attempts to instantiate an abstract class. This problem only occurs due to the 1 end of the association. If the multiplicity is changed to 0..1, then the problem is not present.

class A {
  // The generated method A.addMyB() tries to instantiate the abstract class B.
  1 -- 0..* B myBs;
}

class B {  abstract; }

This problem was flagged by @gmussbacher gunter.mussbacher@mcgill.ca and is a high priority for his work. He might comment further.

Potential Solution 1: Detect associations which have multiplicity 1 at one end, and an abstract class at the other and and either:
a) Disallow such associations with an error
b) Raise a warning, and treat as a 1..* (similar to the way we handle directed associations
c) Simply avoid generating such a method in this exact case only

Option c is suggested.

TimLethbridge added a commit that referenced this issue Dec 19, 2017

Merge pull request #1187 from umple/Issue1160InstantiateAbstract
Fixes #1160 wrongly instantiating abstract class

@TimLethbridge TimLethbridge reopened this Jan 26, 2018

@TimLethbridge TimLethbridge modified the milestones: Dec 2017 for release 1.27, April 2018 for release 1.28 Jan 26, 2018

@TimLethbridge

This comment has been minimized.

Show comment
Hide comment
@TimLethbridge

TimLethbridge Jan 26, 2018

Member

PR #1187, it turns out, didn't fix all cases of this problem. Additional templates need to be adjusted in the same way. This should be straightforward. But we need to find all relevant templates this time.

The user reported the following case:

class A {
  // The generated method A.addMyB() tries to instantiate the abstract class B.
  // The problem has been fixed for multiplicity * but still occurs with any multiplicity greater than 1.
  1 -- 0..2 B myBs;
}

class B {
  abstract;
}
Member

TimLethbridge commented Jan 26, 2018

PR #1187, it turns out, didn't fix all cases of this problem. Additional templates need to be adjusted in the same way. This should be straightforward. But we need to find all relevant templates this time.

The user reported the following case:

class A {
  // The generated method A.addMyB() tries to instantiate the abstract class B.
  // The problem has been fixed for multiplicity * but still occurs with any multiplicity greater than 1.
  1 -- 0..2 B myBs;
}

class B {
  abstract;
}

@TimLethbridge TimLethbridge self-assigned this Feb 1, 2018

TimLethbridge added a commit that referenced this issue Feb 3, 2018

TimLethbridge added a commit that referenced this issue Feb 3, 2018

Merge pull request #1217 from umple/Issue1160MNAssociations
Fixes #1160 two other templates that were missed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment