Bug 288586 - bogus 'incompatible return type applying to constructor-call' error
Summary: bogus 'incompatible return type applying to constructor-call' error
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-03 20:11 EDT by Godmar Back CLA
Modified: 2009-09-03 20:11 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 Godmar Back CLA 2009-09-03 20:11:17 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13 (.NET CLR 3.5.30729)
Build Identifier: 

The following code produces a 'incompatible return type error', though - in my opinion - it should not:

package asp;

aspect Intercept {
    ConstructorIntercept around(String s)
        : call(ConstructorIntercept+.new (String)) && args(s)
    {
        return proceed(s + ", World");
    }
}

public class ConstructorIntercept {
    private String s;
    public String toString() { return this.s; }
    ConstructorIntercept(String s) { this.s = s; }

    public static void main(String []av) {
        System.out.println(new ConstructorIntercept("Hello") { });
    }
}



Reproducible: Always

Steps to Reproduce:
1. Save above code in asp/ConstructorIntercept.java
2. Run /opt/aspectj1.6/bin/ajc -classpath /opt/aspectj1.6/lib/aspectjrt.jar:. asp/ConstructorIntercept.java
3. See the error




I believe this is an error because, curiously, the following program compiles and runs:

package asp;

aspect Intercept {
    Object around(String s) 
        : call(ConstructorIntercept+.new (String)) && args(s) 
    {
        return proceed(s + ", World");
    }
}

public class ConstructorIntercept {
    private String s;
    public String toString() { return this.s; }
    ConstructorIntercept(String s) { this.s = s; }

    public static void main(String []av) {
        System.out.println(new ConstructorIntercept("Hello") { });
    }
}

The only difference is the return type of the 'around' advice - Object vs. ConstructorIntercept.  If returning Object is okay, why not ConstructorIntercept?