vitebonus / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

TreeNode.getParent() not optimizable #620

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Compile the below.  Notice that all references to getParent() now cannot be 
inlined nor renamed.

// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @use_types_for_optimization true
// @code_url https://closure-library.googlecode.com/git/closure/goog/base.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/structs/node.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/structs/treenode.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/dom/nodetype.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/debug/error.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/string/string.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/asserts/asserts.js
// @code_url 
https://closure-library.googlecode.com/git/closure/goog/array/array.js
// @formatting pretty_print
// ==/ClosureCompiler==

goog.provide('ns.x');

goog.require('goog.structs.TreeNode');

/** @constructor */
ns.x = function(){this._x = 1;};

/**
* @private
* @type {number}
*/
ns.x.prototype._x

/** @returns {number} */
ns.x.prototype.getParent = function(){
return this._x;
}
var x = (new ns.x()).getParent();
console.log(x);

var node1 = new goog.structs.TreeNode(1, '1');
var node2 = new goog.structs.TreeNode(2, '2');
var node3 = new goog.structs.TreeNode(3, '3');
node1.addChild(node2);
node2.addChild(node3);

var node4 = new goog.structs.TreeNode(4, '4');
node4.setParent(node3);

var clone = node2.clone();
console.log(clone.getKey()+clone.getParent()+node3.getParent()+node2.getChildren
());

Original issue reported on code.google.com by jhiswin on 13 Jan 2014 at 7:14

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Related to this
https://code.google.com/p/closure-compiler/issues/detail?id=1195
The example I gave on that page compiles fine.  The new example I gave does not 
compile properly.

Original comment by jhiswin on 13 Jan 2014 at 7:16