Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364212 - [Xtend] Type variable causes Xtend to silently generate broken Java
Summary: [Xtend] Type variable causes Xtend to silently generate broken Java
Status: CLOSED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-11-19 04:32 EST by McKinley CLA
Modified: 2017-10-31 10:59 EDT (History)
3 users (show)

See Also:
sven.efftinge: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description McKinley CLA 2011-11-19 04:32:28 EST
Build Identifier: 2.2.0.v201111181146

The follow Java and Xtend code causes Xtend to silently generate broken Java. If more type information is needed in Xtend, perhaps the IDE should highlight that error in the Xtend file. The following example was seen in the wild when I recently tried the HtmlUnit library with Xtend.

public interface InterfaceA { }

public class ClassB implements InterfaceA { }

public class ClassC extends ClassB {
    public static <T extends InterfaceA> T newClassBAsInterfaceA() {
        return (T) new ClassC();
    }
}

class XtendClass1 {
    def test() {
        val x = ClassC::newClassBAsInterfaceA
    }
}

This causes Xtend to produce the following broken generated Java code:

@SuppressWarnings("all")
public class XtendClass1 {
  public void test() {
    ? _newClassBAsInterfaceA = ClassC.newClassBAsInterfaceA();
    final ? x = _newClassBAsInterfaceA;
  }
}

Reproducible: Always

Steps to Reproduce:
See above.
Comment 1 Sven Efftinge CLA 2012-01-31 05:42:10 EST
We need to use the type's upper bound in the compiler.
Comment 2 Dennis Huebner CLA 2013-02-14 03:29:44 EST
Given Xtend code produces a valid Java. Seems to be fixed.
Comment 3 Eclipse Webmaster CLA 2017-10-31 10:48:05 EDT
Requested via bug 522520.

-M.
Comment 4 Eclipse Webmaster CLA 2017-10-31 10:59:08 EDT
Requested via bug 522520.

-M.