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

Problem with setter/getter in .as file with multiple classes

    XMLWordPrintableJSON

Details

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

    Description

      Internal classes local to another class (defined outside the package definition) get cross-compiled incorrectly when there are setter/getters in the main class. Notice in the example below that the PublicClass setter/getter are included in the InternalClass prototype at the bottom.

      AS input:

      package foo.bar {
      	public class PublicClass {
      		public function get publicVar():String {
      			return _publicVar;
      		}
      		public function set publicVar(value:String):void {
      			_publicVar = value;
      		}
      		
      		private var _publicVar:String = "from public class";
      	}
      }
      
      internal class InternalClass {
      	public function get internalVar():String {
      		return _internalVar;
      	}
      	public function set internalVar(value:String):void {
      		_internalVar = value;
      	}
      	
      	private var _internalVar:String = "from internal class";
      }
      

      Incorrect JS output:

      /**
       * Generated by Apache Flex Cross-Compiler from foo\bar\PublicClass.as
       * foo.bar.PublicClass
       *
       * @fileoverview
       *
       * @suppress {checkTypes}
       */
      
      goog.provide('foo.bar.PublicClass');
      
      
      
      /**
       * @constructor
       */
      foo.bar.PublicClass = function() {
      };
      
      
      /**
       * @private
       * @type {string}
       */
      foo.bar.PublicClass.prototype._publicVar = "from public class";
      
      
      Object.defineProperties(foo.bar.PublicClass.prototype, /** @lends {foo.bar.PublicClass.prototype} */ {
      /** @export */
      publicVar: {
      get: /** @this {foo.bar.PublicClass} */ function() {
        return this._publicVar;
      },
      set: /** @this {foo.bar.PublicClass} */ function(value) {
        this._publicVar = value;
      }}}
      );
      
      
      /**
       * Metadata
       *
       * @type {Object.<string, Array.<Object>>}
       */
      foo.bar.PublicClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'PublicClass', qName: 'foo.bar.PublicClass'}] };
      
      
      
      /**
       * @constructor
       */
      InternalClass = function() {
      };
      
      
      /**
       * @private
       * @type {string}
       */
      InternalClass.prototype._internalVar = "from internal class";
      
      
      Object.defineProperties(InternalClass.prototype, /** @lends {InternalClass.prototype} */ {
      /** @export */
      publicVar: {
      get: /** @this {InternalClass} */ function() {
        return this._publicVar;
      },
      set: /** @this {InternalClass} */ function(value) {
        this._publicVar = value;
      }},
      /** @export */
      internalVar: {
      get: /** @this {InternalClass} */ function() {
        return this._internalVar;
      },
      set: /** @this {InternalClass} */ function(value) {
        this._internalVar = value;
      }}}
      );
      

      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: