Change regarding conditional expression & capture & lub?

Stephan Herrmann stephan.herrmann at
Mon Dec 9 17:28:26 PST 2013

On 12/09/2013 09:40 PM, Dan Smith wrote:
> On Dec 8, 2013, at 8:56 AM, Stephan Herrmann <stephan.herrmann at> wrote:
>> This doesn't seem directly connected to JSR 335 but I wonder
>> if the following change in behavior has s.t. to do with the
>> type checking we are discussing here:
>>   class A{/**/}
>>   class B extends A {/**/}
>>   class G<T> {
>>     G<B> gb=null;
>>     G<? super A> gsa=null;
>>     G<? super B> l = (true)? gsa : gb;
>>   }
>> javac7- rejects this, which corresponds to my understanding of the JLS:
>> (1) capture the types of gsa and gb, respectively.
>> (2) compute the lub
>> (3) detect type mismatch
>> javac8, OTOH, accepts the snippet.
>> Has the specification for any of the three steps been changed?
> Yes!  Conditional expressions can be poly expressions.  See Part D, 15.25.

I've seen that, but couldn't see a connection because ...

> The relevant change is that poly conditionals do not perform lub at all.  Instead, they simply check that each branch is compatible with the target type, and then consider the expression to have the same type as its target type.

... it seems javac applies that rule also to standalone expressions.
Or it considers a variable access as a poly expression... or ...

IOW, is it expected that the example above is affected by the
spec changes?


More information about the lambda-spec-experts mailing list