Skip to content

Commit 33817d8

Browse files
wmdietlnetdpb
andcommitted
Use EISOP CF sources (#118)
Co-authored-by: David P. Baker <[email protected]>
1 parent 9e57ea8 commit 33817d8

File tree

11 files changed

+209
-425
lines changed

11 files changed

+209
-425
lines changed

initialize-project

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Set SHALLOW=1 to clone sibling projects at depth 1.
1212
#
1313
# This script automatically tries to download your fork of
14-
# jspecify/checker-framework, jspecify/jspecify, or jspecify/jdk, if they exist.
14+
# eisop/checker-framework, jspecify/jspecify, or jspecify/jdk, if they exist.
1515
# It uses the URL of the origin remote (the default remote created when cloning
1616
# a repo) to determine that.
1717
#
@@ -55,12 +55,17 @@ git_clone() {
5555

5656
local forking_org
5757
forking_org="$(forking_org)"
58-
if [[ -n "${forking_org}" ]]; then
58+
if [[ -n "${forking_org}" ]] && [[ "${forking_org}" != "https://github.com/jspecify" ]]; then
5959
if run "${git[@]}" "${forking_org}/${repo}.git" "../${repo}"; then
6060
return
6161
fi
6262
fi
63-
run "${git[@]}" "https://github.com/jspecify/${repo}.git" "../${repo}"
63+
if [[ "${repo}" == checker-framework ]]; then
64+
forking_org=https://github.com/eisop
65+
else
66+
forking_org=https://github.com/jspecify
67+
fi
68+
run "${git[@]}" "${forking_org}/${repo}.git" "../${repo}"
6469
}
6570

6671
git_clone jdk --depth 1 --single-branch

settings.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ includeBuild("../checker-framework")
1515
dependencyResolutionManagement {
1616
versionCatalogs {
1717
libs {
18-
version("checkerFramework", "3.21.5-SNAPSHOT")
18+
version("checkerFramework", "3.42.0-eisop2-SNAPSHOT")
1919

20-
library("checkerFramework-checker", "org.checkerframework", "checker").versionRef("checkerFramework")
21-
library("checkerFramework-checker-qual", "org.checkerframework", "checker-qual").versionRef("checkerFramework")
22-
library("checkerFramework-framework", "org.checkerframework", "framework").versionRef("checkerFramework")
23-
library("checkerFramework-framework-test", "org.checkerframework", "framework-test").versionRef("checkerFramework")
24-
library("checkerFramework-javacutil", "org.checkerframework", "javacutil").versionRef("checkerFramework")
20+
library("checkerFramework-checker", "io.github.eisop", "checker").versionRef("checkerFramework")
21+
library("checkerFramework-checker-qual", "io.github.eisop", "checker-qual").versionRef("checkerFramework")
22+
library("checkerFramework-framework", "io.github.eisop", "framework").versionRef("checkerFramework")
23+
library("checkerFramework-framework-test", "io.github.eisop", "framework-test").versionRef("checkerFramework")
24+
library("checkerFramework-javacutil", "io.github.eisop", "javacutil").versionRef("checkerFramework")
2525
library("errorProne-core", "com.google.errorprone:error_prone_core:2.18.0")
2626
library("errorProne-javac", "com.google.errorprone:javac:9+181-r4173-1")
2727
library("guava", "com.google.guava:guava:31.1-jre")

src/main/java/com/google/jspecify/nullness/NullSpecAnalysis.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414

1515
package com.google.jspecify.nullness;
1616

17-
import java.util.Set;
18-
import javax.lang.model.element.AnnotationMirror;
1917
import javax.lang.model.type.TypeMirror;
2018
import org.checkerframework.common.basetype.BaseTypeChecker;
2119
import org.checkerframework.framework.flow.CFAbstractAnalysis;
2220
import org.checkerframework.framework.flow.CFValue;
21+
import org.checkerframework.javacutil.AnnotationMirrorSet;
2322

2423
final class NullSpecAnalysis extends CFAbstractAnalysis<CFValue, NullSpecStore, NullSpecTransfer> {
2524
NullSpecAnalysis(BaseTypeChecker checker, NullSpecAnnotatedTypeFactory factory) {
@@ -37,7 +36,7 @@ public NullSpecStore createCopiedStore(NullSpecStore other) {
3736
}
3837

3938
@Override
40-
public CFValue createAbstractValue(Set<AnnotationMirror> annotations, TypeMirror underlyingType) {
39+
public CFValue createAbstractValue(AnnotationMirrorSet annotations, TypeMirror underlyingType) {
4140
return defaultCreateAbstractValue(this, annotations, underlyingType);
4241
}
4342
}

src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java

Lines changed: 139 additions & 268 deletions
Large diffs are not rendered by default.

src/main/java/com/google/jspecify/nullness/NullSpecChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.sun.source.util.TreePath;
2424
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
2525
import com.sun.tools.javac.util.Log;
26-
import java.util.SortedSet;
26+
import java.util.NavigableSet;
2727
import java.util.TreeSet;
2828
import javax.lang.model.element.TypeElement;
2929
import org.checkerframework.common.basetype.BaseTypeChecker;
@@ -62,8 +62,8 @@ public final class NullSpecChecker extends BaseTypeChecker {
6262
public NullSpecChecker() {}
6363

6464
@Override
65-
public SortedSet<String> getSuppressWarningsPrefixes() {
66-
SortedSet<String> prefixes = new TreeSet<>();
65+
public NavigableSet<String> getSuppressWarningsPrefixes() {
66+
TreeSet<String> prefixes = new TreeSet<>();
6767
prefixes.add("nullness");
6868
return prefixes;
6969
}

src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static com.sun.source.tree.Tree.Kind.NULL_LITERAL;
1919
import static java.util.Arrays.asList;
2020
import static java.util.Collections.emptyList;
21-
import static java.util.Collections.singleton;
2221
import static java.util.Collections.unmodifiableSet;
2322
import static java.util.stream.Collectors.toList;
2423
import static org.checkerframework.dataflow.expression.JavaExpression.fromNode;
@@ -71,6 +70,7 @@
7170
import org.checkerframework.framework.flow.CFValue;
7271
import org.checkerframework.framework.type.AnnotatedTypeMirror;
7372
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType;
73+
import org.checkerframework.javacutil.AnnotationMirrorSet;
7474

7575
final class NullSpecTransfer extends CFAbstractTransfer<CFValue, NullSpecStore, NullSpecTransfer> {
7676
private final Util util;
@@ -1019,7 +1019,8 @@ private boolean valueIsAtLeastAsSpecificAs(CFValue value, CFValue targetDataflow
10191019
if (target == null) {
10201020
return false;
10211021
}
1022-
return atypeFactory.getQualifierHierarchy().greatestLowerBound(existing, target) == existing;
1022+
return atypeFactory.getQualifierHierarchy().greatestLowerBoundQualifiersOnly(existing, target)
1023+
== existing;
10231024
}
10241025

10251026
private static boolean isNullLiteral(Node node) {
@@ -1052,7 +1053,8 @@ private void setResultValue(
10521053
* if (clazz.cast(foo) != null) { return class.cast(foo); }
10531054
*/
10541055
result.setResultValue(
1055-
analysis.createAbstractValue(singleton(qual), result.getResultValue().getUnderlyingType()));
1056+
analysis.createAbstractValue(
1057+
AnnotationMirrorSet.singleton(qual), result.getResultValue().getUnderlyingType()));
10561058
}
10571059

10581060
private JavaExpression expressionToStoreFor(Node node) {

src/main/java/com/google/jspecify/nullness/NullSpecVisitor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060
import com.sun.source.tree.TypeParameterTree;
6161
import com.sun.source.tree.VariableTree;
6262
import java.util.ArrayList;
63-
import java.util.HashSet;
6463
import java.util.List;
65-
import java.util.Set;
6664
import javax.lang.model.element.AnnotationMirror;
6765
import javax.lang.model.element.Element;
6866
import javax.lang.model.element.ElementKind;
@@ -75,6 +73,7 @@
7573
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType;
7674
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType;
7775
import org.checkerframework.javacutil.AnnotationBuilder;
76+
import org.checkerframework.javacutil.AnnotationMirrorSet;
7877

7978
final class NullSpecVisitor extends BaseTypeVisitor<NullSpecAnnotatedTypeFactory> {
8079
private final boolean checkImpl;
@@ -100,9 +99,11 @@ private void ensureNonNull(Tree tree, String messageKey) {
10099
}
101100
}
102101

102+
/* TODO: implement feature to add extra args to return type errors.
103+
*
103104
@Override
104105
protected String extraArgForReturnTypeError(Tree tree) {
105-
/*
106+
/
106107
* We call originStringIfTernary, not originString:
107108
*
108109
* If the statement is `return foo.bar()`, then the problem is obvious, so we don't want our
@@ -115,10 +116,11 @@ protected String extraArgForReturnTypeError(Tree tree) {
115116
* the possibly null value (possibly both!). However, this gets tricky: If the branches return
116117
* `Foo?` and `Foo*`, then we ideally want to emphasize the `Foo?` branch *but*, at least in
117118
* "strict mode," not altogether ignore the `Foo*` branch.
118-
*/
119+
/
119120
String origin = originStringIfTernary(tree);
120121
return origin.isEmpty() ? "" : (origin + "\n");
121122
}
123+
*/
122124

123125
private String originString(Tree tree) {
124126
while (tree instanceof ParenthesizedTree) {
@@ -621,8 +623,8 @@ private boolean isClassCastAppliedToNonNullableType(MemberReferenceTree tree) {
621623
}
622624

623625
@Override
624-
protected Set<? extends AnnotationMirror> getExceptionParameterLowerBoundAnnotations() {
625-
return new HashSet<>(asList(AnnotationBuilder.fromClass(elements, MinusNull.class)));
626+
protected AnnotationMirrorSet getExceptionParameterLowerBoundAnnotations() {
627+
return new AnnotationMirrorSet(asList(AnnotationBuilder.fromClass(elements, MinusNull.class)));
626628
}
627629

628630
@Override

src/test/java/tests/ConformanceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ static final class DetailMessageReportedFact extends ReportedFact {
154154

155155
private static final ImmutableSet<String> CANNOT_CONVERT_KEYS =
156156
ImmutableSet.of(
157-
"argument",
158-
"assignment",
157+
"argument.type.incompatible",
158+
"assignment.type.incompatible",
159159
"atomicreference.must.include.null",
160160
"cast.unsafe",
161161
"lambda.param",
@@ -164,9 +164,9 @@ static final class DetailMessageReportedFact extends ReportedFact {
164164
"methodref.return",
165165
"override.param",
166166
"override.return",
167-
"return",
167+
"return.type.incompatible",
168168
"threadlocal.must.include.null",
169-
"type.argument");
169+
"type.argument.type.incompatible");
170170

171171
private static final ImmutableSet<String> IRRELEVANT_ANNOTATION_KEYS =
172172
ImmutableSet.of(

src/test/java/tests/NullSpecTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,20 @@ private boolean corresponds(TestDiagnostic missing, DetailMessage unexpected) {
156156
|| missing.getMessage().contains("jspecify_nullness_mismatch")
157157
|| missing.getMessage().contains("test:cannot-convert")) {
158158
switch (unexpected.messageKey) {
159-
case "argument":
160-
case "assignment":
159+
case "argument.type.incompatible":
160+
case "assignment.type.incompatible":
161161
case "atomicreference.must.include.null":
162162
case "cast.unsafe":
163163
case "dereference":
164-
case "lambda.param":
165-
case "methodref.receiver.bound":
166-
case "methodref.receiver":
167-
case "methodref.return":
168-
case "override.param":
169-
case "override.return":
170-
case "return":
164+
case "lambda.param.type.incompatible":
165+
case "methodref.receiver.bound.invalid":
166+
case "methodref.receiver.invalid":
167+
case "methodref.return.invalid":
168+
case "override.param.invalid":
169+
case "override.return.invalid":
170+
case "return.type.incompatible":
171171
case "threadlocal.must.include.null":
172-
case "type.argument":
172+
case "type.argument.type.incompatible":
173173
return true;
174174
default:
175175
return false;
@@ -196,7 +196,7 @@ private boolean corresponds(TestDiagnostic missing, DetailMessage unexpected) {
196196
* custom `*.annotated` error. This test probably doesn't confirm that second thing
197197
* anymore, but I did manually confirm that it is true as of this writing.
198198
*/
199-
case "bound":
199+
case "bound.type.incompatible":
200200
case "local.variable.annotated":
201201
case "type.parameter.annotated":
202202
case "wildcard.annotated":

0 commit comments

Comments
 (0)