Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364692 - [Xtend] warning about little type information
Summary: [Xtend] warning about little type information
Status: CLOSED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Backlog (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-11-24 04:47 EST by Serano Colameo CLA
Modified: 2017-10-31 11:17 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serano Colameo CLA 2011-11-24 04:47:16 EST
Build Identifier: Xtext 2.1.1.v201111141332

xtend:
	def dispatch getOperations(Facade f) {
		if (f == null || f.features.nullOrEmpty) return newArrayList
		return f.features.filter(typeof(Operation))
	}

	def dispatch getOperations(Mapper m) {
		if (m == null || m.features.nullOrEmpty) return newArrayList
		return m.features.filter(typeof(Operation))
	}

generated java:

  public Iterable<? extends Object> getOperations(final StructuralFeature f) {
    if (f instanceof Facade) {
      return _getOperations((Facade)f);
    } else if (f instanceof Mapper) {
      return _getOperations((Mapper)f);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(f).toString());
    }
  }
  protected Iterable<? extends Object> _getOperations(final Facade f) {
      boolean _operator_or = false;
      boolean _operator_equals = ObjectExtensions.operator_equals(f, null);
....

=> BUG:  protected Object _getOperations(final Mapper m) {
      boolean _operator_or = false;
      boolean _operator_equals = ObjectExtensions.operator_equals(m, null);
      if (_operator_equals) {
        _operator_or = true;

~serano

Reproducible: Always

Steps to Reproduce:
1. see details (=> BUG)
2.
3.
Comment 1 Serano Colameo CLA 2011-11-24 04:49:28 EST
workaround is to explicitely define a return type (Iterable<Operation>)

	def dispatch Iterable<Operation> getOperations(Facade f) {
		if (f == null || f.features.nullOrEmpty) return newArrayList
		return f.features.filter(typeof(Operation))
	}

	def dispatch  Iterable<Operation> getOperations(Mapper m) {
		if (m == null || m.features.nullOrEmpty) return newArrayList
		return m.features.filter(typeof(Operation))
	}

regards
serano
Comment 2 Sven Efftinge CLA 2011-11-24 04:56:19 EST
newArrayList is not parameterized with any type argument. So it defaults to ?.

You could either provide more type information in the return type or have an explicit type argument:

  return <Operation>newArrayList

We might want to add a warning if that little type information is available.
As soon as we have means to suppress or deactivate them again :-)
Comment 3 Sebastian Zarnekow CLA 2013-02-28 10:11:55 EST
Fixed with new type system.
Comment 4 Eclipse Webmaster CLA 2017-10-31 11:06:33 EDT
Requested via bug 522520.

-M.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:17:55 EDT
Requested via bug 522520.

-M.