void () { myFixture.configureByText("a.java", """ import java.util.*; abstract class Main { void test(List<Integer> li) { foo(li, s -> <caret>s.substr(0), Collections.emptyList()); } abstract <T, U> Collection<U> foo(Collection<T> coll, Fun<Stream<T>, U> f, List<U> it); interface Stream<T> { T substr(long startingOffset); } interface Fun<T, R> { R _(T t); } } """); final PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Assert.assertTrue(elementAtCaret instanceof PsiIdentifier); final PsiElement refExpr = elementAtCaret.getParent(); Assert.assertTrue(refExpr.toString(), refExpr instanceof PsiExpression); final PsiType type = ((PsiExpression)refExpr).getType(); Assert.assertNotNull(refExpr.toString(), type); Assert.assertTrue(type.getCanonicalText(), type.equalsToText("Stream<java.lang.Integer>")); final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(refExpr, PsiExpressionList.class); assertNotNull(expressionList); final PsiExpression[] expressions = expressionList.getExpressions(); assertEquals(3, expressions.length); final PsiType ensureNotCached = expressions[2].getType(); assertNotNull(ensureNotCached); assertTrue(ensureNotCached.getCanonicalText(), ensureNotCached.equalsToText("java.util.List<java.lang.Integer>")); }