diff --git a/standard/attributes.md b/standard/attributes.md index 89f8822d9..1c0339bcf 100644 --- a/standard/attributes.md +++ b/standard/attributes.md @@ -972,7 +972,7 @@ The captured string is then passed as the argument corresponding to the target p > > *end example* > -> *Example*: An optional target parameter can capture an extension method's receiver by naming the first parameter. Both invocation forms below capture `value`: +> *Example*: An optional target parameter can capture an extension method’s receiver by naming the first parameter. Both invocation forms below capture `value`: > > > ```csharp @@ -1563,7 +1563,7 @@ Constructor binding is performed on `T` using this argument list and the ordinar Append methods are resolved only for components present in the *interpolated_string_handler_expression*: - For each nonempty literal segment, an invocation of `AppendLiteral` is resolved with one value argument of type `string`. -- For each interpolation, an invocation of `AppendFormatted` is resolved. Its first argument is the interpolation's *expression*, passed by value. If an *interpolation_minimum_width* is present, its constant value is supplied as a named argument `alignment`. If a format specifier is present, its text is supplied as a named argument `format`. +- For each interpolation, an invocation of `AppendFormatted` is resolved. Its first argument is the interpolation’s *expression*, passed by value. If an *interpolation_minimum_width* is present, its constant value is supplied as a named argument `alignment`. If a format specifier is present, its text is supplied as a named argument `format`. Member lookup and overload resolution use the ordinary rules for invocation through an instance of `T` ([§12.8.10.2](expressions.md#128102-method-invocations)). Each selected append method shall be an accessible instance method; extension methods are not considered. Optional parameters, generic inference, and argument conversions apply as usual. Every selected append method shall return either `void` or `bool` by value, and all selected append methods shall return the same type. A missing, ambiguous, or otherwise invalid required method is a compile-time error. @@ -1622,7 +1622,7 @@ Handler conversion does not implicitly invoke `ToString` or require a handler to ##### 23.5.11.1.2 Inhibiting a custom handler -If constructor resolution selects a constructor with an `out bool` argument, that argument's value is tested after construction. If it is `true`, component processing begins. If it is `false`, the handler is *inhibited*: no interpolation expression is evaluated and no append method is called. This test is separate from the short-circuiting performed after each bool-returning append call. +If constructor resolution selects a constructor with an `out bool` argument, that argument’s value is tested after construction. If it is `true`, component processing begins. If it is `false`, the handler is *inhibited*: no interpolation expression is evaluated and no append method is called. This test is separate from the short-circuiting performed after each bool-returning append call. ``` csharp public LogInterpolatedStringHandler(int literalLength, int formattedCount, @@ -1672,9 +1672,9 @@ public ref struct LogInterpolatedStringHandler `InterpolatedStringHandlerArgumentAttribute` is applied to the handler parameter. Its arguments specify an ordered list of parameter names to forward to the handler constructor. An empty list forwards nothing. An empty string designates the receiver of the containing invocation. -Each nonempty name shall identify another parameter of the containing member. An unknown name, the handler parameter's own name, or a request for an unavailable receiver, including that of a static method, is a compile-time error. A declaration may produce a warning if a named parameter is declared after the handler parameter; this does not make the declaration invalid. +Each nonempty name shall identify another parameter of the containing member. An unknown name, the handler parameter’s own name, or a request for an unavailable receiver, including that of a static method, is a compile-time error. A declaration may produce a warning if a named parameter is declared after the handler parameter; this does not make the declaration invalid. -At a use of the handler conversion, each forwarded argument shall occur lexically before the *interpolated_string_handler_expression* in the invocation's argument list. A forwarded argument cannot be omitted and supplied by a parameter's default value. These requirements depend on call-site order, not declaration order; named arguments can therefore make a warned declaration usable. A request to forward an indexer receiver when the indexer is an *initializer_target* in a *member_initializer* is a compile-time error. +At a use of the handler conversion, each forwarded argument shall occur lexically before the *interpolated_string_handler_expression* in the invocation’s argument list. A forwarded argument cannot be omitted and supplied by a parameter’s default value. These requirements depend on call-site order, not declaration order; named arguments can therefore make a warned declaration usable. A request to forward an indexer receiver when the indexer is an *initializer_target* in a *member_initializer* is a compile-time error. Constructor overload resolution uses the parameter types of the containing member after substitution of its type arguments, not the original argument expressions. Forwarded arguments retain their parameter-passing modes. At run time, the already evaluated receiver and the already converted argument values or evaluated storage locations are reused by the handler construction and the containing invocation, preserving reference semantics. Additional conversions needed by the constructor are applied to these retained values; the original expressions are not evaluated or bound again. diff --git a/standard/classes.md b/standard/classes.md index 6a35f5a18..347e4bd88 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -5904,7 +5904,7 @@ It is a compile-time error for the parameter list of an async function to specif The *return_type* of an async method shall be either `void`, a ***task type***, or an ***asynchronous iterator type*** ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)). For an async method that produces a result value, a task type or an asynchronous iterator type ([§15.15.3](classes.md#15153-enumerable-interfaces)) shall be generic. For an async method that does not produce a result value, a task type shall not be generic. Such types are referred to in this specification as `«TaskType»` and `«TaskType»`, respectively. The Standard library type `System.Threading.Tasks.Task` and types constructed from `System.Threading.Tasks.Task` and `System.Threading.Tasks.ValueTask` are task types, as well as a class, struct or interface type that is associated with a ***task builder type*** via the attribute `System.Runtime.CompilerServices.AsyncMethodBuilderAttribute`. Such builder types are referred to in this specification as `«TaskBuilderType»` and `«TaskBuilderType»`. A task type can have at most one type parameter and cannot be nested in a generic type. -An async function other than an asynchronous iterator may instead specify a task builder type by applying `AsyncMethodBuilderAttribute` to the function ([§15.14.5](classes.md#15145-task-builder-selection)). Its non-`void` return type shall be a class, struct, or interface type, with at most one type parameter and not nested in a generic type. For checking that function's return type, effective return type, body, and anonymous function conversions, this return type is treated as `«TaskType»` if it is nongeneric, or `«TaskType»` if its single type argument is `T`. This does not make the return type a task type in other contexts or require it to be awaitable. +An async function other than an asynchronous iterator may instead specify a task builder type by applying `AsyncMethodBuilderAttribute` to the function ([§15.14.5](classes.md#15145-task-builder-selection)). Its non-`void` return type shall be a class, struct, or interface type, with at most one type parameter and not nested in a generic type. For checking that function’s return type, effective return type, body, and anonymous function conversions, this return type is treated as `«TaskType»` if it is nongeneric, or `«TaskType»` if its single type argument is `T`. This does not make the return type a task type in other contexts or require it to be awaitable. An async method returning a task type is said to be ***task-returning***. @@ -6014,12 +6014,12 @@ The ability to provide an alternate builder type shall not be used when the synt The builder type of a task-returning async function is determined by: 1. Using the builder type from `AsyncMethodBuilderAttribute`, if one is present; -1. Otherwise, falling back to the builder type determined by the async function's *return_type* ([§15.14.1](classes.md#15141-general)). +1. Otherwise, falling back to the builder type determined by the async function’s *return_type* ([§15.14.1](classes.md#15141-general)). If an `AsyncMethodBuilderAttribute` is present on the function, its argument shall specify a class or struct type, and the builder type is determined as follows: -- If the async function's return type is nongeneric, the specified builder type shall be nongeneric and shall not be nested in a generic type. That type is the builder type. -- Otherwise, the specified builder type shall be an unbound generic type with exactly one type parameter, and shall not be nested in a generic type. The builder type is constructed by substituting the single type argument of the async function's return type for that parameter. +- If the async function’s return type is nongeneric, the specified builder type shall be nongeneric and shall not be nested in a generic type. That type is the builder type. +- Otherwise, the specified builder type shall be an unbound generic type with exactly one type parameter, and shall not be nested in a generic type. The builder type is constructed by substituting the single type argument of the async function’s return type for that parameter. A constructed generic builder type is not permitted as the attribute argument. diff --git a/standard/conversions.md b/standard/conversions.md index 345c7bd8e..d76a61dfc 100644 --- a/standard/conversions.md +++ b/standard/conversions.md @@ -150,7 +150,7 @@ An implicit enumeration conversion permits a *constant_expression* ([§12.26](ex An implicit interpolated string conversion permits an *interpolated_string_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)) to be converted to `System.IFormattable` or `System.FormattableString` (which implements `System.IFormattable`). When this conversion is applied, a string value is not composed from the interpolated string. Instead an instance of `System.FormattableString` is created, as further described in [§12.8.3](expressions.md#1283-interpolated-string-expressions). -For any type `T` that is an applicable interpolated string handler type ([§23.5.11.1.1](attributes.md#2351111-declaring-a-custom-handler)), there exists an implicit interpolated string handler conversion to `T` from an *interpolated_string_handler_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)), including a constant interpolated string. This conversion exists, regardless of whether errors are found later when attempting to lower the interpolation using the handler pattern. This ensures that there are predictable and useful errors, and that runtime behavior doesn't change based on the content of an interpolated string. +For any type `T` that is an applicable interpolated string handler type ([§23.5.11.1.1](attributes.md#2351111-declaring-a-custom-handler)), there exists an implicit interpolated string handler conversion to `T` from an *interpolated_string_handler_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)), including a constant interpolated string. This conversion exists, regardless of whether errors are found later when attempting to lower the interpolation using the handler pattern. This ensures that there are predictable and useful errors, and that runtime behavior doesn’t change based on the content of an interpolated string. ### 10.2.6 Implicit nullable conversions @@ -1054,7 +1054,7 @@ Conversion of an anonymous function to a delegate type produces a delegate insta The invocation list of a delegate produced from an anonymous function contains a single entry. The exact target object and target method of the delegate are unspecified. In particular, it is unspecified whether the target object of the delegate is `null`, the `this` value of the enclosing function member, or some other object. -When a delegate is produced from a lambda expression, attributes explicitly specified on the lambda whose target is the method shall be emitted in metadata on the method referenced by the delegate's `Method` property. Attributes with a `return` target shall be emitted on that method's return parameter, and attributes on lambda parameters shall be emitted on the corresponding method parameters. These requirements do not specify a synthesized method name or the representation of captured variables. +When a delegate is produced from a lambda expression, attributes explicitly specified on the lambda whose target is the method shall be emitted in metadata on the method referenced by the delegate’s `Method` property. Attributes with a `return` target shall be emitted on that method’s return parameter, and attributes on lambda parameters shall be emitted on the corresponding method parameters. These requirements do not specify a synthesized method name or the representation of captured variables. > *Example*: Explicit lambda attributes can be inspected through the resulting delegate: > diff --git a/standard/expressions.md b/standard/expressions.md index fc6f7f8ee..579396776 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -623,7 +623,7 @@ During the run-time processing of a function member invocation ([§12.6.6](expre - For a value argument, if the parameter’s passing mode is value - the argument expression is evaluated and an implicit conversion ([§10.2](conversions.md#102-implicit-conversions)) to the corresponding parameter type is performed. The resulting value becomes the initial value of the value parameter in the function member invocation. - - otherwise, if the parameter's passing mode is reference, it is a struct handler parameter to which an implicit interpolated string handler conversion applies. A temporary of the parameter type is initialized by that conversion and passed by reference. This does not permit an explicit `ref` argument to name an *interpolated_string_handler_expression* instead of a variable reference. + - otherwise, if the parameter’s passing mode is reference, it is a struct handler parameter to which an implicit interpolated string handler conversion applies. A temporary of the parameter type is initialized by that conversion and passed by reference. This does not permit an explicit `ref` argument to name an *interpolated_string_handler_expression* instead of a variable reference. - otherwise, the parameter’s passing mode is input. If the argument is a variable reference and there exists an identity conversion ([§10.2.2](conversions.md#1022-identity-conversion)) between the argument’s type and the parameter’s type, the resulting storage location becomes the storage location represented by the parameter in the function member invocation. Otherwise, a storage location is created with the same type as that of the corresponding parameter. The argument expression is evaluated and an implicit conversion ([§10.2](conversions.md#102-implicit-conversions)) to the corresponding parameter type is performed. The resulting value is stored within that storage location. That storage location is represented by the input parameter in the function member invocation. > *Example*: Given the following declarations and method calls: @@ -1805,7 +1805,7 @@ The *simple_name* is evaluated and classified as follows: - Otherwise, form a set of distinct candidates imported by the *using_namespace_directive*s, *using_static_directive*s, *global_using_namespace_directive*s, and *global_using_static_directive*s in *D*. Include accessible types having name `I` and `e` type parameters, accessible non-extension static methods having name `I` (and, if a type argument list is specified, `e` type parameters), and, if `e` is zero, accessible non-method static members having name `I`. For a static import, only members declared directly in the imported type are included. - If the set contains exactly one type and no other members, the *simple_name* refers to that type constructed with the given type arguments. - If the set contains only methods and is nonempty, the result is a method group with no associated instance expression. Any specified type argument list is used in calling a generic method ([§12.8.10.2](expressions.md#128102-method-invocations)); overload resolution considers the methods in the group. - - If the set contains exactly one member, which is neither a type nor a method, the result is the same as a member access ([§12.8.7](expressions.md#1287-member-access)) of the form `T.I`, where `T` is the member's declaring type. + - If the set contains exactly one member, which is neither a type nor a method, the result is the same as a member access ([§12.8.7](expressions.md#1287-member-access)) of the form `T.I`, where `T` is the member’s declaring type. - Otherwise, if the set is nonempty, the *simple_name* is ambiguous and a compile-time error occurs. > *Note*: The namespace, type, and alias lookup steps parallel those for a *namespace_or_type_name* ([§7.7](basic-concepts.md#77-namespace-and-type-names)). Simple-name lookup additionally considers imported static members. Extension methods are considered separately for extension method invocation ([§12.8.10.3](expressions.md#128103-extension-method-invocations)). *end note* - Otherwise, if `e` is zero and `I` is the identifier `_`, the *simple_name* is a *simple discard*, which is a form of declaration expression ([§12.20](expressions.md#1220-declaration-expressions)). @@ -2820,7 +2820,7 @@ The binding-time processing of an *object_creation_expression* of the form `new - Otherwise, the *object_creation_expression* is a default constructor invocation. The result of the *object_creation_expression* is a value of type `T`, namely the default value for `T` as defined in [§8.3.3](types.md#833-default-constructors). - Otherwise, if `T` is a *type_parameter* and `A` is not present: - If no value type constraint or constructor constraint ([§15.2.5](classes.md#1525-type-parameter-constraints)) has been specified for `T`, a binding-time error occurs. - - The result of the *object_creation_expression* is a value of the run-time type that the type parameter has been bound to, produced by invoking that type's public parameterless instance constructor. For a value type with an explicitly declared parameterless instance constructor, that constructor is invoked; otherwise, the value type's default value is produced. The run-time type may be a reference type or a value type. + - The result of the *object_creation_expression* is a value of the run-time type that the type parameter has been bound to, produced by invoking that type’s public parameterless instance constructor. For a value type with an explicitly declared parameterless instance constructor, that constructor is invoked; otherwise, the value type’s default value is produced. The run-time type may be a reference type or a value type. - Otherwise, if `T` is a *class_type* or a *struct_type*: - If `T` is an abstract or static *class_type*, a compile-time error occurs. - The instance constructor to invoke is determined using the overload resolution rules of [§12.6.4](expressions.md#1264-overload-resolution). The set of candidate instance constructors consists of all accessible instance constructors declared in `T`, which are applicable with respect to `A` ([§12.6.4.2](expressions.md#12642-applicable-function-member)). If the set of candidate instance constructors is empty, or if a single best instance constructor cannot be identified, a binding-time error occurs. @@ -4143,16 +4143,16 @@ The receiver is the *switch_expression* preceding `with`. Its compile-time type - An anonymous type ([§12.8.17.3](expressions.md#128173-anonymous-object-creation-expressions)). - A value type other than `void`, or a type parameter constrained to be a value type. -Each *identifier* in the *member_initializer_list* shall name an accessible instance field or property of the receiver's type. A member shall not be initialized more than once. +Each *identifier* in the *member_initializer_list* shall name an accessible instance field or property of the receiver’s type. A member shall not be initialized more than once. -For a receiver other than an anonymous type, each member initializer is subject to the same rules as an assignment to the corresponding member of a variable of the receiver's type. A property assignment requires an accessible `set` or `init` accessor, but does not require a `get` accessor. An `init` accessor is permitted in this context ([§15.7.3](classes.md#1573-accessors)); the usual accessibility and readonly-field restrictions apply. +For a receiver other than an anonymous type, each member initializer is subject to the same rules as an assignment to the corresponding member of a variable of the receiver’s type. A property assignment requires an accessible `set` or `init` accessor, but does not require a `get` accessor. An `init` accessor is permitted in this context ([§15.7.3](classes.md#1573-accessors)); the usual accessibility and readonly-field restrictions apply. For an anonymous-type receiver, each initializer shall specify an expression implicitly convertible to the type of the named property. The absence of a setter on that property does not prevent its initialization by a *with_expression*. The type of the result is the compile-time type of the receiver. At run time, the receiver is evaluated once, before any member initializer expressions. Subsequent evaluation depends on its compile-time type: -- For a record class type, or a type parameter whose effective base class is a record class type, the receiver's clone method ([§15.16.6.4](classes.md#151664-copy-and-clone-members)) is invoked, and its result is converted to the receiver's type. Each *member_initializer* is then processed as an assignment to a field or property of that result, in lexical order. -- For a value type, or a type parameter constrained to be a value type, the receiver's value is copied. Each *member_initializer* is then processed as an assignment to a field or property of that copy, in lexical order. No record-class clone method is invoked. +- For a record class type, or a type parameter whose effective base class is a record class type, the receiver’s clone method ([§15.16.6.4](classes.md#151664-copy-and-clone-members)) is invoked, and its result is converted to the receiver’s type. Each *member_initializer* is then processed as an assignment to a field or property of that result, in lexical order. +- For a value type, or a type parameter constrained to be a value type, the receiver’s value is copied. Each *member_initializer* is then processed as an assignment to a field or property of that copy, in lexical order. No record-class clone method is invoked. - For an anonymous type, the member initializer expressions are evaluated in lexical order and their converted values are retained. A new instance of the same anonymous type is constructed with those values for the named properties and the values from the evaluated receiver for every remaining property. Its read-only properties are initialized by construction, not by subsequent assignments. If *member_initializer_list* is omitted, no member assignments or replacements are performed after the applicable copying operation. diff --git a/standard/lexical-structure.md b/standard/lexical-structure.md index cf548fd76..faa48ea8d 100644 --- a/standard/lexical-structure.md +++ b/standard/lexical-structure.md @@ -1746,7 +1746,7 @@ For mapping a source span whose start is in the scope of an enhanced directive, All line and column numbers in the following rules are 1-based. Source spans and mapped spans use an inclusive start position and an exclusive end position. Column numbers and the offset are measured in UTF-16 code units. -If a source span starts on line *F* at a column less than or equal to *O*, the entire source span maps to the span from (*startLine*, *startColumn*) to (*endLine*, *endColumn* + 1), regardless of the source span's end position. +If a source span starts on line *F* at a column less than or equal to *O*, the entire source span maps to the span from (*startLine*, *startColumn*) to (*endLine*, *endColumn* + 1), regardless of the source span’s end position. Otherwise, the start and end positions of the source span are each mapped as follows. A position (*l*, *c*) maps to: