lambda: primitive array type constructors fixed (IDEA-102836)

This commit is contained in:
anna
2013-03-11 11:55:41 +01:00
parent 7f31bbcbee
commit 436f2cc351
3 changed files with 29 additions and 1 deletions

View File

@@ -242,9 +242,17 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT
}
}
}
final PsiType newExprType = ((PsiNewExpression)element).getType();
if (containingClass != null) {
methodRefText = getClassReferenceName(containingClass);
final PsiType newExprType = ((PsiNewExpression)element).getType();
} else if (newExprType instanceof PsiArrayType){
final PsiType deepComponentType = newExprType.getDeepComponentType();
if (deepComponentType instanceof PsiPrimitiveType) {
methodRefText = deepComponentType.getCanonicalText();
}
}
if (methodRefText != null) {
if (newExprType != null) {
int dim = newExprType.getArrayDimensions();
while (dim-- > 0) {

View File

@@ -0,0 +1,10 @@
// "Replace lambda with method reference" "true"
class Example {
interface Jjj {
int[] jjj(int p);
}
{
Jjj jjj = int[]::new;
}
}

View File

@@ -0,0 +1,10 @@
// "Replace lambda with method reference" "true"
class Example {
interface Jjj {
int[] jjj(int p);
}
{
Jjj jjj = (p) -> new i<caret>nt[p];
}
}