Community
Participate
Working Groups
Java Compiler error The method ezeSet(int, EglAny) in the type EglList<EglAny> is not applicable for the arguments (int, Delegate) ============================= EGL CODE ================= library tester {} function runTests() // not ok runTestMtds runTestMethod[] = [EBoolean003.runTestConversions02, EBoolean003.runTestConversions03]; end function runtTests2() // ok runTestMtds runTestMethod[2]; runTestMtds[1] = EBoolean003.runTestConversions02; runTestMtds[2] = EBoolean003.runTestConversions03; end end delegate runTestMethod() end ================================== package explore; // basic library library EBoolean003 {} // Function Declarations function runTestConversions02() end function runTestConversions03() end end
Lowered importance because Jing is going to change the code generated by the test framework so we won't get this problem.
I've talked at length with Tim on this. The testcase is invalid and needs to change. This technique is wrong for delegates because there is no type for delegates, so Paul you need to cause validation to prevent this style of coding: runTestMtds runTestMethod[] = [EBoolean003.runTestConversions02, EBoolean003.runTestConversions03]; However, this is the acceptible style and the testcase should be changed to reflect this: runTestMtd runTestMethod[] {EBoolean003.runTestConversions02, EBoolean003.runTestConversions03};
Jeff, I think there should be a question mark on the element type of the array: runTestMethod?[] not runTestMethod[]. Variables of types that can't be instantiated, such as Any and delegates, must always be declared nullable. So doesn't it follow that they must be nullable when they're elements of an array? Did you go over this issue when you spoke with Tim?
I've modified the code testcase to work like this. I haven't closed the defect due to the open question about nullablty of delegates arrays. I'll let development resolve this defect. ================================ package explore; library tester {} function runtTests2() runTestMtds runTestMethod[]{EBoolean003.runTestConversions02,EBoolean003.runTestConversions03}; runTestMtds[1](); runTestMtds[2](); end function runtTests1() runTestMtds runTestMethod[]; runTestMtds.appendElement(EBoolean003.runTestConversions02); runTestMtds.appendElement(EBoolean003.runTestConversions03); runTestMtds[1](); runTestMtds[2](); end end delegate runTestMethod() end =================== package explore; library EBoolean003 {} function runTestConversions02() syslib.writestdout("runTestConversions02"); end function runTestConversions03() syslib.writestdout("runTestConversions03"); end End ============== package explore; program driver type BasicProgram {} use tester; function main() tester.runtTests1(); tester.runtTests2(); end end
I disagree with making this a validation error, which is just as well, since generation seems to have been modified so that the original coding style now produces java that compiles. I have tested this with a variety of ways of initializing the array of delegates and all cases work fine. Here is my testcase: package pkg1; library lib2 {} del1 runTestMethod = f1; del2 runTestMethod = f2; function runTests() runTestMtds1 runTestMethod[] = [f1, f2]; runTestMtds2 runTestMethod[] = [del1, del2]; end function runtTests2() // ok runTestMtds runTestMethod?[] = new runTestMethod?[2]; runTestMtds[1] = f1; runTestMtds[2] = f2; runTestMtds[1] = del1; runTestMtds[2] = del2; end function runtTest3() runTestMtds runTestMethod[]; runTestMtds.appendElement(f1); runTestMtds.appendelement(f2); runTestMtds.appendElement(del1); runTestMtds.appendelement(del2); end function runTests4() runTestMtds runTestMethod[] {f1, f2, del1, del2}; end function f1() end function f2() end end delegate runTestMethod() end
verified 20111027_1153 & closed