diff options
author | acolyer <acolyer> | 2005-03-09 17:22:53 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-03-09 17:22:53 +0000 |
commit | a5e1a73048c9d8edf8834ec2ec34dc29ac61a31c (patch) | |
tree | a6fabf5310abd580ae320ecd40adde102bf884e9 /weaver | |
parent | 4ca8479d63c935c1942a41b31d7f6a0a26781dd3 (diff) | |
download | aspectj-a5e1a73048c9d8edf8834ec2ec34dc29ac61a31c.tar.gz aspectj-a5e1a73048c9d8edf8834ec2ec34dc29ac61a31c.zip |
fix for varargs example in AJDK - 9 failing tests now left in Ajc150...
Diffstat (limited to 'weaver')
6 files changed, 33 insertions, 5 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java index d72b84371..20cdea8ab 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java @@ -68,6 +68,12 @@ public class AndTypePattern extends TypePattern { return left.matchesStatically(type) && right.matchesStatically(type); } + public void setIsVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + left.setIsVarArgs(isVarArgs); + right.setIsVarArgs(isVarArgs); + } + public void write(DataOutputStream s) throws IOException { s.writeByte(TypePattern.AND); left.write(s); @@ -76,8 +82,9 @@ public class AndTypePattern extends TypePattern { } public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - TypePattern ret = new AndTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); + AndTypePattern ret = new AndTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); + if (ret.left.isVarArgs && ret.right.isVarArgs) ret.isVarArgs = true; return ret; } diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java index 1339c4dd8..5d948adca 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -229,9 +229,10 @@ public class ExactTypePattern extends TypePattern { buff.append(annotationPattern.toString()); buff.append(' '); } - buff.append(type.toString()); + String typeString = type.toString(); + if (isVarArgs) typeString = typeString.substring(0,typeString.lastIndexOf('[')); + buff.append(typeString); if (includeSubtypes) buff.append('+'); - // Note, there will be a rogue [] in the pattern here in the case of varargs ... if (isVarArgs) buff.append("..."); if (annotationPattern != AnnotationTypePattern.ANY) { buff.append(')'); diff --git a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java index 0d51c464e..642f09ace 100644 --- a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java @@ -72,6 +72,12 @@ public class OrTypePattern extends TypePattern { return left.matchesStatically(type) || right.matchesStatically(type); } + public void setIsVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + left.setIsVarArgs(isVarArgs); + right.setIsVarArgs(isVarArgs); + } + public void write(DataOutputStream s) throws IOException { s.writeByte(TypePattern.OR); left.write(s); @@ -80,8 +86,9 @@ public class OrTypePattern extends TypePattern { } public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - TypePattern ret = new OrTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); + OrTypePattern ret = new OrTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); + if (ret.left.isVarArgs && ret.right.isVarArgs) ret.isVarArgs = true; return ret; } diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index d33588f0c..17b6388c2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -542,6 +542,8 @@ public class PatternParser { TypePattern p = parseTypePattern(); p = setAnnotationPatternForTypePattern(p,ap); eat(")"); + boolean isVarArgs = maybeEat("..."); + p.setIsVarArgs(isVarArgs); return p; } int startPos = tokenSource.peek().getStart(); diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java index 333bfd574..3e3446ab3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java @@ -68,6 +68,10 @@ public abstract class TypePattern extends PatternNode { this.annotationPattern = annPatt; } + public void setIsVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + } + // answer conservatively... protected boolean couldEverMatchSameTypesAs(TypePattern other) { if (this.includeSubtypes || other.includeSubtypes) return true; @@ -492,7 +496,7 @@ class AnyWithAnnotationTypePattern extends TypePattern { } public boolean isStar() { - return true; + return false; } public String toString() { return annotationPattern+" *"; } diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index d869b4468..97a1ee019 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -66,6 +66,12 @@ public class WildTypePattern extends TypePattern { this.isVarArgs = isVarArg; } + // called by parser after parsing a type pattern, must bump dim as well as setting flag + public void setIsVarArgs(boolean isVarArgs) { + this.isVarArgs = isVarArgs; + if (isVarArgs) this.dim += 1; + } + /* (non-Javadoc) * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) */ @@ -564,6 +570,7 @@ public class WildTypePattern extends TypePattern { } } if (includeSubtypes) buf.append('+'); + if (isVarArgs) buf.append("..."); if (annotationPattern != AnnotationTypePattern.ANY) { buf.append(')'); } |