From: aclement Date: Thu, 29 Jan 2009 23:56:36 +0000 (+0000) Subject: 256779: test and fix: decp lazy resolution in anno style X-Git-Tag: pre268419~163 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=79eda2ed361fc73ae14e9c96b6c6c9f1174ba5f6;p=aspectj.git 256779: test and fix: decp lazy resolution in anno style --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java index cefec1661..896344557 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java @@ -26,6 +26,7 @@ import org.aspectj.weaver.World; public class DeclarePrecedence extends Declare { private TypePatternList patterns; + private IScope scope = null; // non-null means it has not yet been resolved (used by annotation style lazy resolution) public DeclarePrecedence(List patterns) { this(new TypePatternList(patterns)); @@ -76,13 +77,21 @@ public class DeclarePrecedence extends Declare { return ret; } - boolean underResolution = false; + public void setScopeForResolution(IScope scope) { + this.scope = scope; + } + + public void ensureResolved() { // Lazy resolution - due to pr256779 + if (scope != null) { + try { + resolve(scope); + } finally { + scope = null; + } + } + } public void resolve(IScope scope) { - // if (underResolution) { - // return; - // } - // underResolution = true; patterns = patterns.resolveBindings(scope, Bindings.NONE, false, false); boolean seenStar = false; @@ -101,7 +110,8 @@ public class DeclarePrecedence extends Declare { continue; // Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+' - if (!exactType.isAspect() && !pi.isIncludeSubtypes() && !exactType.isTypeVariableReference()) { + if (!exactType.isAspect() && !exactType.isAnnotationStyleAspect() && !pi.isIncludeSubtypes() + && !exactType.isTypeVariableReference()) { scope.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CLASSES_IN_PRECEDENCE, exactType.getName()), pi.getSourceLocation(), null); @@ -119,15 +129,16 @@ public class DeclarePrecedence extends Declare { pi.getSourceLocation(), pj.getSourceLocation()); } } - // underResolution = false; } } public TypePatternList getPatterns() { + ensureResolved(); return patterns; } private int matchingIndex(ResolvedType a) { + ensureResolved(); int knownMatch = -1; int starMatch = -1; for (int i = 0, len = patterns.size(); i < len; i++) { @@ -152,6 +163,7 @@ public class DeclarePrecedence extends Declare { } public int compare(ResolvedType aspect1, ResolvedType aspect2) { + ensureResolved(); int index1 = matchingIndex(aspect1); int index2 = matchingIndex(aspect2);