void () { myFixture.addClass(""" import java.lang.annotation.ElementType; import java.lang.annotation.Target; @Target({ElementType.TYPE_USE}) @interface Nullable {} """); myFixture.addClass("class Middle<R> extends Base<@Nullable R, String>{}"); myFixture.addClass("class Child<R> extends Middle<R>{}"); PsiClass baseClass = myFixture.addClass("class Base<R, C> {}"); PsiClass fooClass = myFixture.addClass(""" class Foo { Child<String> field; }"""); PsiField fooField = fooClass.findFieldByName("field", false); PsiType substituted = TypeConversionUtil.getSuperClassSubstitutor(baseClass, (PsiClassType)fooField.getType()).substitute(baseClass.getTypeParameters()[0]); assertEquals(1, substituted.getAnnotations().length); }