# C# Language Design Meeting for December 11th, 2023

## Agenda

- [Extensions](#extensions)

## Quote(s) of the Day

- "Welcome to the last regular LDM of the year." "You missed the chance to do last explicit meeting." *Sigh* "No, **you** could have done that" "I wanted you to pick it up implicitly."
  "If you keep making bad jokes we may have to extend the meeting."

## Discussion

### Extensions

https://github.com/dotnet/csharplang/issues/5497
https://github.com/dotnet/csharplang/issues/7771  

Now that we're entering the next cycle of C# design, we're bringing back issues that have been on the backburner while we focused on C# 12. First on the docket is extensions; we started
LDM with a quick recap on the general proposal, then dove straight into looking at the progress on lowering that has been made in the past few months. This design has evolved a great deal
since we initially looked at it, and has undergone multiple iterations as we discuss with runtime architects on what is feasible and what is not. Rather than restating the lowering document,
these notes will just point out some comments that we had while going over it.

* We're unsure about the Punnett Square of extension inheritance, in particular whether implicit->implicit inheritance is actually necessary. The only question is whether we'll need that
  for multiple implicit interface implementation; if there are multiple implicit extensions that implement different interfaces on a type, and then that type is used in a locaton that
  constrains to both of those interfaces, will we need to synthesize a new implicit extension that inherits from each original extension to combine them? Will the user need to manually
  introduce that extension?
* We continue to have no good ideas on how to solve nested generics in the general case that can also handle extensions that add interfaces. The representation we've chosen currently
  is representation-preserving at the top level, but `List<U>` cannot be easily converted to `List<E>` without an allocation somewhere.
    * We could consider erasure here, but that will only postpone the problem, as extensions can add interfaces (eventually).
* Interface member lookup through extensions will be tricky. If the runtime definition of an interface adds a member, and the underlying type has a method that would normally be automatically
  hooked up to that member at runtime, what will do that for an extension implementation and its underlying type?
    * May need some runtime help for this one.

Ultimately, there are no conclusions today. We'll keep iterating on these questions and bring lowering back to LDM for continued discussion in future sessions.
