Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new TypeUseLocation default locations #165

Merged
merged 30 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
33817d8
Use EISOP CF sources (#118)
wmdietl Feb 6, 2024
324d817
Document that detail messages should not be filtered out (#146)
wmdietl Feb 6, 2024
1ef0817
Update `tests/ConformanceTest-report.txt` (#157)
wmdietl Feb 7, 2024
e673ee8
Use standard error format (#154)
wmdietl Feb 8, 2024
209435e
Handle both `https` and `git@` clones (#158)
wmdietl Feb 8, 2024
d9e96d0
Use the new `TypeInformationPresenter` to output more type informatio…
wmdietl Feb 8, 2024
1362fa2
Use the new `TypeUseLocation.IMPLICIT_WILDCARD_UPPER_BOUND`
wmdietl Feb 8, 2024
4a8bd5b
Split out fields for NullMarked default locations, to make it easier
wmdietl Feb 26, 2024
cb1c7b2
Add test for issue #161
wmdietl Feb 26, 2024
cbebcf2
Check out related eisop branch
wmdietl Feb 26, 2024
a1a45fc
Remove debugging output
wmdietl Feb 26, 2024
8eb4ab8
Map `type.invalid.super.wildcard` as an expected error (#166)
wmdietl Feb 27, 2024
fad09d5
Merge branch 'main-eisop' of github.com:jspecify/jspecify-reference-c…
wmdietl Feb 27, 2024
04b8d84
Remove special handling of type variables. Fixes #159.
wmdietl Feb 27, 2024
9ee2796
Use `hasEffectiveAnnotation` to handle TVs in bounds. Fixes #164.
wmdietl Feb 27, 2024
93b50dc
Use dedicated `ParametricNull` qualifier
wmdietl Feb 28, 2024
cf2aa1d
CF branch was merged
wmdietl Feb 28, 2024
859669f
Specify hierarchy
wmdietl Feb 28, 2024
f73dfbf
Use `hasAnnotation` with `unionNull`, pending further investigation
wmdietl Feb 28, 2024
41a4ce4
Apply spotless
wmdietl Feb 28, 2024
e073d35
Adapt a few more error keys
wmdietl Mar 5, 2024
77dc086
Undo some has[Effective]Annotation changes
wmdietl Mar 26, 2024
752ad09
Rerun conformance tests
wmdietl Mar 26, 2024
88d9c88
Output details in conformance tests
wmdietl Mar 28, 2024
a4d344b
Re-instate work-around to type variable bound issue
wmdietl Apr 10, 2024
acf4230
Merge branch 'main-eisop' of github.com:jspecify/jspecify-reference-c…
wmdietl Apr 10, 2024
5c25a46
Add tests for #159, #161, and #163.
wmdietl Apr 10, 2024
ac7487f
Ensure tests are properly formatted
wmdietl Apr 10, 2024
9ba1aa8
Add test of overrides.
wmdietl Apr 10, 2024
2588340
Move regression tests to `tests/regression`.
wmdietl Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ jobs:
run: ./gradlew build conformanceTests demoTest --include-build ../jspecify
env:
SHALLOW: 1
- name: Check out jspecify/samples-google-prototype
JSPECIFY_CONFORMANCE_TEST_MODE: details
- name: Check out jspecify/samples-google-prototype-eisop
if: always()
run: |
git fetch --depth=1 origin samples-google-prototype
git checkout samples-google-prototype
git fetch --depth=1 origin samples-google-prototype-eisop
git checkout samples-google-prototype-eisop
working-directory: jspecify
- name: Run Samples Tests
if: always()
Expand Down
13 changes: 10 additions & 3 deletions initialize-project
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Set SHALLOW=1 to clone sibling projects at depth 1.
#
# This script automatically tries to download your fork of
# jspecify/checker-framework, jspecify/jspecify, or jspecify/jdk, if they exist.
# eisop/checker-framework, jspecify/jspecify, or jspecify/jdk, if they exist.
# It uses the URL of the origin remote (the default remote created when cloning
# a repo) to determine that.
#
Expand Down Expand Up @@ -55,12 +55,19 @@ git_clone() {

local forking_org
forking_org="$(forking_org)"
if [[ -n "${forking_org}" ]]; then
if [[ -n "${forking_org}" ]] \
&& [[ "${forking_org}" != "https://github.com/jspecify" ]] \
&& [[ "${forking_org}" != "[email protected]:jspecify" ]] ; then
if run "${git[@]}" "${forking_org}/${repo}.git" "../${repo}"; then
return
fi
fi
run "${git[@]}" "https://github.com/jspecify/${repo}.git" "../${repo}"
if [[ "${repo}" == "checker-framework" ]]; then
forking_org=https://github.com/eisop
else
forking_org=https://github.com/jspecify
fi
run "${git[@]}" "${forking_org}/${repo}.git" "../${repo}"
}

git_clone jdk --depth 1 --single-branch
Expand Down
12 changes: 6 additions & 6 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ includeBuild("../checker-framework")
dependencyResolutionManagement {
versionCatalogs {
libs {
version("checkerFramework", "3.21.5-SNAPSHOT")
version("checkerFramework", "3.42.0-eisop3-SNAPSHOT")

library("checkerFramework-checker", "org.checkerframework", "checker").versionRef("checkerFramework")
library("checkerFramework-checker-qual", "org.checkerframework", "checker-qual").versionRef("checkerFramework")
library("checkerFramework-framework", "org.checkerframework", "framework").versionRef("checkerFramework")
library("checkerFramework-framework-test", "org.checkerframework", "framework-test").versionRef("checkerFramework")
library("checkerFramework-javacutil", "org.checkerframework", "javacutil").versionRef("checkerFramework")
library("checkerFramework-checker", "io.github.eisop", "checker").versionRef("checkerFramework")
library("checkerFramework-checker-qual", "io.github.eisop", "checker-qual").versionRef("checkerFramework")
library("checkerFramework-framework", "io.github.eisop", "framework").versionRef("checkerFramework")
library("checkerFramework-framework-test", "io.github.eisop", "framework-test").versionRef("checkerFramework")
library("checkerFramework-javacutil", "io.github.eisop", "javacutil").versionRef("checkerFramework")
library("errorProne-core", "com.google.errorprone:error_prone_core:2.18.0")
library("errorProne-javac", "com.google.errorprone:javac:9+181-r4173-1")
library("guava", "com.google.guava:guava:31.1-jre")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2024 The JSpecify Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.jspecify.nullness;

import com.sun.source.tree.AssignmentTree;
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.Tree;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
import org.checkerframework.framework.type.AnnotatedTypeFactory;
import org.checkerframework.framework.type.AnnotatedTypeFormatter;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType;
import org.checkerframework.framework.util.visualize.AbstractTypeInformationPresenter;
import org.checkerframework.framework.util.visualize.TypeOccurrenceKind;
import org.checkerframework.javacutil.TreeUtils;

/**
* Output "sinkType" and "sourceType" diagnostic warning messages so the conformance tests can look
* for (a subset of) them.
*/
public final class ConformanceTypeInformationPresenter extends AbstractTypeInformationPresenter {

/**
* Constructs a presenter for the given factory.
*
* @param atypeFactory the AnnotatedTypeFactory for the current analysis
*/
public ConformanceTypeInformationPresenter(AnnotatedTypeFactory atypeFactory) {
super(atypeFactory);
}

@Override
protected AnnotatedTypeFormatter createTypeFormatter() {
// Use the same type formatter as normal error messages. Look into whether a different format
// would be better here.
return atypeFactory.getAnnotatedTypeFormatter();
}

@Override
protected TypeInformationReporter createTypeInformationReporter(ClassTree tree) {
return new ConformanceTypeInformationReporter(tree);
}

class ConformanceTypeInformationReporter extends TypeInformationReporter {
ConformanceTypeInformationReporter(ClassTree tree) {
super(tree);
}

@Override
protected void reportTreeType(
Tree tree, AnnotatedTypeMirror type, TypeOccurrenceKind occurrenceKind) {
switch (tree.getKind()) {
case ASSIGNMENT:
AssignmentTree asgn = (AssignmentTree) tree;
AnnotatedTypeMirror varType =
genFactory != null
? genFactory.getAnnotatedTypeLhs(asgn.getVariable())
: atypeFactory.getAnnotatedType(asgn.getVariable());
checker.reportWarning(
asgn.getVariable(),
"sinkType",
typeFormatter.format(varType),
asgn.getVariable().toString());
break;
case RETURN:
checker.reportWarning(tree, "sinkType", typeFormatter.format(type), "return");
break;
case METHOD_INVOCATION:
ExecutableElement calledElem = TreeUtils.elementFromUse((MethodInvocationTree) tree);
String methodName = calledElem.getSimpleName().toString();
AnnotatedExecutableType calledType = (AnnotatedExecutableType) type;
List<? extends AnnotatedTypeMirror> params = calledType.getParameterTypes();
MethodInvocationTree mit = (MethodInvocationTree) tree;
List<? extends ExpressionTree> args = mit.getArguments();
assert params.size() == args.size();

for (int i = 0; i < params.size(); ++i) {
String paramName = calledElem.getParameters().get(i).getSimpleName().toString();
String paramLocation = String.format("%s#%s", methodName, paramName);
checker.reportWarning(
tree, "sinkType", typeFormatter.format(params.get(i)), paramLocation);
}
break;
default:
// Nothing special for other trees.
}

if (TreeUtils.isExpressionTree(tree)) {
checker.reportWarning(tree, "sourceType", typeFormatter.format(type), tree.toString());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

package com.google.jspecify.nullness;

import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.type.TypeMirror;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.framework.flow.CFAbstractAnalysis;
import org.checkerframework.framework.flow.CFValue;
import org.checkerframework.javacutil.AnnotationMirrorSet;

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

@Override
public CFValue createAbstractValue(Set<AnnotationMirror> annotations, TypeMirror underlyingType) {
public CFValue createAbstractValue(AnnotationMirrorSet annotations, TypeMirror underlyingType) {
return defaultCreateAbstractValue(this, annotations, underlyingType);
}
}
Loading
Loading