Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362239 - [xtend] missing type checks for type casts of primitives
Summary: [xtend] missing type checks for type casts of primitives
Status: CLOSED DUPLICATE of bug 342007
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-27 16:06 EDT by Knut Wannheden CLA
Modified: 2012-01-31 06:12 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***