Showing results for 
Search instead for 
Did you mean: 

Labview Interface Override Behavior

Go to solution

I have a class which inherits (Blue) an interface (Purple) which inherits an interface (Orange). Orange has a method "" which Purple overrides (Blue does not implement this method).


I want to call this method, passing in Blue. My expectation is that it it should dispatch to the "nearest" implementation, ie Purple. However, I am seeing that it is skipping Purple and going straight to Orange.




Whats more, when I try to specifically upcast to Purple and yet it still dispatches to Orange at runtime




Am I wrong to assume that it should dispatch to the "closest" child implementation?


Example code attached  (LV2020, reproduced in 2021)


0 Kudos
Message 1 of 4
Accepted by skaley

I don't have 2020 to try it out but I believe this is because Green inherits from Orange as well.  If you were to remove Green's inheritance from Orange, then it should work as you expect.  I think this is because Green has a "virtual" instance, i.e. it refers it to Orange, and the system can't tell which of either Green or Purple to call since both can call it, so it calls Orange because there's only the one instance of it.


I would also note that the upcasting there doesn't actually do anything other than change the color of the wire on the diagram.  Part of the core LVOOP design (and OOP design in general) is that you can never just "change" from one class to another.

Message 2 of 4

Great catch! That was the issue, thank you! 

0 Kudos
Message 3 of 4

FYI If you haven't read it, this is an interesting resource into the decision making behind the behavior. 

Message 4 of 4