Bug 318815 - [otjld] [compiler] Support the "Internal Role" pattern
Summary: [otjld] [compiler] Support the "Internal Role" pattern
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 0.7   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 0.7.1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2010-07-04 09:53 EDT by Stephan Herrmann CLA
Modified: 2010-09-23 11:22 EDT (History)
0 users

See Also:


Attachments
proposed implementation (30.39 KB, patch)
2010-07-09 12:04 EDT, Stephan Herrmann CLA
no flags Details | Diff
additional patch (1.78 KB, patch)
2010-07-09 15:18 EDT, Stephan Herrmann CLA
no flags Details | Diff
ui-part (3.79 KB, patch)
2010-07-09 16:46 EDT, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2010-07-04 09:53:15 EDT
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.
Comment 1 Stephan Herrmann CLA 2010-07-08 17:15:07 EDT
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.
Comment 2 Stephan Herrmann CLA 2010-07-09 12:04:54 EDT
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)
Comment 3 Stephan Herrmann CLA 2010-07-09 12:07:04 EDT
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.
Comment 4 Stephan Herrmann CLA 2010-07-09 15:18:52 EDT
Created attachment 173901 [details]
additional patch

This patch fixes an NPE in the initial implementation.
Comment 5 Stephan Herrmann CLA 2010-07-09 16:46:31 EDT
Created attachment 173918 [details]
ui-part

Implementation of UI-configurability for new warning token "baseclasscycle".
Comment 6 Stephan Herrmann CLA 2010-09-23 11:22:15 EDT
Verified using I201009211735