Community
Participate
Working Groups
I just found this odd behaviour: The following error is thrown in this code: No enclosing instance of the type MyTeam is accessible in scope (Compiler Error, please report) The code: package otb; public class Main { public static void main(String[] args){ MyTeam t = new MyTeam(); B b = new B(); A[] as = t.getAs(b); } } package otb; public team class MyTeam { protected class RoleA playedBy A { } protected class RoleB playedBy B { protected RoleA[] getAs(){ return new RoleA[0]; } } public RoleA[] getAs(B as RoleB rb) { return rb.getAs(); } } It works fine if either used without an array or by returning the basetype array in the getAs() method. greetings Jan Marc
I can reproduce, thanks for the report.
Created attachment 182523 [details] test & fix
Patch has been committed as r983 f.
When trying this fix in real life, the OT builder throws: need to create transform method, but have no source type: otb.MyTeam at org.eclipse.objectteams.otdt.internal.core.compiler.lifting.ArrayTranslations.ensureTransformMethod(ArrayTranslations.java:146) at org.eclipse.objectteams.otdt.internal.core.compiler.lifting.ArrayTranslations.translateArray(ArrayTranslations.java:98) at org.eclipse.objectteams.otdt.internal.core.compiler.lifting.ArrayLowering.lowerArray(ArrayLowering.java:55) at org.eclipse.objectteams.otdt.internal.core.compiler.lifting.Lowering.lowerExpression(Lowering.java:95) at org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.InsertTypeAdjustmentsVisitor.maybeWrap(InsertTypeAdjustmentsVisitor.java:320) at org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.InsertTypeAdjustmentsVisitor.endVisit(InsertTypeAdjustmentsVisitor.java:113) at org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.InsertTypeAdjustmentsVisitor.endVisit(InsertTypeAdjustmentsVisitor.java:86) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:317) Here we indeed have a problem: the type Main requires that MyTeam has an array-lowering method, but it may be too late to generate that method when the need is detected. I don't see an easy fix right now.
Created attachment 184546 [details] fix for the remaining problem The remaining problem has been fixed by generating array lowering for all externally visible methods returning an array of roles. I forced the test to run into this issue by defining a compileOrder.
Second fix has been committed as r1124 f.
Verified for M4 using build 201012150343
Setting the iplog flag to acknowledge the contributed test case in comment 0.