[External] : Re: Can not call a private method, no idea why ?
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Jan 21 13:11:57 UTC 2021
Some further history - this was tweaked several years ago in 7:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6246814
There's also an open RFE on the spec:
https://bugs.openjdk.java.net/browse/JDK-6644562
Which basically refers to what we have discussed - e.g. the type system
rules being too conservative and applying intersection type semantics
even if there's only one bound.
Maurizio
On 21/01/2021 13:03, Maurizio Cimadamore wrote:
> I sympathize with your argument: at the end of the day, when you have
> X <: Foo, you can always widen (e.g. assign) X to Foo (w/o warnings)
> and take it from there, and all restrictions are gone - so maybe this
> is excessive hand-holding on the language-side - but I was trying to
> explain the rationale behind the rules - it is pretty common when
> dealing with parametric polymorphism to think of membership of a
> type-variable X in a "for all" semantics - e.g. the intersection of
> members that are available in all instantiations of X; so, for the
> language (and the compiler) X <: Foo and Foo are two very different
> types, with very different membership rules.
More information about the compiler-dev
mailing list