--- /dev/null
+// TESTING: invalid return type for factory method
+import org.aspectj.lang.annotation.*;
+
+public class CaseJ {
+ public static void main(String[]argv) { }
+}
+
+aspect X {
+ @DeclareMixin("A")
+ public static void createImplementation1() {}
+
+ @DeclareMixin("A")
+ public static int createImplementation2(Object o) {return 2;}
+}
+
+interface I {}
+
--- /dev/null
+// TESTING: too many arguments to the factory method
+import org.aspectj.lang.annotation.*;
+
+public class CaseK {
+ public static void main(String[]argv) { }
+}
+
+aspect X {
+ @DeclareMixin("A")
+ public static I createImplementation1(String s,long foo) {return null;}
+
+}
+
+interface I {}
+
* In many ways the design is similar to DeclareParents now - so we have to plug in at the same points, but the code generation for
* generating the delegate object and the choice of which interfaces (and methods within those) to mixin is different.
*
- * <h4>Design and test considerations:</h4><br>
+ * <h4>Tested:</h4><br>
+ * <ul>
+ * <li>Factory method with void or primitive return value
+ * <li>Check the factory method has at most one parameter
+ * </ul>
+ *
+ * <h4>Still to test/explore:</h4><br>
* <ul>
* <li>model relationships
* <li>incremental compilation
* <li>Clashing with existing methods
* <li>varying parameter type on the factory method
* <li>See CaseF - what if mixin target is not assignable to the parameter type? create cast?
- * <li>Check the factory method has at most one parameter
* </ul>
*
* @author Andy Clement
runTest("casei");
}
+ // invalid return type for factory method
+ public void testCaseJ() {
+ runTest("casej");
+ }
+
+ // too many arguments to the factory method
+ public void testCaseK() {
+ runTest("casek");
+ }
+
// --
public static Test suite() {
<message kind="error" text="Types listed in the 'interfaces'"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="features164/declareMixin" title="casej">
+ <compile files="CaseJ.java" options="-1.5">
+ <message kind="error" text="createImplementation1"/>
+ <message kind="error" text="Method 'int X.createImplementation2(java.lang.Object)': factory methods "/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features164/declareMixin" title="casek">
+ <compile files="CaseK.java" options="-1.5">
+ <message kind="error" text="factory methods for a mixin can take a maximum of one parameter"/>
+ </compile>
+ </ajc-test>
</suite>
\ No newline at end of file