Start let insert example

This commit is contained in:
Andreas Stadelmeier 2024-01-31 18:05:22 +01:00
parent 8e3707b9a6
commit 921adc85b1

View File

@ -47,6 +47,29 @@ List<?> genList() {
%\label{fig:intro-example-code} %\label{fig:intro-example-code}
\end{figure} \end{figure}
In \cite{WildcardsNeedWitnessProtection} existential types have to be \textit{unpacked} before they can be used.
Our type inference algorithm has to add let statements surrounding method invocations.
\begin{figure}[tp]
\begin{subfigure}[t]{0.49\linewidth}
\begin{lstlisting}[style=fgj]
List<? super Integer> ls = ...;
ls.add(new Integer());
\end{lstlisting}
\caption{Method invocation}
\label{fig:intro-example-typeless}
\end{subfigure}
~
\begin{subfigure}[t]{0.49\linewidth}
\begin{lstlisting}[style=tfgj]
List<? super Integer> ls = ...;
ls.add(new Integer());
\end{lstlisting}
\caption{Capture Conversion by \texttt{let}-statement}
\label{fig:intro-example-typed}
\end{subfigure}
\end{figure}
% \subsection{Wildcards} % \subsection{Wildcards}
% Java subtyping involving generics is invariant. % Java subtyping involving generics is invariant.
% For example \texttt{List<String>} is not a subtype of \texttt{List<Object>}. % For example \texttt{List<String>} is not a subtype of \texttt{List<Object>}.