Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347114 - Cannot refer to a non-final variable i inside an inner class defined in a different method
Summary: Cannot refer to a non-final variable i inside an inner class defined in a dif...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 352642 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-25 03:43 EDT by Serano Colameo CLA
Modified: 2017-09-19 18:08 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serano Colameo CLA 2011-05-25 03:43:56 EDT
Build Identifier: Xtext 2.0.0.v201105230203

xtend2:
	def Interface toInterface(InterfaceDcl source, Model model) {
		val target = model.createIcmInterface(source.name)
		val inherits = source.inherits.filter(typeof(InterfaceDcl))
		source.exports.filter(typeof(OpDcl)).forEach([e|e.toOperation(target)])
		source.exports.filter(typeof(TypeDcl)).forEach([e|e.toTypeDef(target)])
		for (i : inherits) {
			if (!model.features.filter(typeof(Interface)).exists(e|e.name == i.name)) {
				target.^extends.add(i.toInterface(model))
				target.extended = true 
			}
		}
		debug("Interface created => " + target.name)
		return target
	}

generated java class:

  public Interface toInterface(final InterfaceDcl source, final Model model) {
    {
      String _name = source.getName();
      Interface _createIcmInterface = this.createIcmInterface(model, _name);
      final Interface target = _createIcmInterface;
      EList<InterfaceDcl> _inherits = source.getInherits();
      Iterable<InterfaceDcl> _filter = IterableExtensions.<InterfaceDcl>filter(_inherits, com.csg.cs.tools.mdgen.idl.idl.InterfaceDcl.class);
      final Iterable<InterfaceDcl> inherits = _filter;
      EList<Export> _exports = source.getExports();
      Iterable<OpDcl> _filter_1 = IterableExtensions.<OpDcl>filter(_exports, com.csg.cs.tools.mdgen.idl.idl.OpDcl.class);
      final Function1<OpDcl,Operation> _function = new Function1<OpDcl,Operation>() {
          public Operation apply(final OpDcl e) {
            Operation _operation = Idl2Icm.this.toOperation(e, target);
            return _operation;
          }
        };
      IterableExtensions.<OpDcl>forEach(_filter_1, _function);
      EList<Export> _exports_1 = source.getExports();
      Iterable<TypeDcl> _filter_2 = IterableExtensions.<TypeDcl>filter(_exports_1, com.csg.cs.tools.mdgen.idl.idl.TypeDcl.class);
      final Function1<TypeDcl,TypeDef> _function_1 = new Function1<TypeDcl,TypeDef>() {
          public TypeDef apply(final TypeDcl e_1) {
            TypeDef _typeDef = Idl2Icm.this.toTypeDef(e_1, target);
            return _typeDef;
          }
        };
      IterableExtensions.<TypeDcl>forEach(_filter_2, _function_1);
      for (InterfaceDcl i : inherits) {
        EList<StructuralFeature> _features = model.getFeatures();
        Iterable<Interface> _filter_3 = IterableExtensions.<Interface>filter(_features, com.csg.cs.tools.mdgen.icm.icmDsl.Interface.class);
        final Function1<Interface,Boolean> _function_2 = new Function1<Interface,Boolean>() {
            public Boolean apply(final Interface e_2) {
              String _name_1 = e_2.getName();
              String _name_2 = i.getName();
              boolean _operator_equals = ObjectExtensions.operator_equals(_name_1, _name_2);
              return ((Boolean)_operator_equals);
            }
          };
        boolean _exists = IterableExtensions.<Interface>exists(_filter_3, _function_2);
        boolean _operator_not = BooleanExtensions.operator_not(_exists);
        if (_operator_not) {
          {
            EList<InterfaceType> _extends = target.getExtends();
            Interface _interface = this.toInterface(i, model);
            _extends.add(_interface);
            target.setExtended(true);
          }
        }
      }
      String _name_3 = target.getName();
      String _operator_plus = StringExtensions.operator_plus("Interface created => ", _name_3);
      this.debug(_operator_plus);
      return target;
    }
  }

Reproducible: Always

Steps to Reproduce:
1. see details
2.
3.
Comment 1 Serano Colameo CLA 2011-05-25 03:44:10 EDT
workaround:

	def Interface toInterface(InterfaceDcl source, Model model) {
		val target = model.createIcmInterface(source.name)
		val inherits = source.inherits.filter(typeof(InterfaceDcl))
		source.exports.filter(typeof(OpDcl)).forEach([e|e.toOperation(target)])
		source.exports.filter(typeof(TypeDcl)).forEach([e|e.toTypeDef(target)])
		for (i : inherits) {
			if (!model.exists(i)) {
				target.^extends.add(i.toInterface(model))
				target.extended = true 
			}
		}
		debug("Interface created => " + target.name)
		return target
	}

	def boolean exists(Model model, InterfaceDcl idcl) {
		val ifaces = model.features.filter(typeof(Interface))
		ifaces.exists(e|e.name == idcl.name)
	}
Comment 2 Sebastian Zarnekow CLA 2011-06-07 07:00:03 EDT
I'll push the fix as soon as Xtext 2.0 final was tagged.
Comment 3 Sebastian Zarnekow CLA 2011-06-14 08:40:10 EDT
Pushed to master.
Comment 4 Sebastian Zarnekow CLA 2011-07-20 17:26:17 EDT
*** Bug 352642 has been marked as a duplicate of this bug. ***
Comment 5 Karsten Thoms CLA 2017-09-19 17:58:03 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 18:08:50 EDT
Closing all bugs that were set to RESOLVED before Neon.0