diff --git a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java index 3205e3881e1..5c535b4d774 100644 --- a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java +++ b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java @@ -2260,21 +2260,21 @@ public Void visitReturn(ReturnTree tree, Void p) { Tree enclosing = TreePathUtil.enclosingOfKind(getCurrentPath(), methodAndLambdaExpression); - AnnotatedTypeMirror ret = null; + AnnotatedTypeMirror declaredReturnType = null; if (enclosing.getKind() == Tree.Kind.METHOD) { MethodTree enclosingMethod = (MethodTree) enclosing; boolean valid = validateTypeOf(enclosingMethod); if (valid) { - ret = atypeFactory.getMethodReturnType(enclosingMethod, tree); + declaredReturnType = atypeFactory.getMethodReturnType(enclosingMethod, tree); } } else { AnnotatedExecutableType result = atypeFactory.getFunctionTypeFromTree((LambdaExpressionTree) enclosing); - ret = result.getReturnType(); + declaredReturnType = result.getReturnType(); } - if (ret != null) { - commonAssignmentCheck(ret, tree.getExpression(), "return"); + if (declaredReturnType != null) { + commonAssignmentCheck(declaredReturnType, tree.getExpression(), "return"); } return super.visitReturn(tree, p); }