diff options
author | jhugunin <jhugunin> | 2003-04-11 00:48:49 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-04-11 00:48:49 +0000 |
commit | 039d04d39da57d5ef47193509a364d9ceed9b98e (patch) | |
tree | 98870c277b2da902ef8deda9f20b18aad0247b91 /org.aspectj.ajdt.core | |
parent | 11b3b0740b66f1d962b5179ece2f2d23e88f040b (diff) | |
download | aspectj-039d04d39da57d5ef47193509a364d9ceed9b98e.tar.gz aspectj-039d04d39da57d5ef47193509a364d9ceed9b98e.zip |
fixing declare parents problems
Diffstat (limited to 'org.aspectj.ajdt.core')
3 files changed, 13 insertions, 41 deletions
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 { |