Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3CD7E200C32 for ; Thu, 9 Mar 2017 08:06:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3B62A160B67; Thu, 9 Mar 2017 07:06:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 84F50160B64 for ; Thu, 9 Mar 2017 08:06:05 +0100 (CET) Received: (qmail 94543 invoked by uid 500); 9 Mar 2017 07:06:04 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 94535 invoked by uid 99); 9 Mar 2017 07:06:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Mar 2017 07:06:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 33137DFE1E; Thu, 9 Mar 2017 07:06:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-falcon] [refs/heads/develop] - fix interface override checking Date: Thu, 9 Mar 2017 07:06:04 +0000 (UTC) archived-at: Thu, 09 Mar 2017 07:06:06 -0000 Repository: flex-falcon Updated Branches: refs/heads/develop 6e14d6835 -> dad773a21 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/develop Commit: dad773a2193b5a80aee1e5a5f82d30b82ac19431 Parents: 6e14d68 Author: Alex Harui Authored: Wed Mar 8 22:42:14 2017 -0800 Committer: Alex Harui 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);; + } + }