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[] statements = method.getBody().getStatements(); final PsiVariable var = (PsiVariable) ((PsiDeclarationStatement) statements[0]).getDeclaredElements()[0]; final PsiType varType = var.getType(); final PsiType typeRawIterator = factory.createTypeFromText("test.Iterator", null); assertEquals(varType, typeRawIterator); final PsiType initializerType = var.getInitializer().getType(); assertEquals(initializerType, typeRawIterator); assertTrue(varType.isAssignableFrom(initializerType)); }