From 7d430b159e295077aee9ad42f7d2f85c2f6e0569 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 1 Jan 2018 14:12:58 +0100 Subject: [PATCH] IG: more robust check for existence of compareTo() method --- ...mparableImplementedButEqualsNotOverriddenInspection.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java index 8ff2ef8d4e17..eb1b196f7c19 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2017 Bas Leijdekkers + * Copyright 2006-2018 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,8 +139,8 @@ public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseI if (comparableClass == null || !aClass.isInheritor(comparableClass, true)) { return; } - final PsiMethod[] comparableMethods = comparableClass.getMethods(); - if (comparableMethods.length != 1) { // incorrect/broken jdk + final PsiMethod[] comparableMethods = comparableClass.findMethodsByName(HardcodedMethodConstants.COMPARE_TO, false); + if (comparableMethods.length == 0) { // incorrect/broken jdk return; } final PsiMethod comparableMethod = MethodSignatureUtil.findMethodBySuperMethod(aClass, comparableMethods[0], false);