On Mon, Mar 30, 2009 at 1:57 PM, Scott Blum <[email protected]> wrote:

> John and I discussed this face to face.  It turns out that the find()
> method has, perhaps, an unnecessarily complicated specification that pushes
> generic compile time sugar arguably past the point of usefulness --- and
> definitely past what OpenJDK allows.
> So our tentative resolution is to simplify the declaration of find() and
> make it slightly less powerful.  It turns out none of our own code is making
> any use whatsoever of the extra flexibility it currently has.
>

Here is the patch which does what Scott suggested.  Any objections?

-- 
John A. Tamplin
Software Engineer (GWT), Google

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Index: dev/core/src/com/google/gwt/core/ext/linker/ArtifactSet.java
===================================================================
--- dev/core/src/com/google/gwt/core/ext/linker/ArtifactSet.java	(revision 5074)
+++ dev/core/src/com/google/gwt/core/ext/linker/ArtifactSet.java	(working copy)
@@ -61,6 +61,7 @@
     return treeSet.containsAll(c);
   }
 
+  @Override
   public boolean equals(Object o) {
     return treeSet.equals(o);
   }
@@ -68,28 +69,29 @@
   /**
    * Find all Artifacts assignable to some base type. The returned value will be
    * a snapshot of the values in the ArtifactSet. The following two examples
-   * result in an equivalent set:
+   * result in an equivalent set (assuming there were no EmittedArtifacts
+   * present not of type PublicResource or GeneratedResource):
    * 
    * <pre>
-   * SortedSet&lt;EmittedArtifact&gt; search = artifactSet.find(PublicResource.class);
-   * search.addAll(artifactSet.find(GeneratedResource.class);
+   *   SortedSet&lt;EmittedArtifact&gt; search = new TreeSet&lt;EmittedArtifact&gt;();
+   *   search.addAll(artifactSet.find(PublicResource.class));
+   *   search.addAll(artifactSet.find(GeneratedResource.class));
    * </pre>
    * 
    * or
    * 
    * <pre>
-   * SortedSet&lt;EmittedArtifact&gt; search = artifactSet.find(EmittedArtifact.class);
+   *   SortedSet&lt;EmittedArtifact&gt; search = artifactSet.find(EmittedArtifact.class);
    * </pre>
    * 
-   * @param <A> a type bound possibly wider than the desired type of artifact
    * @param <T> the desired type of Artifact
    * @param artifactType the desired type of Artifact
    * @return all Artifacts in the ArtifactSet assignable to the desired type
    */
-  public <A extends Artifact<?>, T extends A> SortedSet<A> find(
+  public <T extends Artifact<? super T>> SortedSet<T> find(
       Class<T> artifactType) {
     // TODO make this sub-linear (but must retain order for styles/scripts!)
-    SortedSet<A> toReturn = new TreeSet<A>();
+    SortedSet<T> toReturn = new TreeSet<T>();
     for (Artifact<?> artifact : this) {
       if (artifactType.isInstance(artifact)) {
         toReturn.add(artifactType.cast(artifact));
@@ -113,6 +115,7 @@
     }
   }
 
+  @Override
   public int hashCode() {
     return treeSet.hashCode();
   }

Reply via email to