Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365697 - Validation error or warning for not matching dispatch signature (see details)
Summary: Validation error or warning for not matching dispatch signature (see details)
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Backlog (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 03:51 EST by Serano Colameo CLA
Modified: 2012-11-08 04:40 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serano Colameo CLA 2011-12-06 03:51:08 EST
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
Comment 1 Sven Efftinge CLA 2011-12-06 03:53:16 EST
This can only be done if the class is marked 'final', which is not supported atm.
Comment 2 Jan Koehnlein CLA 2011-12-06 04:02:36 EST
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.
Comment 3 Serano Colameo CLA 2011-12-06 05:06:42 EST
(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
Comment 4 Sebastian Zarnekow CLA 2011-12-06 18:03:56 EST
(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.
Comment 5 Sven Efftinge CLA 2011-12-07 03:03:15 EST
Agreed, as soon as we support @SuppressWarnings.