]> source.dussan.org Git - aspectj.git/commitdiff
Add method ArrayReferenceType.equals to fix failing tests
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 26 Jun 2023 06:11:38 +0000 (08:11 +0200)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 26 Jun 2023 06:48:27 +0000 (13:48 +0700)
This also fixes a bug. Previously, ResolvedType.equals was used for
equality check, and in there is a '==' comparison, which does not work
for two different ArrayReferenceType instances, even if the component
type is the same.

Relates to #246.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.matcher/src/main/java/org/aspectj/weaver/ArrayReferenceType.java
tests/bugs1920/github_246/ITDAspect.aj
tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml

index 23aaa2e5e6c78e53b4288749b6facf23206f4db4..76d947e7609d1289de835dad9eeca2f9a7d63f96 100644 (file)
@@ -208,4 +208,12 @@ public class ArrayReferenceType extends ReferenceType {
                        return false;
                }
        }
+
+       @Override
+       public boolean equals(Object other) {
+               if (other instanceof ArrayReferenceType)
+                       return componentType.equals(((ArrayReferenceType) other).componentType);
+               return super.equals(other);
+       }
+
 }
index fffef16513130109ee373b7c0d5d60bfe6dfd054..7e4f30e3f846c00d3d6de57e9c60b43f7750ac1d 100644 (file)
@@ -10,4 +10,14 @@ public aspect ITDAspect {
   public int App.foo(int parameter) {
     return parameter + 3;
   }
+
+  public void App.foo(String... parameters) { }
+
+  @Second
+  public int App.foo(int... parameters) {
+    int sum = 0;
+    for (int parameter : parameters)
+      sum += parameter;
+    return sum;
+  }
 }
index 2026df491bc22d6f9264434f3191d2718171e5e5..9f072c86d304c66e9adb5573805cedd389da1d55 100644 (file)
                <compile files="First.java Second.java App.java ITDAspect.aj" options="-8"/>
                <run class="App">
                        <stdout>
-                               <line text="[@First(), @Second()] public void App.foo(java.lang.Object)"/>
+                               <line text="[@Second()] public int App.foo(int[])"/>
                                <line text="[@First()] public void App.foo(java.lang.String)"/>
+                               <line text="[] public void App.foo(java.lang.String[])"/>
+                               <line text="[@First(), @Second()] public void App.foo(java.lang.Object)"/>
                                <line text="[@Second()] public int App.foo(int)"/>
                        </stdout>
                </run>