Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343090 - [xbase] [compiler] casting using function type literal produces illegal Java
Summary: [xbase] [compiler] casting using function type literal produces illegal Java
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-18 02:49 EDT by Knut Wannheden CLA
Modified: 2017-09-19 17:56 EDT (History)
1 user (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 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