String (@NotNull List<? extends MethodSignatureBackedByPsiMethod> superMethodSignatures, @NotNull LanguageLevel languageLevel) { if (superMethodSignatures.size() < 2) return null; MethodSignatureBackedByPsiMethod[] returnTypeSubstitutable = {superMethodSignatures.get(0)}; for (int i = 1; i < superMethodSignatures.size(); i++) { PsiMethod currentMethod = returnTypeSubstitutable[0].getMethod(); PsiType currentType = returnTypeSubstitutable[0].getSubstitutor().substitute(currentMethod.getReturnType()); MethodSignatureBackedByPsiMethod otherSuperSignature = superMethodSignatures.get(i); PsiMethod otherSuperMethod = otherSuperSignature.getMethod(); PsiSubstitutor otherSubstitutor = otherSuperSignature.getSubstitutor(); PsiType otherSuperReturnType = otherSubstitutor.substitute(otherSuperMethod.getReturnType()); PsiSubstitutor unifyingSubstitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(returnTypeSubstitutable[0], otherSuperSignature); if (unifyingSubstitutor != null) { otherSuperReturnType = unifyingSubstitutor.substitute(otherSuperReturnType); currentType = unifyingSubstitutor.substitute(currentType); } if (otherSuperReturnType == null || currentType == null || otherSuperReturnType.equals(currentType)) continue; PsiType otherReturnType = otherSuperReturnType; PsiType curType = currentType; String info = LambdaUtil.performWithSubstitutedParameterBounds(otherSuperMethod.getTypeParameters(), otherSubstitutor, () -> { if (languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) { //http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.8 Example 8.1.5-3 if (!(otherReturnType instanceof PsiPrimitiveType || curType instanceof PsiPrimitiveType)) { if (otherReturnType.isAssignableFrom(curType)) return null; if (curType.isAssignableFrom(otherReturnType)) { returnTypeSubstitutable[0] = otherSuperSignature; return null; } } if (otherSuperMethod.getTypeParameters().length > 0 && JavaGenericsUtil.isRawToGeneric(otherReturnType, curType)) return null; } return MessageFormat.format("{0}; {1}", createClashMethodMessage(otherSuperMethod, currentMethod, true), JavaErrorBundle.message("unrelated.overriding.methods.return.types")); }); if (info != null) return info; } return null; }