[cdi-dev] [JBoss JIRA] (CDI-736) Observer resolution - assignability clarification

Matej Novotny (JIRA) issues at jboss.org
Tue Sep 18 03:49:00 EDT 2018


Matej Novotny created CDI-736:
---------------------------------

             Summary: Observer resolution - assignability clarification
                 Key: CDI-736
                 URL: https://issues.jboss.org/browse/CDI-736
             Project: CDI Specification Issues
          Issue Type: Clarification
          Components: Resolution
    Affects Versions: 2.0.SP1
            Reporter: Matej Novotny


Recently we came up across an observer resolution issue which concerns [10.3.1. Assignability of type variables, raw and parameterized types|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#observers_assignability].

What happens when you are trying to assign a non-parameterized subclass to a parameterized superclass?
Here is a bit of code, we have following two classes:

{code}
public interface QualifiedEvent<T> {
 // some methods
}

public class EventImpl implements QualifiedEvent { //NOTE - implements raw type
 // some method impls
}
{code}

Here is observer code:
{code}
    void listenForChildEvent(@Observes QualifiedEvent<Bar> foo) {
      // stuff going on here...
    }
{code}

And your event type is:
{code}
new EventImpl(clazz);
{code}

In this scenario, the spec is IMO unclear on what should happen in this particular case.

Looking at other parts of spec, we already have this covered in, for instance, [delegate injection point assignability|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#delegate_assignable_parameters], where it says:

bq. A raw bean type is considered assignable to a parameterized delegate type if the raw types are identical and all type parameters of the delegate type are either unbounded type variables or java.lang.Object.

I think we should add a similar sentence to  [10.3.1. Assignability of type variables, raw and parameterized types|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#observers_assignability].



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the cdi-dev mailing list