]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/NameExistenceChecks.java
(refs #7459) Fixed check for alread defined value name in the module.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / compilation / NameExistenceChecks.java
index d21e215f6ac0e156d4135e93ded5e58eeeb9539e..b9f2f8597a03f8a0cd74b2a74082ca363adb663b 100644 (file)
@@ -5,24 +5,30 @@ import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
 import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.ErrorLog;
+import org.simantics.scl.compiler.module.ConcreteModule;
 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
 
 public class NameExistenceChecks {
     public static void checkIfValueExists(ErrorLog errorLog, long location,
-            Environment environment, String name) {
-        if(SCLCompilerConfiguration.ALLOW_OVERLOADING)
+            Environment environment, ConcreteModule currentModule, String name) {
+        if(SCLCompilerConfiguration.ALLOW_OVERLOADING) {
+            if(currentModule.getValue(name) != null) {
+                errorLog.log(location,
+                        "Value " + name + " has already been defined in this module.");
+            }
             return;
+        }
         else {
             try {
                 SCLValue value = environment.getLocalNamespace().getValue(name);
                 if(value != null)
                     errorLog.log(location,
-                            "Value " + name + " is already defined in the module " + 
+                            "Value " + name + " has already been defined in the module " + 
                                     value.getName().module + 
                             " that is imported to the default namespace.");
             } catch(AmbiguousNameException e) {
                 errorLog.log(location,
-                        "Value " + name + " is already defined in the modules " + 
+                        "Value " + name + " has already been defined in the modules " + 
                                 e.conflictingModules[0] + " and  " + e.conflictingModules[1] +  
                         " that are imported to the default namespace.");
             }
@@ -35,12 +41,12 @@ public class NameExistenceChecks {
             TypeDescriptor tdesc = environment.getLocalNamespace().getTypeDescriptor(name);
             if(tdesc != null)
                 errorLog.log(location,
-                        "Type " + name + " is already defined in the module " + 
+                        "Type " + name + " has already been defined in the module " + 
                                 tdesc.name.module + 
                         " that is imported to the default namespace.");
         } catch(AmbiguousNameException e) {
             errorLog.log(location,
-                    "Type " + name + " is already defined in the modules " + 
+                    "Type " + name + " has already been defined in the modules " + 
                             e.conflictingModules[0] + " and  " + e.conflictingModules[1] +  
                     " that are imported to the default namespace.");
         }