Reviewers: rjrjr,

Message:
Review requested.

Description:
Prevent an AutoBean property named "property" from causing a compilation
error.
Patch by: bobv
Review by: rjrjr


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

Affected files:
M user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java
  M user/test/com/google/web/bindery/autobean/gwt/client/AutoBeanTest.java


Index: user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java
===================================================================
--- user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java (revision 10473) +++ user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java (working copy)
@@ -231,8 +231,9 @@
           String castType;
           if (returnType.isPrimitive() != null) {
castType = returnType.isPrimitive().getQualifiedBoxedSourceName();
-            // Boolean toReturn = getOrReify("foo");
- sw.println("%s toReturn = getOrReify(\"%s\");", castType, method.getPropertyName());
+            // Boolean toReturn = Outher.this.getOrReify("foo");
+ sw.println("%s toReturn = %s.this.getOrReify(\"%s\");", castType, type
+                .getSimpleSourceName(), method.getPropertyName());
             // return toReturn == null ? false : toReturn;
sw.println("return toReturn == null ? %s : toReturn;", returnType.isPrimitive()
                 .getUninitializedFieldExpression());
@@ -241,17 +242,19 @@
sw.println("return data.isNull(\"%1$s\") ? null : data.get(\"%1$s\");", method
                 .getPropertyName());
           } else {
-            // return (ReturnType) values.getOrReify(\"foo\");
+            // return (ReturnType) Outer.this.getOrReify(\"foo\");
             castType = ModelUtils.getQualifiedBaseSourceName(returnType);
- sw.println("return (%s) getOrReify(\"%s\");", castType, method.getPropertyName()); + sw.println("return (%s) %s.this.getOrReify(\"%s\");", castType, type
+                .getSimpleSourceName(), method.getPropertyName());
           }
         }
           break;
         case SET:
         case SET_BUILDER: {
           JParameter param = jmethod.getParameters()[0];
-          // setProperty("foo", parameter);
- sw.println("setProperty(\"%s\", %s);", method.getPropertyName(), param.getName());
+          // Other.this.setProperty("foo", parameter);
+ sw.println("%s.this.setProperty(\"%s\", %s);", type.getSimpleSourceName(), method
+              .getPropertyName(), param.getName());
           if (JBeanMethod.SET_BUILDER.equals(method.getAction())) {
             sw.println("return this;");
           }
Index: user/test/com/google/web/bindery/autobean/gwt/client/AutoBeanTest.java
===================================================================
--- user/test/com/google/web/bindery/autobean/gwt/client/AutoBeanTest.java (revision 10473) +++ user/test/com/google/web/bindery/autobean/gwt/client/AutoBeanTest.java (working copy)
@@ -15,14 +15,14 @@
  */
 package com.google.web.bindery.autobean.gwt.client;

+import com.google.gwt.core.client.GWT;
+import com.google.gwt.junit.client.GWTTestCase;
 import com.google.web.bindery.autobean.shared.AutoBean;
 import com.google.web.bindery.autobean.shared.AutoBeanFactory;
 import com.google.web.bindery.autobean.shared.AutoBeanFactory.Category;
 import com.google.web.bindery.autobean.shared.AutoBeanUtils;
 import com.google.web.bindery.autobean.shared.AutoBeanVisitor;
import com.google.web.bindery.autobean.shared.AutoBeanVisitor.ParameterizationVisitor;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.junit.client.GWTTestCase;

 import java.util.ArrayList;
 import java.util.Collection;
@@ -42,6 +42,7 @@
     public static Object seen;

     public static <T> T __intercept(AutoBean<HasCall> bean, T value) {
+      assertNotNull(bean);
       seen = value;
       return value;
     }
@@ -129,9 +130,14 @@
   interface Intf {
     int getInt();

+    String getProperty();
+
     String getString();

     void setInt(int number);
+
+    // Avoid name conflicts in AbstractAutoBean
+    void setProperty(String value);

     void setString(String value);
   }
@@ -150,6 +156,7 @@

   static class RealIntf implements Intf {
     int i;
+    String property;
     String string;

     @Override
@@ -161,6 +168,11 @@
       return i;
     }

+    @Override
+    public String getProperty() {
+      return property;
+    }
+
     public String getString() {
       return string;
     }
@@ -172,6 +184,11 @@

     public void setInt(int number) {
       this.i = number;
+    }
+
+    @Override
+    public void setProperty(String value) {
+      this.property = value;
     }

     public void setString(String value) {
@@ -473,7 +490,7 @@
         if ("int".equals(propertyName)) {
           assertEquals(42, value);
           assertEquals(int.class, ctx.getType());
-        } else if ("string".equals(propertyName)) {
+ } else if ("string".equals(propertyName) | | "property".equals(propertyName)) {
           assertNull(value);
           assertEquals(String.class, ctx.getType());
         } else if ("get".equals(propertyName) || "has".equals(propertyName)


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

Reply via email to