September 24, 2007 call to private super-constructor should not be allowed | ||||
---|---|---|---|---|
| ||||
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 |
Copyright © 1999-2021 by the D Language Foundation