Open williamb1024 opened 4 years ago
Tagging @gafter who worked on private protected
The same is true for protected
:
public class X : X.XII
{
protected interface XII
{
}
}
public class XX : X, X.XII // X.XII is inaccessible due to its protection level
{
public void Test()
{
XII z = this;
}
}
This is due to the fact that the compiler temporarily assumes, when binding the base clause, that the base class is object
. The specification says that "While determining the meaning of the direct base class specification A of a class B, the direct base class of B is temporarily assumed to be object." But the base clause does not have a distinguished direct base class specification in the syntax, so the specification does not make sense as written. It is taken in the compiler to apply to the whole base clause.
This is a known open issue in the ECMA specification, which the committee has punted from addressing in the C# 5 specification.
Moving to csharpstandard for the ECMA committee.
Version Used: Visual Studio 16.5.4
Expected Behavior:
The class type
XX
would be able to implement theX.XII
interface.Actual Behavior:
The error "CS0122: 'X.XII' is inaccessible due to its protection level" is generated.