| Summary: | [xbase][types] problem with type inference of closure return type | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Knut Wannheden <knut.wannheden> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | Flags: | knut.wannheden:
kepler+
|
| Version: | 2.1.0 | ||
| Target Milestone: | M6 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
I was further surprised to find that the example works if the generic type is declared on the method instead:
public class Foo {
def <T> foo() {
[T x|x].apply(null)
}
}
This bug has been fixed in Xtend 2.4. |
For the following Xtend2 file: public class Foo<T> { def foo() { [T x|x].apply(null) } } an error marker is generated for the closure body expression "x": "Incompatible implicit return type. Expected T but was Result". I don't think there should be an error marker in this case. Workarounds. Change the code to read: public class Foo<T> { def foo() { [T x|x as T].apply(null) } } or: public class Foo<T> { def T foo() { [T x|x].apply(null) } }