Announcement

Collapse
No announcement yet.

[CLOSED] [#566] [1.10] "this" reference incorrect in abstract base ctor when derived class has no ctor

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] [#566] [1.10] "this" reference incorrect in abstract base ctor when derived class has no ctor

    If I have an abstract base class with an argument-less constructor and with an abstract method then the "this" reference in the base class constructor is not correct and can not access the implementation of the abstract method.

    This is hard to explain with words! The example is simple, though :)

    public class Start
    {
        [Ready]
        public static void Main()
        {
            new D1();
        }
    }
    
    public class D1 : B1
    {
        protected override string GetName() { return "Ted"; }
     }
    
    public abstract class B1
    {
        protected B1()
        {
            Console.WriteLine(GetName());
        }
    
        protected abstract string GetName();
    }
    This should print the string "Ted" to the console - but, instead, I get an error:

    Uncaught TypeError: this.getName is not a function
    If I add a constructor to D1 that passes straight through to B1 then it works - eg.

    public class D1 : B1
    {
        public D1() : base() { }
    }
    But this should be unnecessary since this is not required in regular C# (and it's a nasty error as it doesn't cause any compile / translation warnings, it just fails at runtime).

    #2
    Nice find. We will investigate and fix.

    Comment


      #3
      Created an Issue to track this defect:

      https://github.com/bridgedotnet/Bridge/issues/566

      Comment


        #4
        The following Live Bridge sample demonstrates how to reproduce the defect:

        http://live.bridge.net/#b19b735ab324f639ca5d

        Comment


          #5
          Hi ProductiveRage! We cannot reproduce the issue against the latest release1.10 branch.
          We added a test to make sure this issue will not appear again.

          Comment


            #6
            Perfect! Can't wait for 1.10 to go live! :D

            Comment

            Working...
            X