You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2017/04/13 17:43:35 UTC

[04/50] git commit: [flex-falcon] [refs/heads/dual] - fix interface override checking

fix interface override checking


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/dad773a2
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/dad773a2
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/dad773a2

Branch: refs/heads/dual
Commit: dad773a2193b5a80aee1e5a5f82d30b82ac19431
Parents: 6e14d68
Author: Alex Harui <ah...@apache.org>
Authored: Wed Mar 8 22:42:14 2017 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Wed Mar 8 22:42:14 2017 -0800

----------------------------------------------------------------------
 .../semantics/MethodBodySemanticChecker.java    |  7 +++
 .../src/test/java/as/ASInheritanceTests.java    | 59 ++++++++++++++++++++
 2 files changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dad773a2/compiler/src/main/java/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java b/compiler/src/main/java/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
index 1b51727..3904823 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -2799,7 +2799,14 @@ public class MethodBodySemanticChecker
         if( conflicts.size() > 0 )
         {
             for( IFunctionDefinition overriden : conflicts )
+            {
+            	if ((overriden instanceof SetterDefinition &&
+            		funcDef instanceof GetterDefinition) ||
+            		(overriden instanceof GetterDefinition &&
+            		funcDef instanceof SetterDefinition))
+            		continue;
                 addProblem(new InterfaceMethodOverrideProblem(iNode, funcDef.getBaseName(), overriden.getParent().getBaseName()));
+            }
         }
 
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dad773a2/compiler/src/test/java/as/ASInheritanceTests.java
----------------------------------------------------------------------
diff --git a/compiler/src/test/java/as/ASInheritanceTests.java b/compiler/src/test/java/as/ASInheritanceTests.java
index 4d1d393..b5833e1 100644
--- a/compiler/src/test/java/as/ASInheritanceTests.java
+++ b/compiler/src/test/java/as/ASInheritanceTests.java
@@ -83,4 +83,63 @@ public class ASInheritanceTests  extends ASFeatureTestsBase{
 
         compileAndExpectErrors(source, false,false,false, null,"No default constructor found in base class A.\n");
     }
+    
+    @Test
+    public void InterfaceOverrideError()
+    {
+        // all tests can assume that flash.display.Sprite
+        // flash.system.System and flash.events.Event have been imported
+        String[] imports = new String[]
+                {
+                };
+        String[] declarations = new String[]
+                {
+                };
+        String[] testCode = new String[]
+                {
+
+                };
+        String[] extra = new String[]
+                {
+                        "interface A {",
+                        "function get text():String;",
+                        "}",
+                        "interface B extends A {",
+                        "function get text():String;",
+                        "}"
+                };
+        String source = getAS(imports, declarations, testCode, extra);
+
+        compileAndExpectErrors(source, false,false,false, null,"Cannot override an interface method.  Method text conflicts with a method in base interface A.\n");
+    }
+
+    @Test
+    public void InterfaceOverrideOK()
+    {
+        // all tests can assume that flash.display.Sprite
+        // flash.system.System and flash.events.Event have been imported
+        String[] imports = new String[]
+                {
+                };
+        String[] declarations = new String[]
+                {
+                };
+        String[] testCode = new String[]
+                {
+
+                };
+        String[] extra = new String[]
+                {
+                        "interface A {",
+                        "function get text():String;",
+                        "}",
+                        "interface B extends A {",
+                        "function set text(value:String):void;",
+                        "}"
+                };
+        String source = getAS(imports, declarations, testCode, extra);
+
+        compileAndRun(source);;
+    }
+
 }