Browse Source

Supersends are not inlined.

Herby Vojčík 4 years ago
parent
commit
6ff24aaf97

+ 8 - 4
lang/src/Compiler-Inlining.js

@@ -1972,28 +1972,32 @@ selector: "shouldInline:",
 protocol: "accessing",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anIRSend"],
-source: "shouldInline: anIRSend\x0a\x09(self inlinedSelectors includes: anIRSend selector) ifFalse: [ ^ false ].\x0a\x09^ anIRSend arguments allSatisfy: [ :each | each isClosure ]",
+source: "shouldInline: anIRSend\x0a\x09(self inlinedSelectors includes: anIRSend selector) ifFalse: [ ^ false ].\x0a\x09anIRSend receiver isSuper ifTrue: [ ^ false ].\x0a\x09^ anIRSend arguments allSatisfy: [ :each | each isClosure ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "allSatisfy:", "arguments", "isClosure"]
+messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "ifTrue:", "isSuper", "receiver", "allSatisfy:", "arguments", "isClosure"]
 }, function ($methodClass){ return function (anIRSend){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
+var $1,$2;
 $1=$recv($self._inlinedSelectors())._includes_($recv(anIRSend)._selector());
 if(!$core.assert($1)){
 return false;
 }
+$2=$recv($recv(anIRSend)._receiver())._isSuper();
+if($core.assert($2)){
+return false;
+}
 return $recv($recv(anIRSend)._arguments())._allSatisfy_((function(each){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 return $recv(each)._isClosure();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
 //>>excludeEnd("ctx");
 }));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);

+ 1 - 0
lang/src/Compiler-Inlining.st

@@ -494,6 +494,7 @@ inlinedSelectors
 
 shouldInline: anIRSend
 	(self inlinedSelectors includes: anIRSend selector) ifFalse: [ ^ false ].
+	anIRSend receiver isSuper ifTrue: [ ^ false ].
 	^ anIRSend arguments allSatisfy: [ :each | each isClosure ]
 ! !
 

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

@@ -1232,6 +1232,30 @@ return self;
 }; }),
 $globals.AbstractCompilerTest);
 
+$core.addMethod(
+$core.method({
+selector: "testSuperSend6",
+protocol: "tests",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "testSuperSend6\x0a\x09self \x0a\x09\x09should: 'foo ^ super ifTrue: [ true ] ifFalse: [ false ]' \x0a\x09\x09receiver: true\x0a\x09\x09raise: Error",
+referencedClasses: ["Error"],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["should:receiver:raise:"]
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._should_receiver_raise_("foo ^ super ifTrue: [ true ] ifFalse: [ false ]",true,$globals.Error);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"testSuperSend6",{})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.AbstractCompilerTest);
+
 $core.addMethod(
 $core.method({
 selector: "testTempVariables",

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

@@ -335,6 +335,13 @@ testSuperSend5
 		return: #(1 2 3 5)
 !
 
+testSuperSend6
+	self 
+		should: 'foo ^ super ifTrue: [ true ] ifFalse: [ false ]' 
+		receiver: true
+		raise: Error
+!
+
 testTempVariables
 	self should: 'foo | a | ^ a' return: nil.
 	self should: 'foo | AVariable | ^ AVariable' return: nil.