Roslyn: Suboptimal code for e is null

Created on 18 Aug 2016  路  8Comments  路  Source: dotnet/roslyn

Currently e is null translates to an object.Equals call on master. The question is that (1) does it meant to be a shorthand for explicit reference null check (object)e == null? If so, (2) shouldn't it just translate to a ceq?

1 - Planning Area-Compilers Bug New Language Feature - Pattern Matching

All 8 comments

What if e is a nullable value type? But I agree, the compiler can check this at compile time and emit better code for reference types.

@alrz they should generate the same code

@gafter if so, I think this covers #8409 unless you have two non-constant expressions.

Moving out for now as this doesn't meet the RTM bar.

Did you want to move #16129 out too?

Also #14252

Yes and Yes. Thanks!

:bulb: See #19803 for a very descriptive breakdown of the current and expected behavior for both Nullable<T> and reference types.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marler8997 picture marler8997  路  3Comments

OndrejPetrzilka picture OndrejPetrzilka  路  3Comments

vbcodec picture vbcodec  路  3Comments

NikChao picture NikChao  路  3Comments

johndog picture johndog  路  3Comments