Browse Source

Simplify, add regression test.

Herby Vojčík 4 years ago
parent
commit
d3f3e10eeb
3 changed files with 29 additions and 5 deletions
  1. 1 5
      lang/base/kernel-runtime.js
  2. 24 0
      lang/src/Compiler-Tests.js
  3. 4 0
      lang/src/Compiler-Tests.st

+ 1 - 5
lang/base/kernel-runtime.js

@@ -358,17 +358,13 @@ define(function () {
         };
     }
 
-    MessageSendBrik.deps = ["smalltalkGlobals", "selectorConversion", "root"];
+    MessageSendBrik.deps = ["smalltalkGlobals", "selectorConversion"];
     function MessageSendBrik (brikz, st) {
         var globals = brikz.smalltalkGlobals.globals;
-        var nilAsReceiver = brikz.root.nilAsReceiver;
 
         /* Send message programmatically. Used to implement #perform: & Co. */
 
         st.send2 = function (self, selector, args, klass) {
-            if (self == null) {
-                self = nilAsReceiver;
-            }
             var method = klass ? klass.fn.prototype[st.st2js(selector)] : self.a$cls && self[st.st2js(selector)];
             return method != null ?
                 method.apply(self, args || []) :

+ 24 - 0
lang/src/Compiler-Tests.js

@@ -1271,6 +1271,30 @@ return self;
 }; }),
 $globals.CodeGeneratorTest);
 
+$core.addMethod(
+$core.method({
+selector: "testNilPerform",
+protocol: "tests",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testNilPerform\x0a\x09self should: 'foo ^ nil perform: #yourself' return: nil",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["should:return:"]
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._should_return_("foo ^ nil perform: #yourself",nil);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testNilPerform",{})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.CodeGeneratorTest);
+
 $core.addMethod(
 $core.method({
 selector: "testNonLocalReturn",

+ 4 - 0
lang/src/Compiler-Tests.st

@@ -342,6 +342,10 @@ testNestedSends
 	self should: 'foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString' return: (Point x: (2@3) y: 4) asString
 !
 
+testNilPerform
+	self should: 'foo ^ nil perform: #yourself' return: nil
+!
+
 testNonLocalReturn
 	self should: 'foo [ ^ 1 ] value' return: 1.
 	self should: 'foo [ ^ 1 + 1 ] value' return: 2.