-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Inheritance cleanups #962
Conversation
…cted and duplicate extensions were not merged. Added a test.
There was a problem hiding this 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.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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... |
This PR changes the way inheritance is handled to fix two problems identified in #907.