Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343714 - [xtend] Add error check for variable name shadowing
Summary: [xtend] Add error check for variable name shadowing
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-24 16:15 EDT by Krzysztof Kowalczyk CLA
Modified: 2017-09-19 18:09 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Kowalczyk CLA 2011-04-24 16:15:35 EDT
Let's assume we have Java class Base that is extended by X,Y and Z. We also have Xtend class:

class Dispatch {
	foo(Z z){
		f(z) //This will throw exception
	}
	dispatch f(X x){ 1 }
	dispatch f(Y y){ 2 }
}

Because dispatch leads to f(Base) Java function, f(Z) is a correct Java invocations, but we know this is incorrect invocations as user only created implementations for f(X) and f(Y). So I think it should be marked as error.
Comment 1 Sven Efftinge CLA 2011-04-26 02:27:21 EDT
The runtime exception is intentional. 
Dispatching is an implementation detail and the caller doesn't know (and shouldn't) about it. 
You cannot tell at compile time what kind of dispatch functions are there since one for 'Z' could have been introduced in a subclass.
Comment 2 Krzysztof Kowalczyk CLA 2011-04-26 03:48:46 EDT
In old Xtend it was marked as error, but old Xtend does not have inheritance.

The class can have a subclass, but can also be instantiated and such instance will lead to errors. 

If one plan to add such method in subclasses then 'abstract' method should be provided in this class, so we cannot create wrong instances and users know that subclasses should provide this behavior. IMO there should be at least a warning.
Comment 3 Karsten Thoms CLA 2017-09-19 17:59:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 18:09:58 EDT
Closing all bugs that were set to RESOLVED before Neon.0