simo
simo

Reputation: 24560

Why does super class overriden method called?

I am overriding a method ini in a super class, but strangely the ini method in super class is still called although I am not calling it using super

Any idea? is this a problem in haxe 3? p.s: its an OpenFL project, targeting flash ..

class superClass{
 function ini():Void 
 {
   // this line should not be reached, but, it is reached .. !
 }
}

class subClass extends superClass{
 override function ini():Void 
 {
   // I Am not calling super ini here ..
 }
}

EDIT

Here is an abstract of my code, where you can see my classes set:

class EComponent extends Sprite
{

}

class Component extends EComponent
{

    public function new(aBoard:Board) 
    {
        ini();
    }
    function ini():Void 
    {
    // I am checking this manually, 
    // because ini is called even though its BeziereWire instance!
        if (Std.is(this, BeziereWire))
        return;
    }

    function iniRotators():Void 
    {

    }
}

class BeziereWire extends Component
{
    override function ini():Void 
    {
        iniRotators();      
    }
}

Upvotes: 0

Views: 348

Answers (1)

Sergey Miryanov
Sergey Miryanov

Reputation: 1830

Hmm, something wrong with your real code. I make a test project and all works fine. This is a test Main.hx - https://gist.github.com/sergey-miryanov/6658172

And this is a screenshot: And this is a screenshot

Upvotes: 3

Related Questions