call to private super-constructor should not be allowed

Slavisa konfusious at gmx.de
Mon Sep 24 04:41:12 PDT 2007


Recently I realized that a inheriting class is able to call the
super-constructor of its super-class even if it is declared private.
My expectation was that the compiler would force me to call a explicit
super-constructor which is not declared private. Well, it didn't. It compiles
and even linking is no problem.

For illustration of the described problem consider the following example. The
different classes are located in different files.

------------------
module abstractClass;

abstract class AbstractClass
{
    private this()
    {
    }
}
---------------------
import abstractClass;

class InheritingClass : AbstractClass
{
    public this()
    {
        super();
    }
}
-------------------

Compiler used: Digital Mars D Compiler v1.015 and GDC 0.22 (both affected)
System: Linux x86


More information about the Digitalmars-d-bugs mailing list