java7 cast conventions

This commit is contained in:
anna
2012-10-15 16:20:56 +02:00
parent 1c0933b830
commit 5c798946df
3 changed files with 20 additions and 1 deletions
@@ -470,7 +470,18 @@ public class TypeConversionUtil {
|| ltypeRank == BOOL_RANK && rtypeRank == BOOL_RANK;
}
else {
if (isPrimitiveAndNotNull(ltype) || isPrimitiveAndNotNull(rtype)) return false;
if (isPrimitiveAndNotNull(ltype)) {
if (rtype instanceof PsiClassType && ((PsiClassType)rtype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7)) {
return areTypesConvertible(ltype, rtype);
}
return false;
}
if (isPrimitiveAndNotNull(rtype)) {
if (ltype instanceof PsiClassType && ((PsiClassType)ltype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7)) {
return areTypesConvertible(rtype, ltype);
}
return false;
}
isApplicable = areTypesConvertible(ltype, rtype) || areTypesConvertible(rtype, ltype);
}
}
@@ -0,0 +1,7 @@
class Test {
public static void main(String[] args) {
Object o = null;
if (o == 1) {}
if (1 == o) {}
}
}
@@ -162,4 +162,5 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
public void testMethodReferences() throws Exception { doTest(false, true, false); }
public void testUsedMethodsByMethodReferences() throws Exception { doTest(true, true, false); }
public void testLambdaExpressions() throws Exception { doTest(false, true, false); }
public void testJava7CastConventions() throws Exception { doTest(false, true, false); }
}