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

Bug 343090

Summary: [xbase] [compiler] casting using function type literal produces illegal Java
Product: [Modeling] TMF Reporter: Knut Wannheden <knut.wannheden>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: M7   
Hardware: All   
OS: All   
Whiteboard:

Description Knut Wannheden CLA 2011-04-18 02:49:45 EDT
The following Xtend2 snippet:

	<T extends Integer> castOfFunction() {
		[T a,T b|(a+(b as Integer))] as (T,T)=>T
	}

is accepted as legal by the Xtend2 editor, but is compiled to the following illegal Java code:


  public <T extends Integer> Function2<? extends Integer,? extends Integer,? extends Integer> castOfFunction() {
    final Function2<T,T,Integer> _function = new Function2<T,T,Integer>() {
        public Integer apply(T a , T b) {
          final T typeConverted_a = (T)a;
          int _operator_plus = IntegerExtensions.operator_plus(typeConverted_a, ((java.lang.Integer) b));
          return _operator_plus;
        }
      };
    return (((T, T) => T) _function); // COMPILE ERROR HERE
  }
Comment 1 Sebastian Zarnekow CLA 2011-04-20 05:59:49 EDT
Pushed to master.
Comment 2 Karsten Thoms CLA 2017-09-19 17:45:53 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:56:52 EDT
Closing all bugs that were set to RESOLVED before Neon.0