Merge branch 'master' of ssh://gitea.hb.dhbw-stuttgart.de:2222/stan/Ecoop2024_TIforWildFJ
This commit is contained in:
commit
df22ed5cce
@ -17,13 +17,35 @@ List<String> ls = emptyList();
|
||||
|
||||
Local type inference \cite{javaTIisBroken} is able to find a type substitution $\sigma$ satisfying
|
||||
$\overline{\type{A} <: \sigma(\type{F}) }, \sigma(\type{R}) <: \type{E}$.
|
||||
It is important that $\overline{\type{A}}$ and $\type{E}$ are given types and do not contain
|
||||
type placeholders already used in $\overline{\type{F}}$.
|
||||
|
||||
The type parameters are not allowed on the left side of $A <: F$
|
||||
We can generate method calls where this is the case. The second call to \texttt{get}.
|
||||
|
||||
Local type inference is based on matching and not unification.
|
||||
When calling the \texttt{emptyList} method without context its return value will be set to a \texttt{List<Object>}.
|
||||
The following Java code snippet is incorrect, because \texttt{emptyList()} returns
|
||||
a \texttt{List<Object>} instead of the required \texttt{List<String>}.
|
||||
\begin{verbatim}
|
||||
emptyList().get(0).get(0);
|
||||
emptyList().add(new List<String>())
|
||||
.get(0)
|
||||
.get(0);
|
||||
\end{verbatim}
|
||||
%List<String> <. A
|
||||
%List<A> <: List<B>, B <: List<C>
|
||||
% B = A and therefore A on the left and right side of constraints.
|
||||
% this makes matching impossible
|
||||
|
||||
\begin{verbatim}
|
||||
this.<List<String>>emptyList().add(new List<String>())
|
||||
.get(0)
|
||||
.get(0);
|
||||
\end{verbatim}
|
||||
|
||||
Local type inference cannot deal with type inference during the algorithm.
|
||||
If the left side contains unknown type parameters.
|
||||
|
||||
|
||||
\begin{verbatim}
|
||||
import java.util.ArrayList;
|
||||
|
Loading…
Reference in New Issue
Block a user