Closed GoogleCodeExporter closed 9 years ago
Closure Library API reference:
http://docs.closure-library.googlecode.com/git/closure_goog_structs_treenode.js.
source.html#line94
Original comment by jhiswin
on 13 Jan 2014 at 3:34
This is by design and addressed in the
FAQ:https://code.google.com/p/closure-compiler/wiki/FAQ#Some_of_my_properties_ar
e_getting_renamed,_but_some_aren't.
When you add the use_types_for_optimization flag, the output of your example is:
console.log(1);
For the web service, your header should look like:
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @use_types_for_optimization true
// ==/ClosureCompiler==
Original comment by chadkill...@missouristate.edu
on 13 Jan 2014 at 4:04
Hi,
I'm using Closure Compiler from trunk locally, and for some odd reason it is
not using types for optimization.
It seems to be, as you say, fine on the Closure Compiler service.
Do you happen to know what might be the problem? This problem only happened
recently, and my build scripts are already set up to include -f
"--use-types-for-optimization" on the command line.
Original comment by jhiswin
on 13 Jan 2014 at 6:25
Hi, so here is an example that uses Closure Library's TreeNode. I'm not sure
if this is a problem with Closure Library or Closure Compiler, but this causes
all references to getParent to be unoptimized.
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 comment by jhiswin
on 13 Jan 2014 at 6:49
Hi, so I've managed to create a version that can be pasted into the Closure
Compiler service. The use of goog.structs.TreeNode appears to cause all
references to the name getParent to be no longer optimizable:
// ==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 comment by jhiswin
on 13 Jan 2014 at 6:59
John: Is this because TreeNode uses @template?
Original comment by chadkill...@missouristate.edu
on 13 Jan 2014 at 10:52
Here's another example that may not be related. "name" property doesn't get
renamed.
Though I'm not sure this is valid since "name" is reserved.
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @use_types_for_optimization true
// ==/ClosureCompiler==
/** @type {Object} */
var x = {name: 1};
console.log(x);
console.log(x.name);
Original comment by jhiswin
on 14 Jan 2014 at 4:35
#7 is working as intended.
Original comment by concavel...@gmail.com
on 14 Jan 2014 at 5:39
Issue tracking has been migrated to github. Please make any further comments on
this issue through https://github.com/google/closure-compiler/issues
Original comment by blic...@google.com
on 1 May 2014 at 6:31
Original comment by blic...@google.com
on 1 May 2014 at 6:34
Original issue reported on code.google.com by
jhiswin
on 13 Jan 2014 at 3:33