@Override
 public void visitNode(Tree tree) {
   ConditionalExpressionTree cet = (ConditionalExpressionTree) tree;
   Type trueExpressionType = cet.trueExpression().symbolType();
   Type falseExpressionType = cet.falseExpression().symbolType();
   if (dissimilarPrimitiveTypeWrappers(trueExpressionType, falseExpressionType)) {
     reportIssue(cet.questionToken(), "Add an explicit cast to match types of operands.");
   }
 }
Esempio n. 2
0
 private void buildConditionalExpression(ConditionalExpressionTree tree) {
   ConditionalExpressionTree cond = tree;
   Block next = currentBlock;
   // process else-branch
   ExpressionTree elseStatement = cond.falseExpression();
   currentBlock = createBlock(next);
   build(elseStatement);
   Block elseBlock = currentBlock;
   // process then-branch
   currentBlock = createBlock(next);
   build(cond.trueExpression());
   Block thenBlock = currentBlock;
   // process condition
   currentBlock = createBranch(cond, thenBlock, elseBlock);
   buildCondition(cond.condition(), thenBlock, elseBlock);
 }
 @Override
 public void visitConditionalExpression(ConditionalExpressionTree tree) {
   type = getTypeFromExpression(tree.parent());
 }