Skip to content

Constructors are not inherited #532

@dense13

Description

@dense13

I was testing overwriting constructors (and using super), which works. But then found out that constructors don't seem to be inherited, if not defined in subclasses. Note that this works fine with instance methods.

class A {
    fun @construct(string name) {
        <<< "A with", name>>>;
    }
}

class B extends A {
    fun @construct(string name) {
        super.A("called from B - " + name);
        <<< "B with", name>>>;
    }    
}

class C extends B {
}

new A("Test1") @=> A a;
new B("Test2") @=> B b;

new C("Test3") @=> C c; // FAILS
// error: no constructors defined for 'C'

Chuck 1.5.5.6
OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions