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

Bug 362239

Summary: [xtend] missing type checks for type casts of primitives
Product: [Tools] Xtend Reporter: Knut Wannheden <knut.wannheden>
Component: CoreAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 2.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Knut Wannheden CLA 2011-10-27 16:06:33 EDT
The following Xtend code:

class Other {
	def bar() {
		true as String
	}
}

compiles to the illegal Java code:

@SuppressWarnings("all")
public class Other {
  public String bar() {
    return ((String) ((Boolean)true));
  }
}

The same thing happend for expressions like "42 as String" etc.
Comment 1 Knut Wannheden CLA 2011-10-28 03:23:31 EDT
Could be related: Compiling the following:

public class Foo {
	def foo() {
		switch 123 {
			String case null : "foo"
		}
	}	
}

results in an illegal instanceof expression:

@SuppressWarnings("all")
public class Foo {
  public String foo() {
    String _switchResult = null;
    final int __valOfSwitchOver = 123;
    boolean matched = false;
    if (!matched) {
      if (__valOfSwitchOver instanceof String) {
        if (ObjectExtensions.operator_equals(__valOfSwitchOver,null)) {
          matched=true;
          _switchResult = "foo";
        }
      }
    }
    return _switchResult;
  }
}
Comment 2 Sebastian Zarnekow CLA 2011-10-28 03:30:44 EDT
related to bug 342007 and bug 342431
Comment 3 Sven Efftinge CLA 2012-01-31 06:12:30 EST

*** This bug has been marked as a duplicate of bug 342007 ***