anonymous -> lambda: conflicting ref in var declaration (IDEA-124525)

This commit is contained in:
Anna Kozlova
2014-04-28 13:45:30 +02:00
parent 5dbbebe065
commit c2957e7fe8
3 changed files with 37 additions and 0 deletions

View File

@@ -243,6 +243,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
body.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitVariable(PsiVariable variable) {
super.visitVariable(variable);
final String newName = names.get(variable);
if (newName != null) {
replacements.put(variable.getNameIdentifier(), elementFactory.createIdentifier(newName));

View File

@@ -0,0 +1,17 @@
// "Replace with lambda" "true"
class Test {
static class SetSubThreadReadPacket {
private String getPostId() {
return null;
}
}
public void processPacket(String p) {
IPacketProcessor<SetSubThreadReadPacket> iPacketProcessor = p1 -> {
String root = p1.getPostId();
};
}
private interface IPacketProcessor<T> {
void process(SetSubThreadReadPacket p);
}
}

View File

@@ -0,0 +1,19 @@
// "Replace with lambda" "true"
class Test {
static class SetSubThreadReadPacket {
private String getPostId() {
return null;
}
}
public void processPacket(String p) {
IPacketProcessor<SetSubThreadReadPacket> iPacketProcessor = new IPacketProcessor<SetSubThrea<caret>dReadPacket>() {
public void process(SetSubThreadReadPacket p) {
String root = p.getPostId();
}
};
}
private interface IPacketProcessor<T> {
void process(SetSubThreadReadPacket p);
}
}