Martin Desruisseaux created SIS-578:
---------------------------------------
Summary: Remove contravariance in filters and expressions
Key: SIS-578
URL: https://issues.apache.org/jira/browse/SIS-578
Project: Spatial Information Systems
Issue Type: Task
Components: Features
Affects Versions: 1.3, 1.2, 1.1
Reporter: Martin Desruisseaux
Assignee: Martin Desruisseaux
Fix For: 1.4
Since SIS 1.1, Filters and expressions in {{org.apache.sis.filter}} package
have methods with a signature like below. This signature reproduced the state
of GeoAPI 3.1 draft (not yet released).
{code:java}
List<Expression<? super R, ?>> getParameters();
{code}
However experience has shown that contravariance (the {{<? super>}} part) cause
difficulties that are hard to resolve. The problem is that filters are often
chained. When a code follows a chain of filters, it may need to check for
parameters of parameters. In such cases, invoking the above {{getParameters()}}
method, then invoking again {{getParameters()}} on the result, gives a type
that looks like {{<? super ? super R>>, which is identified by the Java
compiler as {{<? super #CAP1>}}. The consequence is many compilation errors of
the kind "no method match {{List<Expression<? super #CAP1, ?>>}} which are hard
to resolve otherwise than by unsafe cast. Consequently, for having more
type-safe code, it seems necessary to change above method signature like below:
{code:java}
List<Expression<R, ?>> getParameters();
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)