| Summary: | [validation] Missing validation for overloaded dispatch | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Sebastian Zarnekow <sebastian.zarnekow> |
| Component: | Backlog | Assignee: | Project Inbox <xtend-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sven.efftinge |
| Version: | 2.3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
what validation would you like to have here? Good question ...
I had the following use case with a class that defines:
def dispatch generateModifier(JvmGenericType it) {}
def dispatch generateModifier(JvmField it) {}
def dispatch generateModifier(JvmOperation it) {}
def dispatch generateModifier(JvmConstructor it) {}
Starting the migration towards
def dispatch generateModifier(JvmGenericType it, TracingAppendable appendable)
I'd usually use the compiler to provide hints where a method was called with the wrong number of arguments. Since there is no Change Method Signature refactoring (yet :p), it was hard to spot all the places where I had to make changes - first all the declarations, afterwards all the clients.
But that's only half of the story. Assuming a type hierarchy with
class Super {
def dispatch generateModifier(JvmGenericType it) {}
def dispatch generateModifier(JvmField it) {}
}
class Sub extends Super {
def dispatch generateModifier(JvmOperation it) {}
def dispatch generateModifier(JvmConstructor it) {}
}
The newly introduced dispatch cases actually contribute to the 'real thing'. However, there is no override / overload validation thus changing the super type's signatures silently breaks the subtype since it'll simply define its own variant of 'generateModifier'.
I'm aware that there are other cases where a change in a super type breaks subtypes so I'm not sure about this feature request any more.
I guess we can alt least come up with some optional warnings. |
def dispatch generateModifier(JvmGenericType it, TracingAppendable appendable) {} def dispatch generateModifier(JvmField it, TracingAppendable appendable) {} def dispatch generateModifier(JvmOperation it) {} def dispatch generateModifier(JvmConstructor it) {}