0

我有以下代码要分析

a++;
return a++;

现在,我有以下方法 isToBeProcessed 的实现

public boolean isToBeProcessed(CtUnaryOperator<? extends CtElement> candidate) {
    if (!super.validMutationSpot(candidate)) {
        LOGGER.log(Level.FINER, "{0} is not a valid mutation spot", new Object[]{candidate});
        return false;
    }
    if (    candidate.getKind().compareTo(UnaryOperatorKind.POSTDEC) == 0
            ||
            candidate.getKind().compareTo(UnaryOperatorKind.POSTINC) == 0
            ||
            candidate.getKind().compareTo(UnaryOperatorKind.PREDEC) == 0
            ||
            candidate.getKind().compareTo(UnaryOperatorKind.PREINC) == 0) {
        //check that is not a statement
        if (candidate.getParent() instanceof CtStatement) {
            LOGGER.log(Level.FINER, "{0} is a statement {1}", new Object[]{candidate, candidate.getParent()});
            return false;
        } else {
            return true;
        }
    } else {
        LOGGER.log(Level.FINER, "{0} operator is not a pre/post inc or dec", new Object[]{candidate});
        return false;
    }
}

问题是,当第一次调用此方法时,该a++方法getParent()应该返回a++;,但它返回的是整个块。为什么?

4

0 回答 0