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

Bug 351827

Summary: [Xtend][Scoping] Injected Extensions shadow local methods
Product: [Modeling] TMF Reporter: Christian Dietrich <christian.dietrich.opensource>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 2.0.0Flags: sven.efftinge: indigo+
Target Milestone: SR1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
full source code none

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