royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-compiler] 01/02: let local classes (classes in the same file but outside the package) win over global classes
Date Mon, 22 Oct 2018 05:43:59 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 4cc22a09dbcc9110183e672f32852c0343a1fbf1
Author: Alex Harui <aharui@apache.org>
AuthorDate: Sun Oct 21 22:43:09 2018 -0700

    let local classes (classes in the same file but outside the package) win over global classes
---
 .../royale/compiler/internal/projects/RoyaleProject.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
index 55f336d..903889d 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
@@ -2169,6 +2169,10 @@ public class RoyaleProject extends ASProject implements IRoyaleProject,
ICompile
         String thisPackage = null;
         if (scopeDef != null) 
             thisPackage = scopeDef.getPackageName();
+        else if (scope instanceof ASFileScope)
+        {
+        	thisPackage = "";
+        }
         else
         {
             while (!(scope instanceof PackageScope))
@@ -2208,6 +2212,18 @@ public class RoyaleProject extends ASProject implements IRoyaleProject,
ICompile
             // that they meant the one they did import
             if (!usingWindow)
             {
+            	// but if no packages at all first see if it is a local class
+            	if (package1.length() == 0 && package2.length() == 0)
+            	{
+            		if (pkgScope instanceof PackageScope)
+            			pkgScope = pkgScope.getContainingScope();
+            		if (pkgScope.getAllLocalNames().contains(name))
+            		{
+            			IDefinitionSet defSet = pkgScope.getLocalDefinitionSetByName(name);
+            			if (defSet.getSize() == 1)
+            				return defSet.getDefinition(0);
+            		}
+            	}
                 return package1.length() == 0 ? def2 : def1;
             }
             // otherwise fall through to ambiguous because they need to qualify


Mime
View raw message