From 0e8b9886a5c0a2214a034e6236c37f7b60393f43 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 16 Apr 2026 11:17:58 -0400 Subject: [PATCH] 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. --- standard/conversions.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/standard/conversions.md b/standard/conversions.md index 4ec9e62b8..7e419fc66 100644 --- a/standard/conversions.md +++ b/standard/conversions.md @@ -149,7 +149,7 @@ The implicit nullable conversions are those nullable conversions ([§10.6.1](con ### 10.2.7 Null literal conversions -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. +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)). ### 10.2.8 Implicit reference conversions @@ -165,11 +165,12 @@ The implicit reference conversions are: - From a single-dimensional array type `S[]` to `System.Collections.Generic.IList`, `System.Collections.Generic.IReadOnlyList`, and their base interfaces, provided that there is an implicit identity or reference conversion from `S` to `T`. - From any *array_type* to `System.Array` and the interfaces it implements. - From any *delegate_type* to `System.Delegate` and the interfaces it implements. -- From the null literal ([§6.4.5.7](lexical-structure.md#6457-the-null-literal)) to any reference-type. - 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`. - 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`. - Implicit conversions involving type parameters that are known to be reference types. See [§10.2.12](conversions.md#10212-implicit-conversions-involving-type-parameters) for more details on implicit conversions involving type parameters. +> *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* + 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. Reference conversions, implicit or explicit, never change the referential identity of the object being converted.