suspicious call: type of new expression must be assignable otherwise it's suspicious (IDEA-164816)

This commit is contained in:
Anna.Kozlova
2016-12-01 16:52:02 +01:00
parent ba117e7328
commit 4e75eeae21
3 changed files with 29 additions and 3 deletions
@@ -0,0 +1,9 @@
import java.util.*;
class Foo<T extends List<Integer>> {
public void foo() {
Map<T, T> map = new HashMap<>();
map.containsKey(<warning descr="Suspicious call to 'Map.containsKey'">new HashMap<>()</warning>);
}
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2016 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.intellij.codeInspection;
import com.intellij.JavaTestUtil;
@@ -25,6 +40,7 @@ public class SuspiciousCollectionMethodCallsTest extends LightCodeInsightFixture
public void testUseDfa() throws Exception { doTest(); }
public void testWildcard() throws Exception { doTest(); }
public void testPolyConditionalExpressionPassedToMapGetCall() throws Exception { doTest(); }
public void testNewExpressionPassedToMapContains() throws Exception { doTest(); }
public void testIgnoreConvertible() throws Exception {
myTool.REPORT_CONVERTIBLE_METHOD_CALLS = false;
doTest();