Bug 471237 - [1.8][inference] Reconsider tweak in ConstraintExpressionFormula.inferPolyInvocationType()
Summary: [1.8][inference] Reconsider tweak in ConstraintExpressionFormula.inferPolyInv...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug spec
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-28 10:02 EDT by Stephan Herrmann CLA
Modified: 2023-03-24 14:59 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2015-06-28 10:02:26 EDT
Inside ConstraintExpressionFormula.inferPolyInvocationType() we have a tweak commented thusly:

// continuing at true is not spec'd but needed for javac-compatibility,
// see org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_1_8.testBug428198()

After implementing the tweak I received this answer from Dan Smith:

My Question:
> > Is javac right to accept this program?
> >(I couldn't find an existing bug for this)
> >
> >import java.util.*;
> >interface A {}
> >interface B extends A {}
> >public class Z {
> >  static Collection<A> test(B[] array) {
> >    Collection<A> collection =
> >      Collections.unmodifiableCollection(
> >          array == null ? Collections.EMPTY_LIST : Arrays.asList((A[]) array));
> >    return collection;
> >  }
> >}
> >
> >While reducing the constraint regarding EMPTY_LIST:
> >  List → Collection<? extends T#0>
> >we need to apply unchecked conversion, which is remembered for later.
> >
> >Then during 18.5.2. we apply bullet 3.1:
> >  "If unchecked conversion was necessary for the method to be applicable in 18.5.1 ..."
> >creating this constraint:
> >  ⟨Collection → Collection<A>⟩
> >As all subsequent bullets at that level are skipped
> >(due to the "Otherwise, ..." disjunction)
> >the parameter A in the target type has no effect on inference.
> >
> >Hence parameterization of that method is inferred as:
> >   Collection<Object> unmodifiableCollection(Collection<? extends Object>)

Dan's answer:
> Here's where you depart from the spec.  See the last step from 18.5.2.
> 
> "Then apply θ' to the type of m. If unchecked conversion was not necessary for the method to be applicable in 18.5.1, then this is the invocation type of m; if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type, while the return type and thrown types are given by the erasure of m's type (without applying θ')."
> 
> (This is a fairly recent tweak, as of 0.9.0 (December).)

I should try to avoid the un-spec'd tweak and replace it with the spec change from 0.9.0.
Comment 1 Manoj N Palat CLA 2018-05-16 12:56:33 EDT
bulk move out of 4.8
Comment 2 Eclipse Genie CLA 2020-11-09 18:35:02 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2023-03-24 14:59:46 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.