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

Inheritance cleanups #962

Merged
merged 5 commits into from
Feb 15, 2022
Merged

Inheritance cleanups #962

merged 5 commits into from
Feb 15, 2022

Conversation

edwardalee
Copy link
Collaborator

This PR changes the way inheritance is handled to fix two problems identified in #907.

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Looks good! I believe there are some unit tests that @housengw commented out because of the buggy behavior that is now fixed. If my recollection is correct, we should re-enable those unit tests.

@lhstrh
Copy link
Member

lhstrh commented Feb 15, 2022

Looks like my changes introduced a bug. Sorry!

*/
public static <T> List<T> collectElements(Reactor definition, Function<Reactor,List<T>> elements) {
List<T> result = new ArrayList<T>();
// Add elements of the current reactor.
Copy link
Collaborator

@cmnrd cmnrd Feb 15, 2022

Choose a reason for hiding this comment

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

This change looks great! The only "mistake" that I could spot is that the elements of the current reactor are added before the elements of the super classes. In the original code, it was added after the super class elements. I don't know whether the order within the list has any meaning in this context. If it should not have meaning, then maybe the bug lies somewhere else.

Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

The changes look good to me.

Indeed, the reordering in collectElements fixed the tests. As stated in my comment above, the fact that the test outcome depends on the order of elements within the resulting list might indicate a bug further down the line.

@edwardalee
Copy link
Collaborator Author

The order very definitely has meaning. Not only should the base class elements be added first, but also when a reactor extends multiple base classes, those elements need to be added in the order that the extensions are declared. So there is only exactly one order that is correct.

Consider a reaction that writes to an output. A subclass can "override" the output of a base class by overwriting it.

I'm surprised my test caught this bug. I didn't design it to check for this...

@edwardalee edwardalee merged commit 0cf3248 into master Feb 15, 2022
@edwardalee edwardalee deleted the inheritance-cleanups branch February 15, 2022 15:46
@lhstrh lhstrh added refactoring Code quality enhancement bug Something isn't working labels Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactoring Code quality enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants