Skip to content

Abstract null comparison / assign #12415

@ncannasse

Description

@ncannasse

I'm using an abstract over an Int64 to represent some objects.
This is working well, but since Int64 is not nullable, I cannot implement either null check ( == null / != null ) or null assignment ( abs = null ).
I think these should be allowed as overrides on abstracts, at least on static platforms where null is not a valid value for these.

This would allow the following:

if( value == null )  {...} // compiles to if( AbsImpl.isNull(value) )
if( value != null ) {...} // compiles to if( !AbsImpl.isNull(value) )
value = null; // compiles to (inlined) AbsImpl.setNull(value) which allows setting value

Now if we compare a Null'able abs with a not nullable, we would need to be able to check isNull() as well, as a not null value which is isNull() should be strictly the same as a null value.

var value : Abs;
var nullValue : Null<Abs>;
if( value == nullValue ) { ... } // compiles to if( nullValue == null ? value.isNull() : (value == (nullValue:Abs)) )
if( nullValue1 == nullValue2 ) { ... } // ... a bit more complicated as we need to these both nullValue1/2 for both "real" null and .isNull() 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions