Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-34993

implicit super() constructor call receives subclass constructor params

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Apache FlexJS 0.5.0
    • Apache FalconJX 0.6.0
    • Falcon, FlexJS
    • None

    Description

      AS input (2 files):

      package foo.bar {
      	public class MySuperClass {
      		public function MySuperClass(superParam1:String = "Hello", superParam2:String = "World")
      		{
      			this.superString = superParam1 + superParam2;
      		}
      		public var superString:String;
      	}
      }
      
      package foo.bar {
      	public class MyExtendingClass extends MySuperClass {
      		public function MyExtendingClass(extendingParam:String)
      		{
      			this.myExtendingString = extendingParam;
      		}
      		public var myExtendingString:String;
      	}
      }
      

      JS output (relevant part only):

      /**
       * @constructor
       * @extends {foo.bar.MySuperClass}
       * @param {string} extendingParam
       */
      foo.bar.MyExtendingClass = function(extendingParam) {
        foo.bar.MyExtendingClass.base(this, 'constructor', extendingParam);
        this.myExtendingString = extendingParam;
      };
      goog.inherits(foo.bar.MyExtendingClass, foo.bar.MySuperClass);
      

      The correct behavior would be to implicitly call the default constructor (no params):

        foo.bar.MyExtendingClass.base(this, 'constructor');
      

      The current workaround is to explicitly call super() with no params in the subclass.

      Attachments

        Activity

          People

            aharui Alex Harui
            adufilie Andy Dufilie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: