Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327334 - [compiler] generated lift methods fail to detect some lifting ambiguities
Summary: [compiler] generated lift methods fail to detect some lifting ambiguities
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 0.7.1   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 0.8 M3   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 09:22 EDT by Stephan Herrmann CLA
Modified: 2010-11-11 08:54 EST (History)
0 users

See Also:


Attachments
fix (15.22 KB, patch)
2010-10-20 17:32 EDT, Stephan Herrmann CLA
no flags Details | Diff
additional fix (11.64 KB, patch)
2010-10-23 19:31 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-10-08 09:22:42 EDT
Failures in BindingAmbiguities1.test731_ambiguousBinding7() f. show that
the generated liftTo methods create a role object in a specific situation
where actually a LiftingFailedException should be thrown.

This problem was probably introduced by the change from using base class tags
towards using instanceof or "getClass() == xy" checks.

In test731_ambiguousBinding7() a T731ab7_3 is wrongly lifted to a
Role731ab7_3 (despite the ambiguity to Role731ab7_4).
This happends because the Role731ab7_2 branch (OK using exact type comparison)
blindly OR-s instanceof checks for all known subBases (here T731ab7_3).

Attempts to fix the above caused that test731_ambiguousBinding9() wrongly 
throws a LiftingFailedException.
Here, T731ab9_4 is an acceptable subclass of T731ab9_2. This shows that indeed
instanceof checks are required at some point, though in combination with
other checks as to *exclude* the ambiguous subclass T731ab9_3.
Comment 1 Stephan Herrmann CLA 2010-10-20 17:32:11 EDT
Created attachment 181341 [details]
fix

Fixed by actually performing a simplification:
- no longer filter ambiguous roles from the array of relevant roles
- do not use exact type checks but rely on the order of generated
  instanceof checks: most specifics come first
+ add explicit case statements for throwing LiftingFailedException
  if an ambiguous base is the most specific match.
Comment 2 Stephan Herrmann CLA 2010-10-23 19:31:23 EDT
Created attachment 181585 [details]
additional fix

More fixes:
- Sorting must consider roles (fully connected hierarchy) and bases 
  (hierarchy may contain holes)
  fixes regression in BindingAmbiguitiesM.test73M_ambiguousBinding2()
- simplify generated code by avoiding duplicates in relevantRoles 
  (use set instead of list)
  also avoid adding nulls to simplify iterating

Other related fixes have been committed as:
r974:
fixed a regression (NPE) in test219_playedbyInheritance4, triggered 
(but not caused) by r967

r975
fix regression re test921_hasRoleMethod5c2
->  more precise analysis of when binding ambiguity is relevant 
    (consider base & static role type).
Comment 3 Stephan Herrmann CLA 2010-10-24 05:43:31 EDT
With all listed fixes all tests pass again, marking as fixed.
Comment 4 Stephan Herrmann CLA 2010-11-11 08:54:22 EST
Verified for 0.8 M3 using build 201011100445
(by inspecting tests in BindingAmbiguities*).