lambda: take care of diamonds

This commit is contained in:
Anna Kozlova
2012-09-03 18:27:49 +04:00
parent 7d2b48c00a
commit c7781bb05f
2 changed files with 12 additions and 1 deletions
@@ -292,7 +292,17 @@ public class LambdaUtil {
if (expression instanceof PsiCallExpression && ((PsiCallExpression)expression).getTypeArguments().length > 0) return true;
if (expression instanceof PsiNewExpression) {
final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expression).getClassOrAnonymousClassReference();
if (classReference != null && classReference.getTypeParameters().length > 0) return true;
if (classReference != null) {
final PsiReferenceParameterList parameterList = classReference.getParameterList();
if (parameterList != null) {
final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements();
if (typeParameterElements.length > 0) {
if (!(typeParameterElements[0].getType() instanceof PsiDiamondType)){
return true;
}
}
}
}
}
final PsiParameter[] lambdaParams = lambdaExpression.getParameterList().getParameters();
if (lambdaParams.length != methodParameters.length) return false;
@@ -8,6 +8,7 @@ public class BugReportLambdaSquiggles<T> {
static void bar( BugReportLambdaSquiggles<Integer> x) {
x.flatMap(t1 -> new ArrayList<String>(t1));
x.flatMap(t1 -> new ArrayList<>(t1));
}
interface Mapper<T, U> {