Skip to content

Commit aafe291

Browse files
Nigel-Ecmajskeet
authored andcommitted
Apply suggestions from code review
1 parent e0096db commit aafe291

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

standard/classes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,9 @@ A compile-time error occurs unless all of the following are true for an override
27482748
- The overridden base method is not a sealed method.
27492749
- There is an identity conversion between the return type of the overridden base method and the override method.
27502750
- The override declaration and the overridden base method have the same declared accessibility. In other words, an override declaration cannot change the accessibility of the virtual method. However, if the overridden base method is protected internal and it is declared in a different assembly than the assembly containing the override declaration then the override declaration’s declared accessibility shall be protected.
2751-
- If any *type_parameter_constraints_clause*s are present, each of their *type_parameter_constraints* shall be `class` or `struct`, and for the constraint `class` in the override shall correspond to a type parameter in the base method that is known to be a non-nullable reference type. Any type parameter that has the `struct` constraint in the override shall correspond to a type parameter in the base method that is known to be a non-nullable value type. In the absence of *type_parameter_constraints_clause*s, the constraints are inherited from the overridden base method, and for the constraint `struct` a parameter type `T?` is interpreted as `System.Nullable<T>`. Constraints that are type parameters in the overridden method may be replaced by type arguments in the inherited constraint. This can lead to constraints that are not valid when explicitly specified, such as value types or sealed types.
2751+
- A *type_parameter_constraints_clause* may only consist of the `class` or `struct` *primary_constraint*s applied to *type_parameter*s which are known according to the inherited constraints to be either reference or value types respectively. Any type of the form `T?` in the overriding method’s signature, where `T` is a type parameter, is interpreted as follows:
2752+
- If a `class` constraint is added for type parameter `T` then `T?` is a nullable reference type; otherwise
2753+
- If either there is no added constraint, or a `struct` is added, for the type parameter `T` then `T?` is a nullable value type.
27522754
27532755
> *Example*: The following demonstrates how the overriding rules work for generic classes:
27542756
>

standard/interfaces.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,11 @@ It is not possible to access an explicit interface member implementation through
659659
660660
It is a compile-time error for an explicit interface member implementation to include any modifiers ([§15.6](classes.md#156-methods)) other than `extern` or `async`.
661661
662-
If *type_parameter_constraints_clause*s are present in an explicit interface method implementation, each of their *type_parameter_constraints* shall be `class` or `struct`, and for the constraint `class` in the implementation shall correspond to a type parameter in the interface method that is known to be a non-nullable reference type. Any type parameter that has the `struct` constraint in the implementation shall correspond to a type parameter in the interface method that is known to be a non-nullable value type. In the absence of *type_parameter_constraints_clause*s, the constraints for an explicit interface method implementation are inherited from the interface method, and for the constraint `struct` a parameter type `T?` is interpreted as `System.Nullable<T>`.
662+
An explicit interface method implementation inherits any type parameter constraints from the interface.
663+
664+
A *type_parameter_constraints_clause* on an explicit interface method implementation may only consist of the `class` or `struct` *primary_constraint*s applied to *type_parameter*s which are known according to the inherited constraints to be either reference or value types respectively. Any type of the form `T?` in the signature of the explicit interface method implementation, where `T` is a type parameter, is interpreted as follows:
665+
- If a `class` constraint is added for type parameter `T` then `T?` is a nullable reference type; otherwise
666+
- If either there is no added constraint, or a `struct` is added, for the type parameter `T` then `T?` is a nullable value type.
663667
664668
> *Example*: The following demonstrates how the rules work when type parameters are involved:
665669
>

0 commit comments

Comments
 (0)