' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
' We introduce a ByRef local, which will be used to refer to the receiver from within AccessExpression.
' Initially ByRefLocal is set to refer to the rewrittenReceiver location.
' The "receiver IsNot Nothing" check becomes
' Not <receiver's type is refernce type> OrElse { <capture value pointed to by ByRefLocal in a temp>, <store reference to the temp in ByRefLocal>, temp IsNot Nothing }
' Note that after that condition is executed, if it returns true, the ByRefLocal ponts to the captured value of the reference type, which is proven to be Not Nothing,
' and won't change after the null check (we own the local where the value is captured).
' Also, if receiver's type is value type ByRefLocal still points to the original location, which allows access side effects to be observed.
' The <receiver's type is refernce type> is performed by boxing default value of receiver's type and checking if it is a null reference. This makes Nullable
' type to be treated as a reference type, but it is Ok since it is immutable. The only strange thing is that we won't unwrap the nullable.