new inference for enum constants (IDEA-144973)

This commit is contained in:
Anna Kozlova
2015-09-10 15:35:55 +03:00
parent 11cc29416d
commit a811f9668e
3 changed files with 16 additions and 3 deletions

View File

@@ -647,14 +647,14 @@ public class InferenceSession {
if (gParent instanceof PsiAnonymousClass) {
gParent = gParent.getParent();
}
if (gParent instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
if (gParent instanceof PsiCall) {
final PsiExpressionList argumentList = ((PsiCall)gParent).getArgumentList();
if (argumentList != null) {
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
if (properties != null && properties.isApplicabilityCheck()) {
return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor());
}
final JavaResolveResult result = properties != null ? properties.getInfo() : ((PsiCallExpression)gParent).resolveMethodGenerics();
final JavaResolveResult result = properties != null ? properties.getInfo() : ((PsiCall)gParent).resolveMethodGenerics();
final boolean varargs = properties != null && properties.isVarargs() || result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isVarargs();
PsiSubstitutor substitutor = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(context, false,
new Computable<PsiSubstitutor>() {

View File

@@ -0,0 +1,9 @@
import java.util.Comparator;
import static java.util.Comparator.*;
enum TestEnum {
E(naturalOrder());
TestEnum(Comparator<String> c) {}
}

View File

@@ -299,6 +299,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testEnumConstantInference() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}