Community
Participate
Working Groups
As discussed in http://www.eclipse.org/forums/index.php?t=msg&&th=162947&goto=515854#msg_515854 the rules of OT/J could be relaxed to support the "Internal Role" pattern by Graversen et al. This implies to remove the restriction, that a role cannot be played by an enclosing type (2.1.2(b)). The change is not trivial because we'd want to give hints when such circularity of containment and role-playing could result in unwanted recursions at runtime.
While working on this and turning test212_boundToRelatedClass3() into a positive test I noticed that callout transformation failed, because of a compile order problem: - establishMethodMappingsResolved(RoleModel role) requires that the baseclass has STATE_MAPPINGS_TRANSFORMED - if baseclass is an enclosing, it is not ready for mapping transformation because it is currently busy resolving those mappings. This appears to be a special instance of the compiler order issue from bug 318084.
Created attachment 173878 [details] proposed implementation * new diagnostics: - make errors baseclassCircularity/playedByEnclosing configurable (core only) - token = "baseclasscycle", def=warn - tag roles as _playedByEnclosing as precond for next two errors: - new errors: BaseAllocationDespiteBaseclassCycle, CalloutToEnclosing * improve detection of baseclass circularity: - also consider supers of enclosings (see test212_boundToRelatedClass5) * avoid compile order problem by skipping ensureBindingState(baseclass, STATE_MAPPINGS_TRANSFORMED) when _playedByEnclosing was detected * more and changed tests (not part of the patch) - new errors (test212_boundToRelatedClass3, test214_boundToRelatedTeam1) - new positive case (test212_boundToRelatedClass4) - bound to super of enclosing team (test212_boundToRelatedClass5) - indirect baseclass circularity (test212_boundToRelatedClass6) - simulate original inf.recursion with direct outer-call instead of callout (test214_boundToRelatedTeam2) - challenge configuring "baseclasscycle" (ERROR, suppress - several tests)
Patch has been committed as r570, r571. Since callout in affected roles is now an error anyway, the dependency to bug 318084 no longer exists.
Created attachment 173901 [details] additional patch This patch fixes an NPE in the initial implementation.
Created attachment 173918 [details] ui-part Implementation of UI-configurability for new warning token "baseclasscycle".
Verified using I201009211735