dotnet / dotnet/csharplang

[Proposal]: base(T) phase two

Open
#8,871 0 comments 0 reactions 1 assignee Claimed by @MadsTorgersen View on GitHub
Proposal champion
Dominant language
C#
Stars
12.7k
Forks
1.1k
Avg merge
11h 1m
Merged PRs (30d)
3

Description

# base(T) phase two

* Specification: https://github.com/dotnet/csharplang/issues/2910
* Discussion: https://github.com/dotnet/csharplang/discussions/8870

## Summary
[summary]: #summary

We decided that the best design for the `base(I).M` feature would be that we lookup `M` in the interface type `I`, and the result must be accessible. Moreover, there is a requirement that if the found member is abstract, the type `I` must have a unique most specific (concrete) implementation in the type `I`. The compiler would emit IL that identifies the method found, and the type `I`, and the runtime would select the most specific (concrete) implementation in the type `I` and invoke it (or throw an exception if there is no unique most specific implementation at runtime). There is no IL defined today that would serve this purpose, so we would have to design it. (One option would be to generate a "constrained" prefix with the interface type `I`). The IL should not assume or require that the implementing method is accessible to the caller (e.g. it could be private), but it does require that the declared method named in the IL is accessible.

## Design meetings

https://github.com/dotnet/csharplang/blob/main/meetings/2019/LDM-2019-02-27.md
https://github.com/dotnet/csharplang/blob/main/meetings/2019/LDM-2019-04-29.md#default-interface-implementations-and-base-calls

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.