meetings/working-groups/roles/extensions-wg-2024-03-05.md
Just like extension methods on a base type are eligible when given an instance of the derived type,
extension members on the underlying type should be eligible when given an extension type or value.
The extension member lookup rule was updated to look at the underlying type when given an extension type.
var x = E1.Member;
System.Console.Write(x);
class C { }
extension E1 for C { }
implicit extension E2 for C
{
public static string Member = "ran";
}
Decision: that seems fine.
Note: like other extension lookups, that would not apply on Simple Names. For example:
class C { }
extension E1 for C
{
void M()
{
var x = Member; // error
string s = Member; // error
}
}
implicit extension E2 for C
{
public static string Member = "";
}
LDM decided that we should merge extension methods and extension members within the same scope. But how should we deal with ambiguities, either of the same kind or of different kinds?
Decision: let's be strict on merging different kinds of members (produce ambiguity).
Proposal: Consider doing a breaking change or warning wave warning (would be error for extension case)?
We discussed two ways of doing this:
Decision: we'll pursue proposal 2.
System.Console.WriteLine(I4.F);
interface I1
{
static int F = 1;
}
interface I2 : I1
{
static int F = 2;
}
interface I3 : I1 {}
interface I4 : I3, I2 {}
We did not cover this yet.
var x = C.Member; // error: member lookup finds C.Member (method group) and lacks type arguments to apply to that match
class C
{
public static void Member<T>() { }
}
implicit extension E for C
{
public static int Member = 42;
}