Fixes a bad assert. I had thought that java.lang.Object would never end up needing a typeId, but I was wrong. In cases where an Object[] is instantiated, it does need a typeId. Therefore, my original assertion that String would always have typeId = 1 turns out to be wrong. So I'm forcing Object to always have typeId = 1 and String typeId = 2.
Review by: mmendez (postmortem)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1333 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/CastNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/CastNormalizer.java
index b997ff2..e66a718 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/CastNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/CastNormalizer.java
@@ -87,9 +87,13 @@
classes.add(null);
jsonObjects.add(new JsonObject(program));
- // Do java.lang.String first to reserve typeId 1 for the mashup case.
+ /*
+ * Do String first to reserve typeIds 1 and 2 for Object and String,
+ * respectively. This ensures consistent modification of String's
+ * prototype.
+ */
computeSourceClass(program.getTypeJavaLangString());
- assert (classes.size() == 2);
+ assert (classes.size() == 3);
/*
* Compute the list of classes than can successfully satisfy cast
@@ -219,9 +223,11 @@
/*
* Weird: JavaScriptObjects MUST have a typeId, the implementation of
- * Cast.wrapJSO depends on it.
+ * Cast.wrapJSO depends on it. Object must also have a typeId, to force
+ * String to have an id of 2.
*/
- if (yesSet == null && !program.isJavaScriptObject(type)) {
+ if (yesSet == null && !program.isJavaScriptObject(type)
+ && (type != program.getTypeJavaLangObject())) {
return; // won't satisfy anything
}