
google-web-toolkit - issue #6016
EditorContext generated class name should take parameterization into account.
Found in GWT Release (e.g. 1.5.3, 1.6 RC): trunk r9715
Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3): N/A
Detailed description (please be as specific as possible): See notes after the "shortest code snippet which demonstrates the issue".
Shortest code snippet which demonstrates issue (please indicate where actual result differs from expected result):
class BaseFooEditor<T extends BaseFoo> implements Editor<T> { LeafValueEditor<String> subEditor; }
class AEditor implements Editor<A> { BaseFooEditor<Foo1> foo1; BaseFooEditor<Foo2> foo2; }
will cause a BaseFooEditor_subEditor_Context class to be generated, whose 'parent' field and constructor 'parent' argument is of type Foo1. This causes a compilation error in the generated EditorDelegate for AEditor when dealing with the 'foo2' field, because the same BaseFooEditor_subEditor_Context class is used with the Foo2 type (and Foo2 is not assignable to Foo1).
The generator should either use the upper bound of the type parameter (BaseFoo instead of Foo1 or Foo2), or generate different classes for each actual parameterization (BaseFooEditor_Foo1_subEditor_Context and BaseFooEditor_Foo2_subEditor_Context; but with a probable "class explosion").
Workaround if you have one: Create non-generic subclasses of the generic editor class, setting the type parameters to a fixed value, so the generated EditorContext classes all have distinct names (similar to the proposed fix where the actual parameterization would be taken into account in the generated class name).
Links to relevant GWT Developer Forum posts: https://groups.google.com/d/msg/google-web-toolkit-contributors/bkIrQvLtK2k/q46gLnbOIykJ
Comment #1
Posted on Feb 13, 2011 by Swift RhinoComment #2
Posted on Feb 14, 2011 by Quick Ox(No comment was entered for this change.)
Comment #3
Posted on Jul 29, 2011 by Grumpy GiraffeShould be embbeded in 2.4 ?
Comment #4
Posted on Jul 29, 2011 by Grumpy GiraffeThis patch worked for me, thanks again thomas !
Comment #5
Posted on Aug 30, 2011 by Swift Ox(No comment was entered for this change.)
Comment #6
Posted on Sep 27, 2011 by Grumpy GiraffeOuppss ! This fix hasn't been released in 2.4 so I have to patch it again :p.
I hope it will in future release....
Comment #7
Posted on Jan 24, 2012 by Swift RhinoIssue 7144 has been merged into this issue.
Comment #8
Posted on Feb 9, 2012 by Grumpy RabbitI encountered the same problem when upgrading my app from GWT 2.2 to 2.4. I have not tested the patch mentioned above because I don't know where to find it.
- In addition I have the following related problem:
All the Add/Edit operation in my app have some common meta-data which are not part of the object being added. So I wrapped them in a AddEditContext object which is generic on the type being added, having a property "instance" of type T. The editor root is a AddEditContextEditor> (a composite editor).
class AddEditContext { T instance; Metadata metadata; }
class AddEditContextEditor> extends CompositeEditor,T,E> { E instance; Editor metadata; }
The generated AddEditContextEditor_instance_Context has its "parent" property declared as the first type the Editor generator ever encounters - let's call it A - not as T (i.e. BaseType) This causes a compilation error as the AddEditContextEditor_instance_Context.getFromModel() attempts to down-cast parent.getInstance() (which returns a BaseType) to type A. The same thing happen in cascade for all types B, C, D ... extending BaseType. Which is the issue described by Thomas.
This would not happen if the generator was smart enough to use the upper bound type (BaseType) or as a fallback Object.
The only way around that is to create specialized Editors AddEditContextEditorA, AddEditContextEditorB, AddEditContextEditorC etc. AND specialized DTO AddEditContextA, AddEditContextB, AddEditContextC. If I would not mind creating specialized editors, changing my DTOs is a NO GO for me.
Comment #9
Posted on Feb 9, 2012 by Swift RhinoI have not tested the patch mentioned above because I don't know where to find it.
Simply go to http://gwt-code-reviews.appspot.com/1352806 and click the "download raw patch set" link.
Comment #10
Posted on May 31, 2012 by Happy RabbitThis issue was closed by revision r11002.
Comment #11
Posted on May 31, 2012 by Swift Rhino(No comment was entered for this change.)
Comment #12
Posted on Jun 27, 2012 by Happy ElephantBulk edit: should be fixed in the GWT 2.5 release candidate.
Status: Fixed
Labels:
Category-Other
Milestone-2_5