[Laszlo-checkins] r7080 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler

hqm@openlaszlo.org hqm at openlaszlo.org
Thu Nov 1 10:58:04 PDT 2007


Author: hqm
Date: 2007-11-01 10:58:01 -0700 (Thu, 01 Nov 2007)
New Revision: 7080

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
Log:
Change 20071101-hqm-8 by hqm at IBM-2E06404CB67 on 2007-11-01 12:08:42 EDT
    in /cygdrive/c/users/hqm/openlaszlo/trunk2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary:  fix spurious compiler warning on instance method declaration

New Features:

Bugs Fixed: LPP-5003

Technical Reviewer: jcrowley
QA Reviewer: pkang
Doc Reviewer:

Documentation:

Release Notes:

Details:
    

Compiling a method on an Instance requires a different check than when compiling 
a class.

Tests:

from bug test case source 
smokecheck
amazon
webtop/lzmail client 





Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java	2007-11-01 16:32:12 UTC (rev 7079)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java	2007-11-01 17:58:01 UTC (rev 7080)
@@ -1207,7 +1207,7 @@
             // Method declarations inside of class definitions will be already checked elsewhere,
             // in the call from ClassCompiler.updateSchema to schema.addElement
             if (!"class".equals(classname)) {
-                schema.checkMethodDeclaration(element, classname, name, env);
+                schema.checkInstanceMethodDeclaration(element, classname, name, env);
             }
         }
 

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java	2007-11-01 16:32:12 UTC (rev 7079)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java	2007-11-01 17:58:01 UTC (rev 7080)
@@ -216,6 +216,39 @@
         }
     }
 
+    /** Checks to do when declaring a method on an instance;
+     * Does the class exist?
+     * Does the superclass allow overriding of this method?
+     */
+    public void checkInstanceMethodDeclaration (Element elt, String classname, String methodName,
+                                        CompilationEnvironment env) {
+        ClassModel classModel = getClassModel(classname);
+        if (classModel == null) {
+            throw new RuntimeException(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="undefined class: " + p[0]
+ */
+            org.openlaszlo.i18n.LaszloMessages.getMessage(
+                ViewSchema.class.getName(),"051018-168", new Object[] {classname})
+                                       );
+        }
+        AttributeSpec attrspec = classModel.getAttribute(methodName);
+        if ( attrspec != null) {
+            if (attrspec.type != METHOD_TYPE) {
+                env.warn(
+                    "Method named "+methodName+" on class "+classname+
+                    " conflicts with attribute with named "+methodName+" and type "+attrspec.type,
+                    elt);
+            }
+        }
+
+        if (!methodOverrideAllowed(classname, methodName)) {
+            env.warn("Method "+classname+"."+methodName+" is overriding a superclass method"
+                     + " of the same name which has been declared non-overridable" , elt);
+        }
+    }
+
     public String getSuperclassName(String className) {
         ClassModel model = getClassModel(className);
         if (model == null)
@@ -401,7 +434,7 @@
         if (mClassMap.get(classname) == null) {
             mClassMap.put(classname, info);
         } else {
-            throw new CompilationError("makeNewStaticClass: duplicate definition for static class " + classname);
+            throw new CompilationError("makeNewStaticClass: `duplicate definition for static class " + classname);
         }
     }
 



More information about the Laszlo-checkins mailing list