Evaluator (PsiType lType, PsiType rType, Evaluator rEvaluator, Project project) { final PsiType unboxedLType = PsiPrimitiveType.getUnboxedType(lType); if (unboxedLType != null) { if (rType instanceof PsiPrimitiveType && !PsiTypes.nullType().equals(rType)) { if (!rType.equals(unboxedLType)) { rEvaluator = createTypeCastEvaluator(rEvaluator, unboxedLType); } rEvaluator = new BoxingEvaluator(rEvaluator); } } else { // either primitive type or not unboxable type if (lType instanceof PsiPrimitiveType) { if (rType instanceof PsiClassType) { rEvaluator = new UnBoxingEvaluator(rEvaluator); } final PsiPrimitiveType unboxedRType = PsiPrimitiveType.getUnboxedType(rType); final PsiType _rType = unboxedRType != null ? unboxedRType : rType; if (_rType instanceof PsiPrimitiveType && !PsiTypes.nullType().equals(_rType)) { if (!lType.equals(_rType)) { rEvaluator = createTypeCastEvaluator(rEvaluator, lType); } } } else if (lType instanceof PsiClassType && rType instanceof PsiPrimitiveType && !PsiTypes.nullType().equals(rType)) { final PsiClassType rightBoxed = ((PsiPrimitiveType)rType).getBoxedType(PsiManager.getInstance(project), ((PsiClassType)lType).getResolveScope()); if (rightBoxed != null && TypeConversionUtil.isAssignable(lType, rightBoxed)) { rEvaluator = new BoxingEvaluator(rEvaluator); } } } return rEvaluator; }