Community
Participate
Working Groups
Example: ------- class foo<T> { def <X> create new foo<X>() newFoo() { } } ------- this compiles to the following erroneous Java code -------- public class foo<T extends Object> { public <X extends Object> foo<X> newFoo() { final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(); final foo<?> _result; synchronized (_createCache_newFoo) { if (_createCache_newFoo.containsKey(_cacheKey)) { return _createCache_newFoo.get(_cacheKey); } foo<X> _foo = new foo<X>(); _result = _foo; _createCache_newFoo.put(_cacheKey, _result); } _init_newFoo(_result); return _result; } private final HashMap<ArrayList<?>,foo<?>> _createCache_newFoo = CollectionLiterals.newHashMap(); private void _init_newFoo(final foo<?> it) { } } ----------- It's not compilable, because - "final foo<?> _result;" needs to be "foo<X>"; - "return _createCache_newFoo.get(_cacheKey);" needs a cast: "return (foo<X>) _createCache_newFoo.get(_cacheKey);"
This cannot be fixed easily, since we would have to resolve the return type, which is derived eagerly. I added a validation, preventing people to use generified create methods.
Closing all bugs that were set to RESOLVED before Neon.0