Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: third_party/closure_compiler/tests/getInstance_test.js

Issue 421253006: Add ChromeCodingConvention.java to Closure Compiler to preserve getInstance() type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@A_typechecking_about
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/closure_compiler/tests/getInstance_test.js
diff --git a/third_party/closure_compiler/tests/getInstance_test.js b/third_party/closure_compiler/tests/getInstance_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..66af82e9483140f2257c78646d668fe024c6b518
--- /dev/null
+++ b/third_party/closure_compiler/tests/getInstance_test.js
@@ -0,0 +1,48 @@
+var cr = {};
+var myModule = {};
+
+myModule.Mess = function() {};
+myModule.Mess.prototype = {
+ whatever: function() {}
+};
Dan Beam 2014/07/29 18:05:12 ^ unused
Vitaly Pavlenko 2014/07/29 18:53:46 Acknowledged.
+
+/**
+ * @constructor
+ */
+myModule.myBaseClass = function() {};
+
+myModule.myBaseClass.prototype = {
+ /**
+ * @param {number} name
+ */
+ myMethod: function(name) {
+ alert(name);
+ }
+};
+
+/**
+ * @constructor
+ * @extends {myModule.myBaseClass}
+ */
+myModule.myClass = function() {};
+
+/**
+ * @param {!Function} ctor
+ */
+cr.addSingletonGetter = function(ctor) {
Dan Beam 2014/07/29 18:05:12 can this file be: var cr = { /** @param {!Funct
Vitaly Pavlenko 2014/07/29 18:53:46 Done.
+ ctor.getInstance = function() {
+ return ctor.instance_ || (ctor.instance_ = new ctor());
+ };
+};
+
+cr.addSingletonGetter(myModule.myClass);
+
+/**
+ * @param {string} name
+ */
+myModule.myClass.myMethod = function(name) {
+ myModule.myClass.getInstance().whatever();
+ myModule.myClass.getInstance().myMethod(name);
+};
+
+myModule.myClass.myMethod('string');

Powered by Google App Engine
This is Rietveld 408576698