IG: care for generics
authorBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 20 Oct 2016 18:04:25 +0000 (20:04 +0200)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 20 Oct 2016 18:07:56 +0000 (20:07 +0200)
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/naming/LambdaUnfriendlyMethodOverloadInspectionBase.java
plugins/InspectionGadgets/test/com/siyeh/igtest/naming/lambda_unfriendly_method_overload/LambdaUnfriendlyMethodOverload.java

index cc5a6dbe7c6e09709ef5cea752092e7b20c00407..837b802cd900637799ec0267ff346f171f89e146 100644 (file)
@@ -18,6 +18,7 @@ package com.siyeh.ig.naming;
 import com.intellij.openapi.util.Key;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiSuperMethodUtil;
+import com.intellij.psi.util.TypeConversionUtil;
 import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspection;
 import com.siyeh.ig.BaseInspectionVisitor;
@@ -133,8 +134,8 @@ public class LambdaUnfriendlyMethodOverloadInspectionBase extends BaseInspection
         if (i == notThisOne) {
           continue;
         }
-        final PsiType type = parameters[i].getType();
-        final PsiType otherType = otherParameters[i].getType();
+        final PsiType type = TypeConversionUtil.erasure(parameters[i].getType());
+        final PsiType otherType = TypeConversionUtil.erasure(otherParameters[i].getType());
         if (!type.isAssignableFrom(otherType) && !otherType.isAssignableFrom(type)) {
           return false;
         }
index 9bd499c50a090a4b991451f25839c2fc7874b2ae..10b2fac9f05fa80a86d37df802f5b0340a32c6eb 100644 (file)
@@ -50,4 +50,9 @@ interface Consumer<T> {
 }
 interface IntPredicate {
   boolean test(int value);
+}
+class Generics<M, K> {
+  void <warning descr="Lambda unfriendly overload of method 'm()'">m</warning>(IntFunction r, M l) {}
+  void <warning descr="Lambda unfriendly overload of method 'm()'">m</warning>(Function f, K l) {}
+
 }
\ No newline at end of file