mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-69629 (don't override erasure during check)
This commit is contained in:
+11
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -47,7 +47,6 @@ import java.util.*;
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
|
||||
public class GenericsHighlightUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil");
|
||||
private static final String GENERICS_ARE_NOT_SUPPORTED = JavaErrorMessages.message("generics.are.not.supported");
|
||||
@@ -448,14 +447,15 @@ public class GenericsHighlightUtil {
|
||||
new THashMap<MethodSignature, MethodSignatureBackedByPsiMethod>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
|
||||
|
||||
for (HierarchicalMethodSignature signature : signaturesWithSupers) {
|
||||
HighlightInfo info = checkSameErasureNotSubsignatureInner(signature, manager, aClass, sameErasureMethods);
|
||||
HighlightInfo info = checkSameErasureNotSubSignatureInner(signature, manager, aClass, sameErasureMethods);
|
||||
if (info != null) return info;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static HighlightInfo checkSameErasureNotSubsignatureInner(final HierarchicalMethodSignature signature,
|
||||
@Nullable
|
||||
private static HighlightInfo checkSameErasureNotSubSignatureInner(final HierarchicalMethodSignature signature,
|
||||
final PsiManager manager,
|
||||
final PsiClass aClass,
|
||||
final Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods) {
|
||||
@@ -466,19 +466,22 @@ public class GenericsHighlightUtil {
|
||||
MethodSignatureBackedByPsiMethod sameErasure = sameErasureMethods.get(signatureToErase);
|
||||
HighlightInfo info;
|
||||
if (sameErasure != null) {
|
||||
info = checkSameErasureNotSubsignatureOrSameClass(sameErasure, signature, aClass, method);
|
||||
info = checkSameErasureNotSubSignatureOrSameClass(sameErasure, signature, aClass, method);
|
||||
if (info != null) return info;
|
||||
}
|
||||
sameErasureMethods.put(signatureToErase, signature);
|
||||
else {
|
||||
sameErasureMethods.put(signatureToErase, signature);
|
||||
}
|
||||
List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
|
||||
for (HierarchicalMethodSignature superSignature : supers) {
|
||||
info = checkSameErasureNotSubsignatureInner(superSignature, manager, aClass, sameErasureMethods);
|
||||
info = checkSameErasureNotSubSignatureInner(superSignature, manager, aClass, sameErasureMethods);
|
||||
if (info != null) return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static HighlightInfo checkSameErasureNotSubsignatureOrSameClass(final MethodSignatureBackedByPsiMethod signatureToCheck,
|
||||
@Nullable
|
||||
private static HighlightInfo checkSameErasureNotSubSignatureOrSameClass(final MethodSignatureBackedByPsiMethod signatureToCheck,
|
||||
final HierarchicalMethodSignature superSignature,
|
||||
final PsiClass aClass,
|
||||
final PsiMethod superMethod) {
|
||||
|
||||
+9
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -13,12 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Highlight method problems
|
||||
* User: cdr
|
||||
* Date: Aug 14, 2002
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
@@ -49,12 +43,19 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Highlight method problems
|
||||
*
|
||||
* @author cdr
|
||||
* Date: Aug 14, 2002
|
||||
*/
|
||||
public class HighlightMethodUtil {
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
private HighlightMethodUtil() { }
|
||||
|
||||
public static String createClashMethodMessage(PsiMethod method1, PsiMethod method2, boolean showContainingClasses) {
|
||||
@NonNls String pattern = showContainingClasses ? "clash.methods.message.show.classes" : "clash.methods.message";
|
||||
|
||||
return JavaErrorMessages.message(pattern,
|
||||
HighlightUtil.formatMethod(method1),
|
||||
HighlightUtil.formatMethod(method2),
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// IDEA-69629
|
||||
class C {
|
||||
public static interface GenericAgnosticProcessor {
|
||||
void <warning descr="Method 'processMap(java.util.Map)' is never used">processMap</warning>(Map map);
|
||||
// ^^^ to cdr: should not be marked as unused
|
||||
}
|
||||
|
||||
public static interface GenericAwareProcessor {
|
||||
void <warning descr="Method 'processMap(java.util.Map<java.lang.String,java.lang.String>)' is never used">processMap</warning>(Map<String, String> map);
|
||||
// ^^^ to cdr: should not be marked as unused
|
||||
}
|
||||
|
||||
public static class TestProcessor implements GenericAwareProcessor, GenericAgnosticProcessor {
|
||||
@Override public void processMap(Map map) { }
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
final TestProcessor testProcessor = new TestProcessor();
|
||||
testProcessor.processMap(<warning descr="Unchecked assignment: 'java.util.HashMap' to 'java.util.Map<java.lang.String,java.lang.String>'">new HashMap()</warning>);
|
||||
// ^^^ to cdr: should resolve to TestProcessor.processMap() (at UncheckedWarningLocalInspection.java:228)
|
||||
}
|
||||
}
|
||||
+5
@@ -266,4 +266,9 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testPolymorphicTypeCast() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testErasureClashConfusion() throws Exception {
|
||||
enableInspectionTool(new UnusedDeclarationInspection());
|
||||
doTest(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user