Given this code:

abstract class A
{
    package @property void x(int x);
    package @property int x();
}

class B : A
{
    package @property override void x(int x) {}
    package @property override int x() { return 0; }
}

void main() {}

I get the following message:

onlineapp.d(9): Error: function `onlineapp.B.x` package method is not virtual and cannot override onlineapp.d(10): Error: function `onlineapp.B.x` package method is not virtual and cannot override

Why is that? If the access specifier is private, I can perfectly understand it - subclasses can't call the private method of parent class, so there's no need in making it virtual. For protected/public the code compiles. However, for the package protection it may happen that a subclass is in the same package (and just happened to me).

Should I file a bug or is there a reason for such behavior?

Reply via email to