mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
take into account containing class type params when accepting assignability (IDEA-71582)
This commit is contained in:
@@ -900,16 +900,17 @@ public class TypeConversionUtil {
|
||||
PsiClass leftClass = leftResult.getElement();
|
||||
PsiClass rightClass = rightResult.getElement();
|
||||
|
||||
if (!leftClass.hasTypeParameters()) return true;
|
||||
Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
|
||||
|
||||
if (!li.hasNext()) return true;
|
||||
PsiSubstitutor leftSubstitutor = leftResult.getSubstitutor();
|
||||
|
||||
if (!leftClass.getManager().areElementsEquivalent(leftClass, rightClass)) {
|
||||
rightSubstitutor = getSuperClassSubstitutor(leftClass, rightClass, rightSubstitutor);
|
||||
rightClass = leftClass;
|
||||
}
|
||||
else if (!rightClass.hasTypeParameters()) return true;
|
||||
else if (!PsiUtil.typeParametersIterator(rightClass).hasNext()) return true;
|
||||
|
||||
Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
|
||||
Iterator<PsiTypeParameter> ri = PsiUtil.typeParametersIterator(rightClass);
|
||||
while (li.hasNext()) {
|
||||
if (!ri.hasNext()) return false;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Main {
|
||||
static class C<T>
|
||||
{
|
||||
class D{}
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
C<String>.D o1 = null;
|
||||
C<Object>.D o2 = null;
|
||||
<error descr="Incompatible types. Found: 'Main.C<java.lang.Object>.D', required: 'Main.C<java.lang.String>.D'">o1 = o2</error>;
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA63331() { doTest5(false); }
|
||||
public void testIDEA60836() { doTest5(false); }
|
||||
public void testIDEA54197() { doTest5(false); }
|
||||
public void testIDEA71582() { doTest5(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user