{"action":"opened","issue":{"url":"https://api.github.com/repos/google/closure-compiler/issues/964","labels_url":"https://api.github.com/repos/google/closure-compiler/issues/964/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/964/comments","events_url":"https://api.github.com/repos/google/closure-compiler/issues/964/events","html_url":"https://github.com/google/closure-compiler/issues/964","id":79717342,"number":964,"title":"bizarre NTI warning \"Cannot access property foo_ of non-object type bottom\"","user":{"login":"myphysicslab","id":4060786,"avatar_url":"https://avatars.githubusercontent.com/u/4060786?v=3","gravatar_id":"","url":"https://api.github.com/users/myphysicslab","html_url":"https://github.com/myphysicslab","followers_url":"https://api.github.com/users/myphysicslab/followers","following_url":"https://api.github.com/users/myphysicslab/following{/other_user}","gists_url":"https://api.github.com/users/myphysicslab/gists{/gist_id}","starred_url":"https://api.github.com/users/myphysicslab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myphysicslab/subscriptions","organizations_url":"https://api.github.com/users/myphysicslab/orgs","repos_url":"https://api.github.com/users/myphysicslab/repos","events_url":"https://api.github.com/users/myphysicslab/events{/privacy}","received_events_url":"https://api.github.com/users/myphysicslab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-23T04:06:43Z","updated_at":"2015-05-23T04:06:43Z","closed_at":null,"body":"Compiling with new type inference (NTI) get a strange warning which does not make sense:\r\n```\r\nsrc/lab/view/DisplayPath.js:264: WARNING - Cannot access property myImage_ of non-object\r\ntype bottom.\r\n  if (this.redraw_ && this.myImage_ != null) {\r\n                      ^\r\n```\r\nThe `this` is the `DisplayPath` class, and there is nothing named `bottom` here that I'm aware of.  Here is the code for the constructor and the method in question.  The warning happens about 2/3 thru the `draw` method.\r\n\r\n\r\n```javascript\r\n/**\r\n* @constructor\r\n* @struct\r\n* @implements {myphysicslab.lab.view.DisplayObject}\r\n*/\r\nmyphysicslab.lab.view.DisplayPath = function() {\r\n  /**\r\n  * @type {?HTMLCanvasElement}\r\n  * @private\r\n  */\r\n  this.myImage_ = null;\r\n  /**\r\n  * @type {!Array.<!myphysicslab.lab.model.PhysicsPath>}\r\n  * @private\r\n  */\r\n  this.paths_ = new Array(0);\r\n  /**  tells when need to redraw the bitmap from the paths\r\n  * @type {boolean}\r\n  * @private\r\n  */\r\n  this.redraw_ = true;\r\n  /**\r\n  * @type {!myphysicslab.lab.view.ScreenRect}\r\n  * @private\r\n  */\r\n  this.screenRect_ = ScreenRect.EMPTY_RECT;\r\n  /** to detect when redraw needed;  when the coordmap changes, we need to redraw.\r\n  * @type {?myphysicslab.lab.view.CoordMap}\r\n  * @private\r\n  */\r\n  this.lastMap_ = null;\r\n  /**\r\n  * @type {boolean}\r\n  * @private\r\n  */\r\n  this.debug_ = false;\r\n  /**\r\n  * @type {boolean}\r\n  * @private\r\n  */\r\n  this.dragable_ = false;\r\n  /**  a CSS3 color value\r\n  * @type {string}\r\n  * @private\r\n  */\r\n  this.color_ = DisplayPath.color;\r\n  /**  line thickness in pixels\r\n  * @type {number}\r\n  * @private\r\n  */\r\n  this.thickness_ = DisplayPath.thickness;\r\n};\r\n\r\n/** @inheritDoc */\r\nDisplayPath.prototype.draw = function(context, map) {\r\n  var r = this.screenRect_;\r\n  if (r.isEmpty()) {\r\n    // don't bother if the screen isn't visible yet\r\n    return;\r\n  }\r\n  goog.asserts.assert( r.getX() == 0);\r\n  goog.asserts.assert( r.getY() == 0);\r\n  context.save();\r\n  if (this.lastMap_ == null || this.lastMap_ != map) {\r\n    this.lastMap_ = map;\r\n    if (goog.DEBUG && this.debug_)\r\n      window.console.log(\"DisplayPath: redraw because coordmap changed\");\r\n    this.redraw_ = true;\r\n  }\r\n  // compare size of image to that of the screen rect; reallocate if different\r\n  if (this.myImage_ != null)  {\r\n    if (this.myImage_.width != r.getWidth() || this.myImage_.height != r.getHeight())  {\r\n      this.flush();\r\n    }\r\n  }\r\n\r\n  if (this.myImage_ == null)  {\r\n    // For now, bitmaps are always size of the simulation area.\r\n    // In future we could make them any desired size, though the 'screen sized'\r\n    // would be a special mode, because we don't know the size until\r\n    // the draw() happens (since applets are zero sized when created).\r\n    this.myImage_ = /** @type {!HTMLCanvasElement} */(document.createElement('canvas'));\r\n    this.myImage_.width = r.getWidth();\r\n    this.myImage_.height = r.getHeight();\r\n    this.redraw_ = true;\r\n    if (goog.DEBUG && this.debug_)\r\n      window.console.log(\"DisplayPath: redraw because image reallocated\");\r\n  }\r\n  if (this.redraw_ && this.myImage_ != null) {\r\n    // draw the paths into the bitmap\r\n    var ctx = /** @type {!CanvasRenderingContext2D} */(this.myImage_.getContext('2d'));\r\n    // Clear image with transparent alpha by drawing a rectangle\r\n    // \"clearRect fills with transparent black\"\r\n    ctx.clearRect(0, 0, r.getWidth(), r.getHeight());\r\n    ctx.strokeStyle = this.color_;\r\n    ctx.lineWidth = this.thickness_;\r\n    // draw the paths\r\n    goog.array.forEach(this.paths_, function(path) {\r\n        this.path_draw(path, ctx, map);\r\n      }, this);\r\n    this.redraw_ = false;\r\n  }\r\n  context.drawImage(this.myImage_, 0, 0, r.getWidth(), r.getHeight());\r\n  context.restore();\r\n};\r\n```\r\n\r\nHere is the interface for the `draw` method\r\n```javascript\r\n/** Draws this {DisplayObject} using the given coordinate mapping.\r\n@method\r\n@param {!CanvasRenderingContext2D} context the canvas's context to draw this object into\r\n@param {!myphysicslab.lab.view.CoordMap} map the mapping to use for translating between\r\nsimulation and screen coordinates\r\n*/\r\nDisplayObject.prototype.draw;\r\n```\r\n"}}