Looks like there are two problems which were discussed here. I'm going to reject this issue, but here is my reasoning why I'm doing so (apart from the fact that both, CDI TCK lead and CDI spec lead, agreed on the test being correct): Firstly, it was disputed that the test restricts the types of the producer in an incorrect way. The test itself does not make use of @Typed to restrict it, it instead replaces the whole AT. The method itself returns Carrot as it is and we only swapped the getTypeClosure() call, which is used to determine bean types of any kind of bean. Hence the producer still makes sense. One of the relevant parts of spec says:
...the container must:
call Annotated.getBaseType() to determine the type of an injection point, event parameter or disposed parameter,
call Annotated.getTypeClosure() to determine the bean types of any kind of bean,....
And secondly, in regards to Producer-Disposer matching problem - according to specification, the Annotated interface:
getTypeClosure() returns all types to which the base type should be considered assignable.
Changing this has direct effect on bean's assignability to injection points but also to disposer methods. This basically says that for every IP, you look at the getBaseType() and then try to match it against all beans' getClosureType() to see if you get a type match. Test changes getTypeClosure() for createVegetable() producer method to Carrot. The disposer method is altered in a similar way, via getBaseType() - again to Carrot. Hence you are now matching disposer's getBaseType() (Carrot) to producer's getTypeClosure() (Carrot) which is totally valid. I reckon that the bits and pieces of important information are scattered throughout the spec but putting them together, I can only see this test as valid, although not a common case for sure. |