| Summary: | Validation error or warning for not matching dispatch signature (see details) | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Serano Colameo <serano.colameo> |
| Component: | Backlog | Assignee: | Project Inbox <xtend-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | btickets, jan, sebastian.zarnekow, sven.efftinge |
| Version: | 2.2.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
This can only be done if the class is marked 'final', which is not supported atm. Looks like you're missing a common super type for Retangle and Circle. If the common type is Object, of course Person is a legal argument. You can inspect the signature of the synthetic dispatcher method in the outline. (In reply to comment #2) > Looks like you're missing a common super type for Retangle and Circle. If the > common type is Object, of course Person is a legal argument. > > You can inspect the signature of the synthetic dispatcher method in the > outline. You're right, technically is everything correct, but for an "Xtend" developer not so easy to handle. Because you get in this case a runtime exception "IllegalArgumentException" which could be avoided if there would be a validation. And this is not so nice... It's just a wish, no problem if you disregard this "nice-to-have" request. :-) Serano (In reply to comment #1) > This can only be done if the class is marked 'final', which is not supported > atm. Giving this a second thought, I guess a class that clearly 'needs' to be subclassed in order to work properly, deserves a warning for the bogus code segment. The given version of MyXtend will never work thus a suggestion to introduce a case for a supertype of Circle and Person or for Person itself wouldn't be too bad. Agreed, as soon as we support @SuppressWarnings. |
Build Identifier: Xtext 2.1.1.v201111141332 see comments in xtend code: class MyXtend { // setup shape attributes def dispatch setUpShape(Circle c) { // todo } // setup shape attributes def dispatch setUpShape(Rectangle r) { // todo } def useDispatch() { val c = setUpShape(new Circle(50)) val r = setUpShape(new Rectangle(10,20)) // I would expect here a validation error/warning, // because there is no *explicit* dispatch method // which can handle this call... val p = setUpShape(new Person("Serano", "Colameo")) } } Reproducible: Always