Reviewers: scottb, jbrosenberg,

Description:
Adds some more docs to TypeTightener and MethodCallTightener


Please review this at http://gwt-code-reviews.appspot.com/1447814/

Affected files:
  M dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java
  M dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java


Index: dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java (revision 10251) +++ dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java (working copy)
@@ -35,6 +35,17 @@
  *
  * This is possible because the qualifier might have been tightened by
  * {@link com.google.gwt.dev.jjs.impl.TypeTightener}.
+ *
+ * For example, given the code:
+ *
+ *   List foo = new ArrayList<String>();
+ *
+ *   foo.add("bar");
+ *
+ * The type of foo is tightened by TypeTightener from type List to be of type + * ArrayList. This means that MethodCallTightener can analyze the polymorphic + * call List.add() on foo and tighten it to the more specific ArrayList.add()
+ *
  */
 public class MethodCallTightener {
   /**
Index: dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java (revision 10251) +++ dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java (working copy)
@@ -71,6 +71,25 @@
  * types can be inferred for locals, fields, parameters, and method return
  * types. We also optimize dynamic casts and instanceof operations.
  *
+ * Examples:
+ *
+ * This declaration of variable foo:
+ *
+ * final List foo = new ArrayList<String>();
+ *
+ * can be tightened from List to ArrayList because no type other than ArrayList
+ * can ever assigned to foo.
+ *
+ * The return value of the method bar:
+ *
+ * Collection<String> bar() { return new LinkedHashSet<String>; }
+ *
+ * can be tightened from Collection<String> to LinkedHashSet<String> since it
+ * will never return any other type.
+ *
+ * By working in conjunction with {@link MethodCallTightener}, Type tightening can
+ * eliminate generating run-time dispatch code for polymorphic methods.
+ *
  * Type flow occurs automatically in most JExpressions. But locals, fields,
  * parameters, and method return types serve as "way points" where type
* information is fixed based on the declared type. Type tightening can be done


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

Reply via email to