Revision: 10278
Author:   [email protected]
Date:     Sat Jun  4 04:09:38 2011
Log:      Adds some more docs to TypeTightener and MethodCallTightener

Review at http://gwt-code-reviews.appspot.com/1447814

http://code.google.com/p/google-web-toolkit/source/detail?r=10278

Modified:
 /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java
 /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java Thu Jun 2 11:49:52 2011 +++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/MethodCallTightener.java Sat Jun 4 04:09:38 2011
@@ -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:
+ *
+ * <pre>
+ *   List foo = new ArrayList<String>();
+ *   foo.add("bar");
+ * </pre>
+ *
+ * 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 {
   /**
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java Thu Jun 2 11:49:52 2011 +++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java Sat Jun 4 04:09:38 2011
@@ -71,6 +71,31 @@
  * 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:
+ *
+ * <pre>
+ * final List foo = new ArrayList();
+ * </pre>
+ *
+ * can be tightened from List to ArrayList because no type other than ArrayList
+ * can ever be assigned to foo.
+ *
+ * The return value of the method bar:
+ *
+ * <pre>
+ * Collection bar() {
+ *   return new LinkedHashSet;
+ * }
+ * </pre>
+ *
+ * can be tightened from Collection to LinkedHashSet 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