Skip to content

Commit

Permalink
Recognize an experimental protobuf @polynull annotation (opprop#147)
Browse files Browse the repository at this point in the history
Co-authored-by: Werner Dietl <[email protected]>
  • Loading branch information
cpovirk and wmdietl authored Jan 14, 2022
1 parent 96c952c commit 8d9f50c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ public class NullnessAnnotatedTypeFactory
// https://github.com/reactor/reactor-core/blob/main/reactor-core/src/main/java/reactor/util/annotation/Nullable.java
"reactor.util.annotation.Nullable");

// List is in alphabetical order. If you update it, also update
// ../../../../../../../../docs/manual/nullness-checker.tex .
// See more comments with NONNULL_ALIASES above.
/** Aliases for {@code @PolyNull}. */
@SuppressWarnings(
"signature:assignment.type.incompatible") // Class names intentionally obfuscated
private static final List<@FullyQualifiedName String> POLYNULL_ALIASES =
Arrays.asList(
// "com.google.protobuf.Internal.ProtoPassThroughNullness",
"com.go".toString() + "ogle.protobuf.Internal.ProtoPassThroughNullness");

/**
* Creates a NullnessAnnotatedTypeFactory.
*
Expand All @@ -316,6 +327,7 @@ public NullnessAnnotatedTypeFactory(BaseTypeChecker checker) {

NONNULL_ALIASES.forEach(annotation -> addAliasedTypeAnnotation(annotation, NONNULL));
NULLABLE_ALIASES.forEach(annotation -> addAliasedTypeAnnotation(annotation, NULLABLE));
POLYNULL_ALIASES.forEach(annotation -> addAliasedTypeAnnotation(annotation, POLYNULL));

// Add compatibility annotations:
addAliasedTypeAnnotation(
Expand Down
26 changes: 24 additions & 2 deletions docs/manual/nullness-checker.tex
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,9 @@
annotation, the Checker Framework can type-check your code.
It treats annotations from other tools
as if you had written the corresponding annotation from the
Nullness Checker, as described in Figures~\ref{fig-nullness-refactoring-nonnull}
and \ref{fig-nullness-refactoring-nullable}.
Nullness Checker, as described in Figures~\ref{fig-nullness-refactoring-nonnull},
\ref{fig-nullness-refactoring-nullable}, and
\ref{fig-nullness-refactoring-polynull}.
If the other annotation is a declaration annotation, it may be moved; see
Section~\ref{declaration-annotations-moved}.

Expand Down Expand Up @@ -1046,6 +1047,27 @@
\label{fig-nullness-refactoring-nullable}
\end{figure}

% See comments above previous table.
\begin{figure}
\begin{center}
\begin{tabular}{ll}
\begin{tabular}{|l|l|}
\hline
~com.google.protobuf.Internal.ProtoPassThroughNullness~ \\ \hline
\end{tabular}
&
$\Rightarrow$
~org.checkerframework.checker.nullness.qual.PolyNull~
\end{tabular}
\end{center}
%BEGIN LATEX
\vspace{-1.5\baselineskip}
%END LATEX
\caption{Correspondence between other nullness annotations and the
Checker Framework's \<PolyNull> annotation.}
\label{fig-nullness-refactoring-polynull}
\end{figure}

%% Removed, because it's tedious and should be obvious to a decent programmer.
% Your IDE may be able to do that for you. Alternately, do the following:
% \begin{enumerate}
Expand Down

0 comments on commit 8d9f50c

Please sign in to comment.