diff --git a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java index 037c703fbf0..a60a99d1dea 100644 --- a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java @@ -123,17 +123,16 @@ protected void checkThisOrSuperConstructorCall( @Override protected boolean commonAssignmentCheck( Tree varTree, - ExpressionTree valueExp, + ExpressionTree valueExpTree, @CompilerMessageKey String errorKey, Object... extraArgs) { // field write of the form x.f = y if (TreeUtils.isFieldAccess(varTree)) { // cast is safe: a field access can only be an IdentifierTree or MemberSelectTree ExpressionTree lhs = (ExpressionTree) varTree; - ExpressionTree y = valueExp; VariableElement el = TreeUtils.variableElementFromUse(lhs); - AnnotatedTypeMirror xType = atypeFactory.getReceiverType(lhs); - AnnotatedTypeMirror yType = atypeFactory.getAnnotatedType(y); + AnnotatedTypeMirror lhsReceiverType = atypeFactory.getReceiverType(lhs); + AnnotatedTypeMirror valueExpType = atypeFactory.getAnnotatedType(valueExpTree); // the special FBC rules do not apply if there is an explicit // UnknownInitialization annotation AnnotationMirrorSet fieldAnnotations = @@ -141,11 +140,11 @@ protected boolean commonAssignmentCheck( if (!AnnotationUtils.containsSameByName( fieldAnnotations, atypeFactory.UNKNOWN_INITIALIZATION)) { if (!ElementUtils.isStatic(el) - && !(atypeFactory.isInitialized(yType) - || atypeFactory.isUnderInitialization(xType) - || atypeFactory.isFbcBottom(yType))) { + && !(atypeFactory.isInitialized(valueExpType) + || atypeFactory.isUnderInitialization(lhsReceiverType) + || atypeFactory.isFbcBottom(valueExpType))) { @CompilerMessageKey String err; - if (atypeFactory.isInitialized(xType)) { + if (atypeFactory.isInitialized(lhsReceiverType)) { err = COMMITMENT_INVALID_FIELD_WRITE_INITIALIZED; } else { err = COMMITMENT_INVALID_FIELD_WRITE_UNKNOWN_INITIALIZATION; @@ -155,7 +154,7 @@ protected boolean commonAssignmentCheck( } } } - return super.commonAssignmentCheck(varTree, valueExp, errorKey, extraArgs); + return super.commonAssignmentCheck(varTree, valueExpTree, errorKey, extraArgs); } @Override diff --git a/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java b/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java index a94bafee434..831fa8ac721 100644 --- a/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java +++ b/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java @@ -162,8 +162,7 @@ public static TypeElement toplevelEnclosingTypeElement(Element element) { public static PackageElement enclosingPackage(Element elem) { Element result = elem; while (result != null && result.getKind() != ElementKind.PACKAGE) { - Element encl = result.getEnclosingElement(); - result = encl; + result = result.getEnclosingElement(); } return (PackageElement) result; } diff --git a/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java b/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java index 27f47d3284f..6ee85e6f2ff 100644 --- a/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java +++ b/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java @@ -148,9 +148,7 @@ private TreeUtils() { TREEMAKER_SELECT = TreeMaker.class.getMethod("Select", JCExpression.class, Symbol.class); } catch (NoSuchMethodException e) { - Error err = new AssertionError("Unexpected error in TreeUtils static initializer"); - err.initCause(e); - throw err; + throw new AssertionError("Unexpected error in TreeUtils static initializer", e); } }