Skip to content

Commit ba226c0

Browse files
authored
Don't assign within conditional
1 parent 751f087 commit ba226c0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

framework/src/main/java/org/checkerframework/common/value/ValueTreeAnnotator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,22 @@ public Void visitTypeCast(TypeCastTree tree, AnnotatedTypeMirror atm) {
275275

276276
TypeMirror newType = atm.getUnderlyingType();
277277
AnnotationMirror newAnno;
278-
Range range;
279278

280279
if (TypesUtils.isString(newType) || newType.getKind() == TypeKind.ARRAY) {
281280
// Strings and arrays do not allow conversions
282281
newAnno = oldAnno;
283282
} else if (atypeFactory.isIntRange(oldAnno)
284-
&& (range = atypeFactory.getRange(oldAnno))
285-
.isWiderThan(ValueAnnotatedTypeFactory.MAX_VALUES)) {
283+
&& atypeFactory.getRange(oldAnno).isWiderThan(ValueAnnotatedTypeFactory.MAX_VALUES)) {
286284
Class<?> newClass = TypesUtils.getClassFromType(newType);
287285
if (newClass == String.class) {
288286
newAnno = atypeFactory.UNKNOWNVAL;
289287
} else if (newClass == Boolean.class || newClass == boolean.class) {
290288
throw new UnsupportedOperationException(
291289
"ValueAnnotatedTypeFactory: can't convert int to boolean");
292290
} else {
293-
newAnno = atypeFactory.createIntRangeAnnotation(NumberUtils.castRange(newType, range));
291+
newAnno =
292+
atypeFactory.createIntRangeAnnotation(
293+
NumberUtils.castRange(newType, atypeFactory.getRange(oldAnno)));
294294
}
295295
} else {
296296
List<?> values =

0 commit comments

Comments
 (0)