accept inline on method reference (IDEA-102845)

This commit is contained in:
anna
2013-03-11 14:20:03 +01:00
parent f6806ebdf0
commit 5f0b7626de
4 changed files with 27 additions and 0 deletions

View File

@@ -1028,6 +1028,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
initializer.accept(canAllLocalsBeDeclaredFinal);
if (!canAllLocalsBeDeclaredFinal.success) return false;
}
if (initializer instanceof PsiMethodReferenceExpression) return true;
if (initializer instanceof PsiReferenceExpression) {
PsiVariable refVar = (PsiVariable)((PsiReferenceExpression)initializer).resolve();
if (refVar == null) {

View File

@@ -0,0 +1,11 @@
class Foo {
interface Jjj {
int[] jjj(int p);
}
void useJjj(Jjj p) {
p.jjj(9);
}
void test() {
use<caret>Jjj(int[]::new);
}
}

View File

@@ -0,0 +1,11 @@
class Foo {
interface Jjj {
int[] jjj(int p);
}
void useJjj(Jjj p) {
p.jjj(9);
}
void test() {
((Jjj) int[]::new).jjj(9);
}
}

View File

@@ -250,6 +250,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
doTestInlineThisOnly();
}
public void testOnMethodReference() throws Exception {
doTestInlineThisOnly();
}
public void testNonCodeUsage() throws Exception {
doTest(true);
}