Reviewers: cromwellian, robertvawter,

Description:
Fix ArrayStoreException in assignments to an element of an array of a
single jso interface type.

Addresses issue 6448


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

Affected files:
  M dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
  M user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java


Index: dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java       (revision 10405)
+++ dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java       (working copy)
@@ -836,6 +836,13 @@

   public int getQueryId(JReferenceType elementType) {
     assert (elementType == elementType.getUnderlyingType());
+    if (typeOracle.isEffectivelyJavaScriptObject(elementType)) {
+      /*
+ * treat types that are effectively JSO's as JSO's, for the purpose of
+       * castability checking
+       */
+      elementType = getJavaScriptObject();
+    }
     Integer integer = queryIdsByType.get(elementType);
     if (integer == null) {
       return 0;
Index: user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java
===================================================================
--- user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java (revision 10405) +++ user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java (working copy)
@@ -509,9 +509,28 @@
     return {};
   }-*/;

+  private Simple makeSimpleViaCastToInterface() {
+    return (Simple) JavaScriptObject.createObject();
+  }
+
   @Override
   public String getModuleName() {
     return "com.google.gwt.dev.jjs.CompilerSuite";
+  }
+
+  /*
+   * This test is inspired by issue 6448:
+   *
+   * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=6448
+   */
+ public void testAssignToInterfaceArrayElementCreatedWithCastToInterface() {
+    Simple[] simples = new Simple[2];
+    Simple simpleOne = (Simple) JavaScriptObject.createObject();
+    simples[0] = simpleOne;
+    assert simples[0].a().equals("a");
+    Simple simpleTwo = (Simple) JavaScriptObject.createObject();
+    simples[1] = simpleTwo;
+    assert simples[1].a().equals("a");
   }

   public void testCallsToInnerTypes() {


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

Reply via email to