Skip to content

Commit

Permalink
Add more nullability annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Aug 29, 2020
1 parent 11ef05b commit 21074fd
Show file tree
Hide file tree
Showing 46 changed files with 379 additions and 262 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ jobs:
java-version: 11
- name: 'Run CheckerFramework'
uses: burrunan/gradle-cache-action@v1
name: Test
with:
job-id: checkerframework-jdk11
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ allprojects {
checkers.add("org.checkerframework.checker.nullness.NullnessChecker")
checkers.add("org.checkerframework.checker.optional.OptionalChecker")
checkers.add("org.checkerframework.checker.regex.RegexChecker")
extraJavacArgs.add("-Astubs=" +
fileTree("$rootDir/src/main/config/checkerframework") {
include("*.astub")
}.asPath
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public abstract class BaseQueryable<TSource>
extends AbstractQueryable<TSource> {
protected final QueryProvider provider;
protected final Type elementType;
protected final Expression expression;
protected final @Nullable Expression expression;

public BaseQueryable(QueryProvider provider, Type elementType,
Expression expression) {
@Nullable Expression expression) {
this.provider = provider;
this.elementType = elementType;
this.expression = expression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import org.apache.calcite.linq4j.function.Predicate1;
import org.apache.calcite.linq4j.function.Predicate2;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;

import java.math.BigDecimal;
import java.util.Collection;
Expand All @@ -54,7 +54,7 @@
*
* @param <T> Element type
*/
public abstract class DefaultEnumerable<T> implements OrderedEnumerable<T> {
public abstract class DefaultEnumerable<T extends @Nullable Object> implements OrderedEnumerable<T> {

/**
* Derived classes might wish to override this method to return the "outer"
Expand Down Expand Up @@ -92,12 +92,12 @@ protected OrderedQueryable<T> asOrderedQueryable() {
return EnumerableDefaults.asOrderedQueryable(this);
}

public T aggregate(Function2<T, T, T> func) {
public @Nullable T aggregate(Function2<@Nullable T, T, T> func) {
return EnumerableDefaults.aggregate(getThis(), func);
}

public <TAccumulate> TAccumulate aggregate(TAccumulate seed,
Function2<TAccumulate, T, TAccumulate> func) {
public <TAccumulate> @PolyNull TAccumulate aggregate(@PolyNull TAccumulate seed,
Function2<@PolyNull TAccumulate, T, TAccumulate> func) {
return EnumerableDefaults.aggregate(getThis(), seed, func);
}

Expand Down Expand Up @@ -194,11 +194,11 @@ public <TKey> OrderedEnumerable<T> createOrderedEnumerable(
keySelector, comparator, descending);
}

public Enumerable<T> defaultIfEmpty() {
public Enumerable<@Nullable T> defaultIfEmpty() {
return EnumerableDefaults.defaultIfEmpty(getThis());
}

public Enumerable<T> defaultIfEmpty(T value) {
public Enumerable<@PolyNull T> defaultIfEmpty(@PolyNull T value) {
return EnumerableDefaults.defaultIfEmpty(getThis(), value);
}

Expand All @@ -214,7 +214,7 @@ public T elementAt(int index) {
return EnumerableDefaults.elementAt(getThis(), index);
}

public T elementAtOrDefault(int index) {
public @Nullable T elementAtOrDefault(int index) {
return EnumerableDefaults.elementAtOrDefault(getThis(), index);
}

Expand Down Expand Up @@ -248,7 +248,7 @@ public T first(Predicate1<T> predicate) {
return EnumerableDefaults.firstOrDefault(getThis());
}

public T firstOrDefault(Predicate1<T> predicate) {
public @Nullable T firstOrDefault(Predicate1<T> predicate) {
return EnumerableDefaults.firstOrDefault(getThis(), predicate);
}

Expand Down Expand Up @@ -431,11 +431,11 @@ public T last(Predicate1<T> predicate) {
return EnumerableDefaults.last(getThis(), predicate);
}

public T lastOrDefault() {
public @Nullable T lastOrDefault() {
return EnumerableDefaults.lastOrDefault(getThis());
}

public T lastOrDefault(Predicate1<T> predicate) {
public @Nullable T lastOrDefault(Predicate1<T> predicate) {
return EnumerableDefaults.lastOrDefault(getThis(), predicate);
}

Expand Down Expand Up @@ -624,11 +624,11 @@ public T single(Predicate1<T> predicate) {
return EnumerableDefaults.single(getThis(), predicate);
}

public T singleOrDefault() {
public @Nullable T singleOrDefault() {
return EnumerableDefaults.singleOrDefault(getThis());
}

public T singleOrDefault(Predicate1<T> predicate) {
public @Nullable T singleOrDefault(Predicate1<T> predicate) {
return EnumerableDefaults.singleOrDefault(getThis(), predicate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.apache.calcite.linq4j.function.Predicate2;
import org.apache.calcite.linq4j.tree.FunctionExpression;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.math.BigDecimal;
import java.util.Comparator;
Expand Down Expand Up @@ -150,7 +150,7 @@ public Enumerator<T> enumerator() {
return factory.ofType(getThis(), clazz);
}

@Override public Queryable<T> defaultIfEmpty() {
@Override public Queryable<@Nullable T> defaultIfEmpty() {
return factory.defaultIfEmpty(getThis());
}

Expand All @@ -164,7 +164,7 @@ public Enumerator<T> enumerator() {

// End disambiguate

public T aggregate(FunctionExpression<Function2<T, T, T>> selector) {
public @Nullable T aggregate(FunctionExpression<Function2<@Nullable T, T, T>> selector) {
return factory.aggregate(getThis(), selector);
}

Expand Down Expand Up @@ -245,7 +245,7 @@ public T first(FunctionExpression<Predicate1<T>> predicate) {
return factory.first(getThis(), predicate);
}

public T firstOrDefault(FunctionExpression<Predicate1<T>> predicate) {
public @Nullable T firstOrDefault(FunctionExpression<Predicate1<T>> predicate) {
return factory.firstOrDefault(getThis(), predicate);
}

Expand Down Expand Up @@ -423,7 +423,7 @@ public T single(FunctionExpression<Predicate1<T>> predicate) {
return factory.single(getThis(), predicate);
}

public T singleOrDefault(FunctionExpression<Predicate1<T>> predicate) {
public @Nullable T singleOrDefault(FunctionExpression<Predicate1<T>> predicate) {
return factory.singleOrDefault(getThis(), predicate);
}

Expand Down
Loading

0 comments on commit 21074fd

Please sign in to comment.