Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358116

Summary: [Xtend] No error on duplicate variable names
Product: [Modeling] TMF Reporter: Benjamin Schwertfeger <benjamin.schwertfeger>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jan, sven.efftinge
Version: 2.1.0Flags: sven.efftinge: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch for JavaValidator and Testcase none

Description Benjamin Schwertfeger CLA 2011-09-19 09:32:56 EDT
It is possible to define two class variables with the same name:

@Inject String cache
@Inject Integer cache
@Inject Object cache

Leads to one String variable cache and cache_1 and cache_2 in java code. In xtend the type of cache is also String and you can not access the last two.

There should be a check for duplicate variable names inside a class.
Comment 1 Benjamin Schwertfeger CLA 2011-09-19 09:36:46 EDT
Created attachment 203588 [details]
Patch for JavaValidator and Testcase

Added new Validation method for this case.
Comment 2 Sven Efftinge CLA 2011-09-26 03:06:49 EDT
In the long run we should define all these Java-based constraints on the JvmModel, so they will automatically get applied for any Xbase-based language
Comment 3 Jan Koehnlein CLA 2011-10-17 05:41:42 EDT
Pushed to MASTER.

Validation is performed on the Xtend level.

Patch was not used, but thanks for your effort.
Comment 4 Jan Koehnlein CLA 2011-10-17 05:45:47 EDT
Jvm model validation will be handled in separate bug #361114
Comment 5 Karsten Thoms CLA 2017-09-19 17:49:25 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 18:00:27 EDT
Closing all bugs that were set to RESOLVED before Neon.0