Fixes JSORestrictions crash in bad units.

In rare cases, the old code would crash with a null scope.

Review by: bobv

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7340 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/JSORestrictionsChecker.java b/dev/core/src/com/google/gwt/dev/javac/JSORestrictionsChecker.java
index 1e9cb0f..20cb178 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JSORestrictionsChecker.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JSORestrictionsChecker.java
@@ -85,8 +85,19 @@
 
     @Override
     public void endVisit(AllocationExpression exp, BlockScope scope) {
+      // In rare cases we might not be able to resolve the expression.
+      if (exp.type == null) {
+        return;
+      }
+      TypeBinding resolvedType = exp.resolvedType;
+      if (resolvedType == null) {
+        if (scope == null) {
+          return;
+        }
+        resolvedType = exp.type.resolveType(scope);
+      }
       // Anywhere an allocation occurs is wrong.
-      if (exp.type != null && isJsoSubclass(exp.type.resolveType(scope))) {
+      if (isJsoSubclass(resolvedType)) {
         errorOn(exp, ERR_NEW_JSO);
       }
     }