void () { final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); final PsiMethod method = classA.getMethods()[0]; final PsiStatement[] methodStatements = method.getBody().getStatements(); final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement) methodStatements[0]; final PsiVariable varList = (PsiVariable) declarationStatement.getDeclaredElements()[0]; final PsiType typeListOfA = factory.createTypeFromText("test.List<java.lang.String>", null); assertEquals(varList.getType(), typeListOfA); final PsiType typeListOfObject = factory.createTypeFromText("test.List<java.lang.Object>", null); assertFalse(varList.getType().equals(typeListOfObject)); final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression) ((PsiExpressionStatement) methodStatements[1]).getExpression()).getMethodExpression(); final JavaResolveResult resolveResult = methodExpression.advancedResolve(false); assertTrue(resolveResult.getElement() instanceof PsiMethod); final PsiMethod methodFromList = (PsiMethod) resolveResult.getElement(); final PsiType typeOfFirstParameterOfAdd = methodFromList.getParameterList().getParameters()[0].getType(); final PsiType substitutedType = resolveResult.getSubstitutor().substitute(typeOfFirstParameterOfAdd); final PsiClassType typeA = factory.createTypeByFQClassName("java.lang.String"); assertEquals(typeA, substitutedType); assertTrue(typeA.equalsToText("java.lang.String")); final PsiType aListIteratorType = ((PsiExpressionStatement) methodStatements[2]).getExpression().getType(); final PsiType aIteratorType = factory.createTypeFromText("test.Iterator<java.lang.String>", null); assertEquals(aIteratorType, aListIteratorType); final PsiType objectIteratorType = factory.createTypeFromText("test.Iterator<java.lang.Object>", null); assertFalse(objectIteratorType.equals(aListIteratorType)); }