Browse Source

boot.js: Keep the primitives-are-wrapped invariant!

Herbert Vojčík 9 years ago
parent
commit
bac031bda8
1 changed files with 4 additions and 0 deletions
  1. 4 0
      support/boot.js

+ 4 - 0
support/boot.js

@@ -1103,6 +1103,10 @@ define("amber/boot", [ 'require', './browser-compatibility' ], function (require
 			if (typeof o === "object") {
 				return o.klass != null ? o : globals.JSObjectProxy._on_(o);
 			}
+			// IMPORTANT: This optimization (return o if typeof !== "object")
+			// assumes all primitive types are wrapped by some Smalltalk class
+			// so they can be returned as-is, without boxing and looking for .klass.
+			// KEEP THE primitives-are-wrapped INVARIANT!
 			return o;
 		};
 	}