IDEADEV-40774

This commit is contained in:
Alexey Kudravtsev
2009-10-16 11:08:54 +04:00
parent b9ba4ebf41
commit 646abc8739
2 changed files with 14 additions and 5 deletions
@@ -60,6 +60,11 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
if (type1.equals(type2)) return type1;
final int typeRank1 = TypeConversionUtil.getTypeRank(type1);
final int typeRank2 = TypeConversionUtil.getTypeRank(type2);
// bug in JLS3, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6888770
if (type1 instanceof PsiClassType && type2.equals(PsiPrimitiveType.getUnboxedType(type1))) return type2;
if (type2 instanceof PsiClassType && type1.equals(PsiPrimitiveType.getUnboxedType(type2))) return type1;
if (TypeConversionUtil.isNumericType(typeRank1) && TypeConversionUtil.isNumericType(typeRank2)){
if (typeRank1 == TypeConversionUtil.BYTE_RANK && typeRank2 == TypeConversionUtil.SHORT_RANK) return type2;
if (typeRank1 == TypeConversionUtil.SHORT_RANK && typeRank2 == TypeConversionUtil.BYTE_RANK) return type1;
@@ -79,10 +84,14 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
if (!PsiUtil.isLanguageLevel5OrHigher(this)) {
return null;
}
if (TypeConversionUtil.isPrimitiveAndNotNull(type1)) type1 = ((PsiPrimitiveType)type1).getBoxedType(this);
if (type1 == null) return null;
if (TypeConversionUtil.isPrimitiveAndNotNull(type2)) type2 = ((PsiPrimitiveType)type2).getBoxedType(this);
if (type2 == null) return null;
if (TypeConversionUtil.isPrimitiveAndNotNull(type1)) {
type1 = ((PsiPrimitiveType)type1).getBoxedType(this);
if (type1 == null) return null;
}
if (TypeConversionUtil.isPrimitiveAndNotNull(type2)) {
type2 = ((PsiPrimitiveType)type2).getBoxedType(this);
if (type2 == null) return null;
}
return GenericsUtil.getLeastUpperBound(type1, type2, getManager());
}
@@ -53,7 +53,6 @@ public class TypeConversionUtil {
private static final TObjectIntHashMap<PsiType> TYPE_TO_RANK_MAP = new TObjectIntHashMap<PsiType>();
private static final int BOOL_RANK = 10;
public static final int BYTE_RANK = 1;
public static final int SHORT_RANK = 2;
public static final int CHAR_RANK = 3;
@@ -61,6 +60,7 @@ public class TypeConversionUtil {
private static final int LONG_RANK = 5;
private static final int FLOAT_RANK = 6;
private static final int DOUBLE_RANK = 7;
private static final int BOOL_RANK = 10;
private static final int STRING_RANK = 100;
private static final int MAX_NUMERIC_RANK = DOUBLE_RANK;