Start Wildcard elimination example

This commit is contained in:
Andreas Stadelmeier 2024-05-06 12:11:57 +02:00
parent 72dff3fa36
commit 5cd90a9593

View File

@ -108,6 +108,22 @@ List<? extends Object> someList(){
}
\end{lstlisting}
\subsection{Wildcard Elimination Example}
\begin{lstlisting}
<X> List<X> concat(List<X> l, List<X> l2){ ... }
someList(){
return new List("String") :? new List(42);
}
concat(someList(), someList());
\end{lstlisting}
Let's add an additional method call to the previous example.
The \texttt{concat} method takes two lists of the same generic type.
\texttt{concat} cannot be invoked with two existential lists.
%TODO: Explain capture conversion
\subsection{Description}
The \unify{} algorithm tries to find a solution for a set of constraints like
$\set{\exptype{List}{String} \lessdot \tv{a}, \exptype{List}{Integer} \lessdot \tv{a}}$.