private JavaResolveResult advancedResolveImpl() {
   final PsiElement resolve = resolveElement();
   if (resolve instanceof PsiClass) {
     final Map<PsiTypeParameter, PsiType> substitutionMap =
         new HashMap<PsiTypeParameter, PsiType>();
     int index = 0;
     for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiClass) resolve)) {
       if (index >= myTypeParameters.length) {
         final PsiTypeParameterListOwner parameterOwner = parameter.getOwner();
         if (parameterOwner == resolve) {
           substitutionMap.put(parameter, null);
         } else if (parameterOwner instanceof PsiClass) {
           PsiElement containingClass = myParent;
           while ((containingClass =
                   PsiTreeUtil.getParentOfType(containingClass, PsiClass.class, true))
               != null) {
             final PsiSubstitutor superClassSubstitutor =
                 TypeConversionUtil.getClassSubstitutor(
                     (PsiClass) parameterOwner, (PsiClass) containingClass, PsiSubstitutor.EMPTY);
             if (superClassSubstitutor != null) {
               substitutionMap.put(parameter, superClassSubstitutor.substitute(parameter));
               break;
             }
           }
         }
       } else {
         substitutionMap.put(parameter, myTypeParameters[index].getType());
       }
       index++;
     }
     return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap));
   } else {
     return new CandidateInfo(resolve, PsiSubstitutor.EMPTY);
   }
 }
 @NotNull
 @Override
 public PsiSubstitutor createRawSubstitutor(@NotNull final PsiTypeParameterListOwner owner) {
   Map<PsiTypeParameter, PsiType> substitutorMap = null;
   for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(owner)) {
     if (substitutorMap == null) substitutorMap = new HashMap<PsiTypeParameter, PsiType>();
     substitutorMap.put(parameter, null);
   }
   return PsiSubstitutorImpl.createSubstitutor(substitutorMap);
 }
 @NotNull
 @Override
 public PsiSubstitutor createRawSubstitutor(
     @NotNull final PsiSubstitutor baseSubstitutor,
     @NotNull final PsiTypeParameter[] typeParameters) {
   Map<PsiTypeParameter, PsiType> substitutorMap = null;
   for (PsiTypeParameter parameter : typeParameters) {
     if (substitutorMap == null) substitutorMap = new HashMap<PsiTypeParameter, PsiType>();
     substitutorMap.put(parameter, null);
   }
   return PsiSubstitutorImpl.createSubstitutor(substitutorMap).putAll(baseSubstitutor);
 }
 public static PsiSubstitutor composeSubstitutors(PsiSubstitutor s1, PsiSubstitutor s2) {
   final Map<PsiTypeParameter, PsiType> map = s1.getSubstitutionMap();
   Map<PsiTypeParameter, PsiType> result = new THashMap<PsiTypeParameter, PsiType>(map.size());
   for (PsiTypeParameter parameter : map.keySet()) {
     result.put(parameter, s2.substitute(map.get(parameter)));
   }
   final Map<PsiTypeParameter, PsiType> map2 = s2.getSubstitutionMap();
   for (PsiTypeParameter parameter : map2.keySet()) {
     if (!result.containsKey(parameter)) {
       result.put(parameter, map2.get(parameter));
     }
   }
   return PsiSubstitutorImpl.createSubstitutor(result);
 }
 @NotNull
 @Override
 public PsiSubstitutor createSubstitutor(@NotNull final Map<PsiTypeParameter, PsiType> map) {
   return PsiSubstitutorImpl.createSubstitutor(map);
 }