lishunli / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

Can't use extension method within the same class it was declared in #577

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use an extension method within the same class it was declared in
2. It won't compile with javac

What is the expected output? What do you see instead?
Correct compilation, instead results in an error.

What version of the product are you using? On what operating system?
0.12.1 lombok-edge
linux x86_64
java8 developer preview

Please provide any additional information below.
@ExtensionMethod({ ThisClass.class })
public class ThisClass {
    public static void ext(String s) {
        ...
    }

    public void test() {
        "String".ext();
    }
}

This doesn't work with javac, but works with eclipse.

Original issue reported on code.google.com by wkn...@gmail.com on 19 Sep 2013 at 6:35

GoogleCodeExporter commented 9 years ago
Confirmed in 0.12.1 with OpenJDK 1.7.0_15.

Commenting out lombok.javac.handlers.HandleExtensionMethod line 176
    if (surroundingTypeSymbol == extensionProvider) continue;
makes this example compile and run. I don't know if there's a very good reason 
why that line is there though, so I'm hesitant to say that I have an actual fix 
:)

Original comment by askon...@gmail.com on 7 Oct 2013 at 8:09

Attachments: