void () { final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); final PsiMethod method = classA.findMethodsByName("method", false)[0]; final PsiStatement[] statements = method.getBody().getStatements(); final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement) statements[0]; final PsiClassType typeOfL = (PsiClassType) ((PsiVariable) declarationStatement.getDeclaredElements()[0]).getType(); final PsiType typeRawList = factory.createTypeFromText("test.List", null); assertTrue(Comparing.equal(typeOfL, typeRawList)); final PsiSubstitutor typeOfLSubstitutor = typeOfL.resolveGenerics().getSubstitutor(); final PsiMethodCallExpression exprGetArray = (PsiMethodCallExpression) ((PsiExpressionStatement) statements[1]).getExpression(); final PsiType typeOfGetArrayCall = exprGetArray.getType(); final PsiType objectArrayType = factory.createTypeFromText("java.lang.Object[]", null); assertTrue(Comparing.equal(typeOfGetArrayCall, objectArrayType)); final PsiMethod methodGetArray = (PsiMethod) exprGetArray.getMethodExpression().resolve(); final PsiType subtitutedGetArrayReturnType = typeOfLSubstitutor.substitute(methodGetArray.getReturnType()); assertTrue(Comparing.equal(subtitutedGetArrayReturnType, objectArrayType)); final PsiMethodCallExpression exprGetListOfArray = (PsiMethodCallExpression) ((PsiExpressionStatement) statements[2]).getExpression(); final PsiMethod methodGetListOfArray = (PsiMethod) exprGetListOfArray.getMethodExpression().resolve(); final PsiType returnType = methodGetListOfArray.getReturnType(); final PsiType substitutedReturnType = typeOfLSubstitutor.substitute(returnType); assertTrue(Comparing.equal(substitutedReturnType, typeRawList)); final PsiType typeOfGetListOfArrayCall = exprGetListOfArray.getType(); assertTrue(Comparing.equal(typeOfGetListOfArrayCall, typeRawList)); }