You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In conversions, restore the IFormattable/FormattableString conversion about the new handler paragraph. Both are valie.
In expression, update Better conversion bullets to prefer the handler-preference rules, then the existing rules under a "does not exactly match" bullet.
Fix typo in 12.83.
Add a bullet in 12.83 to target the IFormattable/Formattable string conversion around the handler.
Foranytype `T` thatisanapplicableinterpolatedstringhandlertype (§custInterpStrExpCustHandling), thereexistsanimplicitinterpolatedstringhandlerconversionto `T` fromanon-constant*ISE* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)). Thisconversionexists, regardlessofwhethererrorsarefoundlaterwhenattemptingtolowertheinterpolationusing the handler pattern. This ensures that there are predictable and usefulerrors, andthatruntimebehaviordoesn'tchangebasedonthecontentofaninterpolatedstring.
Copy file name to clipboardExpand all lines: standard/expressions.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1150,14 +1150,16 @@ Given `int i = 10;`, according to [§12.6.4.2](expressions.md#12642-applicable-f
1150
1150
1151
1151
#### 12.6.4.5 Better conversion from expression
1152
1152
1153
-
Given an implicit conversion `C₁` that converts from an expression `E` to a type `T₁`, and an implicit conversion `C₂` that converts from an expression `E` to a type `T₂`, `C₁` is a ***better conversion*** than `C₂` if `E` does not exactly match `T₂` and at least one of the following holds:
1153
+
Given an implicit conversion `C₁` that converts from an expression `E` to a type `T₁`, and an implicit conversion `C₂` that converts from an expression `E` to a type `T₂`, `C₁` is a ***better conversion*** than `C₂` if one of the following holds:
1154
1154
1155
-
- `E` exactly matches `T₁` and `E` does not exactly match `T₂` ([§12.6.4.6](expressions.md#12646-exactly-matching-expression))
- `E` isamethodgroup ([§12.2](expressions.md#122-expression-classifications)), `T₁` iscompatible ([§21.4](delegates.md#214-delegate-compatibility)) withthesinglebestmethodfromthemethodgroupfor conversion `C₁`, and `T₂` is not compatible with the single best method from the method group for conversion `C₂`
1155
+
- `E` is a non-constant *interpolated_string_expression*, `C₁` is an implicit interpolated string handler conversion, `T₁` is an applicable interpolated string handler type, and `C₂` is not an implicit interpolated string handler conversion.
1156
+
- `E` does not exactly match `T₂` and at least one of the following holds:
1157
+
- `E` exactly matches `T₁` and `E` does not exactly match `T₂` ([§12.6.4.6](expressions.md#12646-exactly-matching-expression))
- `E` isamethodgroup ([§12.2](expressions.md#122-expression-classifications)), `T₁` iscompatible ([§21.4](delegates.md#214-delegate-compatibility)) withthesinglebestmethodfromthemethodgroupfor conversion `C₁`, and `T₂` is not compatible with the single best method from the method group for conversion `C₂`
1161
1163
1162
1164
#### 12.6.4.6 Exactly matching expression
1163
1165
@@ -1509,6 +1511,7 @@ but this is an implementation detail and therefore not part of this specificatio
1509
1511
An *interpolated_string_expression* is classified as a value, which is evaluated in one of the following ways depending on the context in which it appears:
1510
1512
1511
1513
1. If the target of an assignment or method-call argument has type `string`, the expression is processed by the default interpolated string handler, `System.Runtime.CompilerServices.DefaultInterpolatedStringHandler`, and the result has type `string`.
1514
+
1. If the target of an assignment or method-call argument has type `System.IFormattable` or `System.FormattableString`, a string value is not composed from the interpolated string. Instead an instance of `System.FormattableString` is created.
1512
1515
1. If the target of an assignment or method-call argument has a custom interpolated string handler (§custInterpStrExpHandler) type, then
1513
1516
1514
1517
- If the interpolated string contains no interpolations, the expression is processed as if the target type was `string`.
The remainder of this subclause deals with the default interpolated string handler behavior only. The declaration and use of custom interpolated string handlers is described in §custInterpStrExpHandler.
0 commit comments