Bug 212783 - [generics] [itds] ITD in generic aspect is not working correctly
Summary: [generics] [itds] ITD in generic aspect is not working correctly
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-12 12:06 EST by Andrew Clement CLA
Modified: 2013-06-24 11:03 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2007-12-12 12:06:38 EST
Discovered whilst migrating AspectJ to 1.6 JDT compiler.  Commenting out these 3 tests until it is addressed (run the tests to see the problem):

testSimplifiedGenericAspectITDTest(org.aspectj.systemtest.ajc150.Ajc150Tests)
junit.framework.AssertionFailedError: test "spurious override method warning - 3" failed
test "spurious override method warning - 3" failed
Unexpected error messages:
	error at INode<P, C> getParent();
            ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54148.tmp/SimpleTest.java:4:0::0 can't override INode<Tag,Tag> INode<Tag,Tag>.getParent() with INode<Parent,Child> INode.getParent() return types don't match
	error at public final INode<Parent, Child> INode.getParent() {
                                        ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54148.tmp/SimpleTest.java:10:0::0 can't override INode<Tag,Tag> INode<Tag,Tag>.getParent() with INode<Parent,Child> INode.getParent() return types don't match

testSpuriousOverrideMethodWarning_pr119570_1(org.aspectj.systemtest.ajc150.Ajc150Tests)
junit.framework.AssertionFailedError: test "spurious override method warning" failed
test "spurious override method warning" failed
Unexpected error messages:
	error at public final INode<Parent, Child> INode.getParent() {
                                        ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54149.tmp/NodeImpl.java:14:0::0 can't override bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag> bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag>.getParent() with bugsOtherPackage.INode<Parent,Child> bugsOtherPackage.INode.getParent() return types don't match
	error at INode<Parent, Child> getParent();
                     ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54149.tmp/INode.java:5:0::0 can't override bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag> bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag>.getParent() with bugsOtherPackage.INode<Parent,Child> bugsOtherPackage.INode.getParent() return types don't match

testSpuriousOverrideMethodWarning_pr119570_2(org.aspectj.systemtest.ajc150.Ajc150Tests)
junit.framework.AssertionFailedError: test "spurious override method warning - 2" failed
test "spurious override method warning - 2" failed
Unexpected error messages:
	error at public final INode<Parent, Child> INode.getParent() {
                                        ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54150.tmp/NodeImpl.java:14:0::0 can't override bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag> bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag>.getParent() with bugsOtherPackage.INode<Parent,Child> bugsOtherPackage.INode.getParent() return types don't match
	error at INode<Parent, Child> getParent();
                     ^^^^^^
/private/tmp/ajcSandbox/workspace-aj-merge/ajcTest54150.tmp/INode.java:5:0::0 can't override bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag> bugsOtherPackage.INode<bugs.TaggedTexts$Tag,bugs.TaggedTexts$Tag>.getParent() with bugsOtherPackage.INode<Parent,Child> bugsOtherPackage.INode.getParent() return types don't match
Comment 1 Andrew Clement CLA 2007-12-12 12:19:26 EST
Also this test:

MultiProjectIncrementalTests.testPr119570
Comment 2 Andrew Clement CLA 2008-08-20 13:14:15 EDT
Also affects the other variations of 119570:

MultiProjectIncrementalTests.testPr119570_2

and I just added a testPr119570_3 - a simpler form of the problem for debugging.  Here is the full program:

interface INode<Parent, Child> {
    INode<Parent, Child> getParent();
}

abstract aspect NodeImpl<Parent, Child> {
    declare parents : Child implements INode<Parent, Child>;
    declare parents : Parent implements INode<Parent, Child>;

    private INode<Parent, Child> INode.fParent;
    public final INode<Parent, Child> INode.getParent() {
        return fParent;
    }
}

aspect PC extends NodeImpl<Tag, Tag> { }

class Tag {}

It goes wrong because when comparing the method on the interface
 INode<Parent,Child>.getParent() 
and the inter type munger 
INode<Parent,Child> Inode.getParent() 

we have correctly parameterized the method on the interface to
INode<Tag,Tag>.getParent()

but we only parameterize the ITD correctly if it shares type variables with the target type.  In this case we don't and leave it as is. Parent,Child should have been set because the ITD was parameterized when 'collected up' from the sub-aspect to the concrete aspect.  The collecting up mechanism does not exist for ITDs like it exists for pointcuts.  So we fail to parameterize it then after noticing that the method on the interface is abstract we check that the ITD overrides the abstract method.  Of course it does not because the return value doesn't match.  It *would* match if the itd had been parameterized correctly.

However, until a real person hits this problem and not me in some random sick testcase, I won't debug further...
Comment 3 Andrew Clement CLA 2013-06-24 11:03:05 EDT
unsetting the target field which is currently set for something already released