defaultvalue and enclosing instances
brian.goetz at oracle.com
Wed Sep 19 02:13:05 UTC 2018
We disallow no arg ctor, right? So what if the no arg ctor always returns default value, and then you can say outer.new inner()?
Sent from my iPad
> On Sep 14, 2018, at 9:26 PM, Srikanth <srikanth.adayapalam at oracle.com> wrote:
>> On Friday 14 September 2018 09:47 PM, Victor Nazarov wrote:
>> пт, 14 сент. 2018 г., 19:06 John Rose <john.r.rose at oracle.com <mailto:john.r.rose at oracle.com>>:
>> On Sep 14, 2018, at 1:32 AM, Srikanth
>> <srikanth.adayapalam at oracle.com
>> <mailto:srikanth.adayapalam at oracle.com>> wrote:
>> > ... (d) other solutions ...
>> The simplest one comes to mind: Allow T.default to have a default
>> of null, as a special case for inner values. Referring to the
>> outer instance from
>> a default inner instance will thus fail with NPE. "It hurts when
>> I do this, Doctor"
>> "Then don't do that."
>> But this means that you can't use enclosed value type instances.
> Not quite. Properly enclosed value instances can be created via the classic constructor notation: e.g:
> new Outer().new InnerValue();
More information about the valhalla-dev