Skip to content

Commit 0e8b988

Browse files
committed
Correctly classify null literal conversion
Add normative language that a null literal conversion is classified as an implicit reference conversions. Add an informative note in 10.2.8 that provides a cross reference to the same.
1 parent 779a05a commit 0e8b988

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

standard/conversions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ The implicit nullable conversions are those nullable conversions ([§10.6.1](con
149149
150150
### 10.2.7 Null literal conversions
151151
152-
An implicit conversion exists from the `null` literal to any reference type or nullable value type. This conversion produces a null reference if the target type is a reference type, or the null value ([§8.3.12](types.md#8312-nullable-value-types)) of the given nullable value type.
152+
An implicit conversion exists from the `null` literal to any reference type or nullable value type. This conversion produces a null reference if the target type is a reference type, or the null value ([§8.3.12](types.md#8312-nullable-value-types)) of the given nullable value type. A null literal conversion to a reference type is also classified as an implicit reference conversion ([§10.2.8](conversions.md#1028-implicit-reference-conversions)).
153153
154154
### 10.2.8 Implicit reference conversions
155155
@@ -165,11 +165,12 @@ The implicit reference conversions are:
165165
- From a single-dimensional array type `S[]` to `System.Collections.Generic.IList<T>`, `System.Collections.Generic.IReadOnlyList<T>`, and their base interfaces, provided that there is an implicit identity or reference conversion from `S` to `T`.
166166
- From any *array_type* to `System.Array` and the interfaces it implements.
167167
- From any *delegate_type* to `System.Delegate` and the interfaces it implements.
168-
- From the null literal ([§6.4.5.7](lexical-structure.md#6457-the-null-literal)) to any reference-type.
169168
- From any *reference_type* to a *reference_type* `T` if it has an implicit identity or reference conversion to a *reference_type* `T₀` and `T₀` has an identity conversion to `T`.
170169
- From any *reference_type* to an interface or delegate type `T` if it has an implicit identity or reference conversion to an interface or delegate type `T₀` and `T₀` is variance-convertible ([§19.2.3.3](interfaces.md#19233-variance-conversion)) to `T`.
171170
- Implicit conversions involving type parameters that are known to be reference types. See10.2.12](conversions.md#10212-implicit-conversions-involving-type-parameters) for more details on implicit conversions involving type parameters.
172171
172+
> *Note*: A null literal conversion ([§10.2.7](conversions.md#1027-null-literal-conversions)) to a reference type is also classified as an implicit reference conversion. *end note*
173+
173174
The implicit reference conversions are those conversions between *reference_type*s that can be proven to always succeed, and therefore require no checks at run-time.
174175
175176
Reference conversions, implicit or explicit, never change the referential identity of the object being converted.

0 commit comments

Comments
 (0)