Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351827 - [Xtend][Scoping] Injected Extensions shadow local methods
Summary: [Xtend][Scoping] Injected Extensions shadow local methods
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-12 08:20 EDT by Christian Dietrich CLA
Modified: 2017-09-19 18:02 EDT (History)
2 users (show)

See Also:
sven.efftinge: indigo+


Attachments
full source code (1.87 KB, application/x-zip-compressed)
2011-07-12 08:50 EDT, Christian Dietrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2011-07-12 08:20:14 EDT
Build Identifier: 2.0.0

Having following Xtend/Java classes

public class DomainmodelCompiler extends XbaseCompiler {

	public String compile(Operation operation, ImportManager importManager) {
		StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(
				importManager);
		for (JvmFormalParameter param : operation.getParameters()) {
			appendable.declareVariable(param, param.getName());
		}
		return compile(operation.getBody(), appendable,
				operation.getReturnType()).toString();
	}

	...
}

and

class DomainmodelGenerator implements IGenerator {
    
    ...
    @Inject extension DomainmodelCompiler xbc
    
   ...
    
    def body(Entity e, ImportManager importManager){
    	'''
		public class «e.name» «IF e.superType != null»extends «e.superType.shortName(importManager)» «ENDIF»{
			«FOR f:e.features.filter(typeof(Property))»
				«f.compile(importManager)»
			«ENDFOR»
			«FOR f:e.features.filter(typeof(Operation))»
				«f.compile(importManager)»
			«ENDFOR»
		}
    	'''
    }
    
    
    def compile(Operation o, ImportManager importManager) '''
        public «o.returnType.shortName(importManager)» «o.name»(«
            o.parameterList(importManager)») {
            «xbc.compile(o, importManager)» 
        }
    '''
    
    ...
    
} 

The problem is that
«FOR f:e.features.filter(typeof(Operation))»
«f.compile(importManager)»
«ENDFOR»
links to the compile method from the extension and not the local one

Reproducible: Always
Comment 1 Christian Dietrich CLA 2011-07-12 08:50:46 EDT
Created attachment 199488 [details]
full source code
Comment 2 Sebastian Zarnekow CLA 2011-07-22 10:44:11 EDT
Pushed to master.
Comment 3 Karsten Thoms CLA 2017-09-19 17:52:11 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 18:02:52 EDT
Closing all bugs that were set to RESOLVED before Neon.0