dotnet / dotnet/csharpstandard

15.2.4.2 Base classes (directly depends on)

Open
#156 3 comments 0 reactions 0 assignees View on GitHub
type: clarity
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

15.2.4.2 says

> It is a compile-time error for a class to depend on itself. For the purpose of this rule, a class directly depends on its direct base class (if any) and directly depends on the nearest enclosing class within which it is nested (if any). Given this definition, the complete set of classes upon which a class depends is the transitive closure of the directly depends on relationship.

However, it isn't clear how this affects generics. Does `A` below *depend* on itself?

``` c#
class G { }
class A : A> { }
```

A similar question applies to interfaces in 18.2.4 Base interfaces

``` c#
interface G { }
interface A : A> { }
```

Does the interface `A` "directly or indirectly inherit from itself"?

Whatever the meaning of the existing text, these programs should be forbidden.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.