diff --git a/meetings/2025/README.md b/meetings/2025/README.md index 5d1ebbc049..2b603655ab 100644 --- a/meetings/2025/README.md +++ b/meetings/2025/README.md @@ -8,6 +8,7 @@ All schedule items must have a public issue or checked-in proposal that can be l ## Schedule when convenient - [Readonly setter calls on non-variables](https://github.com/dotnet/csharplang/blob/main/proposals/readonly-setter-calls-on-non-variables.md) jnm2 +- [Target-typed static member lookup](https://github.com/dotnet/csharplang/blob/main/proposals/target-typed-static-member-lookup.md) jnm2, CyrusNajmabadi - Triage (working set) ## Recurring topics diff --git a/proposals/target-typed-static-member-lookup.md b/proposals/target-typed-static-member-lookup.md index 4f8ccb9b40..6434077196 100644 --- a/proposals/target-typed-static-member-lookup.md +++ b/proposals/target-typed-static-member-lookup.md @@ -2,6 +2,8 @@ Champion issue: +Thanks to those who provided insight and input into this proposal, especially @CyrusNajmabadi! + ## Summary This feature enables a type name to be omitted from static member access when it is the same as the target type. @@ -170,7 +172,7 @@ void M(string p) => ... ### Target-typing with invocations -A core scenario for this proposal is calling factory methods, providing symmetry between production and consumption of values. +A core scenario for this proposal is calling factory methods. This enables the use of the feature with some of today's class and struct types. This also provides symmetry between production and consumption of values at a future point when there is a facility for `is .Some(42)` to light up without a type hierarchy, which is a future potential with discriminated unions. ```cs SomeResult = .Error("Message"); @@ -183,6 +185,27 @@ For an invocation expression such as `e(...)` where the invoked expression `e` i Even though the conversion always succeeds when the invoked expression `e` is a _target-typed member binding expression_, further errors may occur if the invocation expression cannot be bound for any of the same reasons as though the _target-typed member binding expression_ was a non-target-typed expression, qualified as a member of `T`. For instance, the member might not be invocable, or might return a type other than `T`. +### Target-typing after the `new` keyword + +A core scenario for this proposal is enable the `new` operator to look up nested derived types. This provides symmetry between production and consumption of values with class DUs and with today's type hierarchies based on nested derived classes or records. + +```cs +new .Case1(arg1, arg2) +``` + +This balances the consumption syntax: + +```cs +du switch +{ + .Case1(var arg1, var arg2) => ... +} +``` + +This would continue to be target-typed static member access (since nested types are members of their containing type), which is distinct from target-typed `new` since a definite type is provided to the `new` operator. + +TODO: spec the conversion + ### Notes As with target-typed `new`, targeting a nullable value type should access members on the inner value type: @@ -282,27 +305,6 @@ with (expr) This doesn't seem to be a popular request among the language team members who have commented on it. If we go ahead with the proposed target-typing for `.Name` syntax, this seals the fate of the requested `with` statement syntax shown here. -## Expansions - -To match the production and consumption sides even better, it could be very desirable to enable the `new` operator to look up nested derived types in the same way: - -```cs -new .Case1(arg1, arg2) -``` - -This would continue to be target-typed static member access (since nested types are members of their containing type), which is distinct from target-typed `new` since a definite type is provided to the `new` operator. - -If target-typed static member access is not allowed in this location, the downside is that the production and consumption syntaxes will not have parity. - -```cs -du switch -{ - .Case1(var arg1, var arg2) => ... -} -``` - -In cases where the union name is long, perhaps `SomeDiscriminatedUnion>`, this will really stand out. - ## Alternatives ### Alternative: doing nothing