Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318084

Summary: [compiler] cannot callin-bind a callout-defined method
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTJAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.7   
Target Milestone: 0.7.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
implementation part 1
none
additional fixes
none
additional fixes
none
additional fixes none

Description Stephan Herrmann CLA 2010-06-26 11:59:56 EDT
If a role contains two method bindings like this:
  void k() <- after void test();
  void k() -> void k();
the callin binding cannot resolve its role method.
See test1122_layeredTeams8() for a witness.

This is a compile order problem and suggest that callout
method bindings should actually be resolved and transformed
no later than STATE_METHODS_CREATED.
Comment 1 Stephan Herrmann CLA 2010-06-26 12:11:09 EDT
Deferring post 0.7.0 due to potentially wide impact.
Comment 2 Stephan Herrmann CLA 2010-07-17 17:45:04 EDT
Created attachment 174567 [details]
implementation part 1

This patch implements the change in compile order:

 * integrate wrapTypesInMethodDeclSignature into
   SourceTypeBinding.resolveTypesFor(MethodBinding) (unified for roles/teams).
   (was: STATE_TYPES_ADJUSTED)

 * defer some actions on parameter mappings until
   MethodMappingImplementor.makeWrapperCallArguments:
   - replace SingleNameReference("result") with ResultReference
     (was: TransformStatementsVisitor for STATE_STATEMENTS_TRANSFORMED)
     (using new class ReplaceResultReferenceVisitor extracted from
      TransformStatementsVisitor)
   - check replace for replace callin
     (was: CallinMappingDeclaration.checkResultForReplace for
      STATE_MAPPINGS_RESOLVED)

 * resolve mappings and transform callouts from establishMethodsCreated()
   (was: STATE_MAPPINGS_RESOLVED & STATE_MAPPINGS_TRANSFORMED)

The patch also contains some cleanup (resolve warnings)

TODO:
* should signature weakening be integrated into resolveTypesFor(..), too?
    CopyInheritance.weakenTeamMethodSignatures(teamDecl)
    CopyInheritance.weakenInterfaceSignatures(..)
    CopyInheritance.weakenSignaturesFromSupers(..)
* remove STATE_MAPPINGS_RESOLVED
* move from Dependencies to proper locations:
  - resolveMethodMappings, transformCallouts

Patch has already been committed for testing as r581.
Comment 3 Stephan Herrmann CLA 2010-07-18 06:41:36 EDT
Created attachment 174575 [details]
additional fixes

Fine-tuning compile order to fix regressions caused by the previous patch:
* consistently handle CALLIN_FLAG_BASE_SUPER_CALL during analyseCode:
  * move setting the flag BaseCallMessageSend.analyseCode, this is not a
    transformation and thus has nothing to do in TransformStatementsVisitor
  * move checking against this flag to CallinMappingDeclaration.analyseDetails
    (this method has been combined with checkBaseResult()):
    this check needs the flag to be set and thus cannot be performed during
    resolveMethodMappings().
* create base call surrogates between LATE_ATTRIBUTES_EVALUATED and RESOLVED:
  needs inherited callin bindings but must happen before resolve()

Patch has already been committed for testing as r583.
Comment 4 Stephan Herrmann CLA 2010-07-18 07:38:27 EDT
Created attachment 174576 [details]
additional fixes

Cleanup:
(In reply to comment #2)
> TODO:
> * remove STATE_MAPPINGS_RESOLVED

Done.
Also:
- renamed STATE_MAPPINGS_TRANSFORMED to STATE_CALLINS_TRANSFORMED
- reduce 2x ensureState(MAPPINGS_TRANSFORMED) to METHODS_CREATED

> * move from Dependencies to proper locations:
>   - resolveMethodMappings, transformCallouts

Done.
A few helper methods have been extracted from establishMethodsCreated.

Patch has already been committed for testing as r585.
Comment 5 Stephan Herrmann CLA 2010-07-24 06:50:04 EDT
Created attachment 175129 [details]
additional fixes

Final fixes
- fine grained order: resolve callout, generate callout decl, resolve callin
- handle private shorthand callout:
  - don't generate ifc-part,
  - don't make class-part public

Test test1122_layeredTeams8 now passes.
Comment 6 Stephan Herrmann CLA 2010-07-24 06:51:33 EDT
With last patch committed as r638 this issue is now resolved.
Comment 7 Stephan Herrmann CLA 2010-09-22 17:34:49 EDT
Verified using I201009211735