Skip to content

Commit 50cb4ab

Browse files
authored
Remove need to use JSpecify's @nullable annotation (#1142)
Fixes #1139. There are real scenarios where projects may not want to ship with a JSpecify dependence; see #1139 (comment). So, we remove any cases where we were specifically checking for or using JSpecify's `@Nullable` annotation. Most of the code changes are due to the fact that now, we check if an annotation is a `@Nullable` annotation using `Nullness.hasNullableAnnotation`, which requires a `Config` object as a parameter. So we need to thread a `Config` object as a parameter through a bunch of methods.
1 parent f064222 commit 50cb4ab

File tree

4 files changed

+116
-87
lines changed

4 files changed

+116
-87
lines changed

nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.errorprone.VisitorState;
44
import com.sun.tools.javac.code.Type;
55
import com.sun.tools.javac.code.Types;
6+
import com.uber.nullaway.Config;
67
import java.util.List;
78
import javax.lang.model.type.NullType;
89
import javax.lang.model.type.TypeKind;
@@ -14,9 +15,11 @@
1415
*/
1516
public class CheckIdenticalNullabilityVisitor extends Types.DefaultTypeVisitor<Boolean, Type> {
1617
private final VisitorState state;
18+
private final Config config;
1719

18-
CheckIdenticalNullabilityVisitor(VisitorState state) {
20+
CheckIdenticalNullabilityVisitor(VisitorState state, Config config) {
1921
this.state = state;
22+
this.config = config;
2023
}
2124

2225
@Override
@@ -60,8 +63,8 @@ public Boolean visitClassType(Type.ClassType lhsType, Type rhsType) {
6063
// TODO Handle wildcard types
6164
continue;
6265
}
63-
boolean isLHSNullableAnnotated = GenericsChecks.isNullableAnnotated(lhsTypeArgument, state);
64-
boolean isRHSNullableAnnotated = GenericsChecks.isNullableAnnotated(rhsTypeArgument, state);
66+
boolean isLHSNullableAnnotated = GenericsChecks.isNullableAnnotated(lhsTypeArgument, config);
67+
boolean isRHSNullableAnnotated = GenericsChecks.isNullableAnnotated(rhsTypeArgument, config);
6568
if (isLHSNullableAnnotated != isRHSNullableAnnotated) {
6669
return false;
6770
}
@@ -91,8 +94,8 @@ public Boolean visitArrayType(Type.ArrayType lhsType, Type rhsType) {
9194
Type.ArrayType arrRhsType = (Type.ArrayType) rhsType;
9295
Type lhsComponentType = lhsType.getComponentType();
9396
Type rhsComponentType = arrRhsType.getComponentType();
94-
boolean isLHSNullableAnnotated = GenericsChecks.isNullableAnnotated(lhsComponentType, state);
95-
boolean isRHSNullableAnnotated = GenericsChecks.isNullableAnnotated(rhsComponentType, state);
97+
boolean isLHSNullableAnnotated = GenericsChecks.isNullableAnnotated(lhsComponentType, config);
98+
boolean isRHSNullableAnnotated = GenericsChecks.isNullableAnnotated(rhsComponentType, config);
9699
if (isRHSNullableAnnotated != isLHSNullableAnnotated) {
97100
return false;
98101
}

0 commit comments

Comments
 (0)