method refs: mismatched collection query (IDEA-112981)

This commit is contained in:
Anna Kozlova
2013-09-02 13:32:28 +04:00
parent 465edc7a24
commit 38c6a24c39
2 changed files with 32 additions and 0 deletions
@@ -96,6 +96,17 @@ class CollectionQueryCalledVisitor extends JavaRecursiveElementVisitor {
checkQualifier(qualifier);
}
@Override
public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
if (queried) return;
final String methodName = expression.getReferenceName();
if (methodName == null) {
return;
}
checkQualifier(expression.getQualifierExpression());
}
private void checkQualifier(PsiExpression expression) {
if (queried) {
return;
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.igtest.bugs.mismatched_collection_query_update;
import java.util.*;
@@ -190,4 +205,10 @@ class MethReference<E> {
interface I<E> {
boolean _(E e);
}
void qTest() {
Map<Integer, Boolean> map = new HashMap<>();
map.put(1, true);
I<Integer> mapper = map::get;
}
}