From: jhugunin Date: Fri, 11 Apr 2003 00:48:49 +0000 (+0000) Subject: fixing declare parents problems X-Git-Tag: V1_1_0_RC2~179 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=039d04d39da57d5ef47193509a364d9ceed9b98e;p=aspectj.git fixing declare parents problems --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index c2bf0e41a..868499adc 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -191,58 +191,30 @@ public class AjLookupEnvironment extends LookupEnvironment { } private void doDeclareParents(DeclareParents declareParents, SourceTypeBinding sourceType) { - if (declareParents.match(factory.fromEclipse(sourceType))) { - TypePatternList l = declareParents.getParents(); - for (int i=0, len=l.size(); i < len; i++) { - addParent(declareParents, sourceType, l.get(i)); + List newParents = declareParents.findMatchingNewParents(factory.fromEclipse(sourceType)); + if (!newParents.isEmpty()) { + for (Iterator i = newParents.iterator(); i.hasNext(); ) { + ResolvedTypeX parent = (ResolvedTypeX)i.next(); + addParent(sourceType, parent); } } } - private void addParent(DeclareParents declareParents, SourceTypeBinding sourceType, TypePattern typePattern) { - if (typePattern == TypePattern.NO) return; // already had an error here - TypeX iType = typePattern.getExactType(); - ReferenceBinding b = (ReferenceBinding)factory.makeTypeBinding(iType); //" - - if (b.isClass()) { - if (sourceType.isInterface()) { - factory.showMessage(IMessage.ERROR, - "interface can not extend a class", - declareParents.getSourceLocation(), null - ); - // how to handle xcutting errors??? - } - - if (sourceType == b || sourceType.isSuperclassOf(b)) { - factory.showMessage(IMessage.ERROR, - "class can not extend itself", declareParents.getSourceLocation(), null - ); - return; - } - sourceType.superclass = b; + private void addParent(SourceTypeBinding sourceType, ResolvedTypeX parent) { + ReferenceBinding parentBinding = (ReferenceBinding)factory.makeTypeBinding(parent); + if (parentBinding.isClass()) { + sourceType.superclass = parentBinding; } else { - //??? it's not considered an error to extend yourself, nothing happens - if (sourceType.equals(b)) { - return; - } - - if (sourceType.isInterface() && b.implementsInterface(sourceType, true)) { - factory.showMessage(IMessage.ERROR, - "interface can not extend itself", declareParents.getSourceLocation(), null - ); - return; - } - if (sourceType == b || b.isSuperclassOf(sourceType)) return; ReferenceBinding[] oldI = sourceType.superInterfaces; ReferenceBinding[] newI; if (oldI == null) { newI = new ReferenceBinding[1]; - newI[0] = b; + newI[0] = parentBinding; } else { int n = oldI.length; newI = new ReferenceBinding[n+1]; System.arraycopy(oldI, 0, newI, 0, n); - newI[n] = b; + newI[n] = parentBinding; } sourceType.superInterfaces = newI; } diff --git a/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java b/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java index 745fb67c9..6ed5f5680 100644 --- a/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java +++ b/org.aspectj.ajdt.core/testdata/src1/ParentsFail.java @@ -18,5 +18,5 @@ aspect A { declare parents: C2 implements I; // CE can't implement declare parents: C2 extends C3; // CE circular - declare parents: C1 extends C1; // CE self + declare parents: C1 extends C1; // not considered a CE, just does nothing } \ No newline at end of file diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java index 650b2a37c..2326c3126 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompileAndRunTestCase.java @@ -44,7 +44,7 @@ public class CompileAndRunTestCase extends CommandTestCase { } public void testDeclareParentsFail() throws IOException { - CommandTestCase.checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19, 21}); + CommandTestCase.checkCompile("src1/ParentsFail.java", new int[] {3, 11, 19}); } public void testDeclareParents() throws IOException { diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 97927ea16..6d4fd67b9 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -5781,5 +5781,27 @@ + + + + + + + + + + + + + + + + diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 27b67e5b0..1b2b82f8c 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -4,19 +4,6 @@ - - - - - - - - - - + diff --git a/tests/jimTests.xml b/tests/jimTests.xml index 7664c3799..cc3257d9f 100644 --- a/tests/jimTests.xml +++ b/tests/jimTests.xml @@ -1,7 +1,6 @@ -