1
0
Bläddra i källkod

Do not export methods from trait composition.

Herbert Vojčík 7 år sedan
förälder
incheckning
dd0a9ad051
4 ändrade filer med 101 tillägg och 15 borttagningar
  1. 34 3
      src/Kernel-Classes.js
  2. 7 2
      src/Kernel-Classes.st
  3. 50 6
      src/Platform-ImportExport.js
  4. 10 4
      src/Platform-ImportExport.st

+ 34 - 3
src/Kernel-Classes.js

@@ -510,7 +510,7 @@ return $recv($recv(self._ownProtocols())._inject_into_($recv($globals.OrderedCol
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $recv(acc).__comma(self._methodsInProtocol_(each));
+return $recv(acc).__comma(self._ownMethodsInProtocol_(each));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({acc:acc,each:each},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -533,10 +533,41 @@ return $recv($1).__lt_eq($recv(b)._selector());
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "ownMethods\x0a\x09\x22Answer the methods of the receiver that are not package extensions\x22\x0a\x0a\x09^ (self ownProtocols \x0a\x09\x09inject: OrderedCollection new\x0a\x09\x09into: [ :acc :each | acc, (self methodsInProtocol: each) ])\x0a\x09\x09\x09sorted: [ :a :b | a selector <= b selector ]",
+source: "ownMethods\x0a\x09\x22Answer the methods of the receiver that are not package extensions\x0a\x09nor obtained via trait composition\x22\x0a\x0a\x09^ (self ownProtocols \x0a\x09\x09inject: OrderedCollection new\x0a\x09\x09into: [ :acc :each | acc, (self ownMethodsInProtocol: each) ])\x0a\x09\x09\x09sorted: [ :a :b | a selector <= b selector ]",
 referencedClasses: ["OrderedCollection"],
 //>>excludeEnd("ide");
-messageSends: ["sorted:", "inject:into:", "ownProtocols", "new", ",", "methodsInProtocol:", "<=", "selector"]
+messageSends: ["sorted:", "inject:into:", "ownProtocols", "new", ",", "ownMethodsInProtocol:", "<=", "selector"]
+}),
+$globals.BehaviorBody);
+
+$core.addMethod(
+$core.method({
+selector: "ownMethodsInProtocol:",
+protocol: "accessing",
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(self._methodsInProtocol_(aString))._select_((function(each){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv($recv(each)._methodClass()).__eq(self);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"ownMethodsInProtocol:",{aString:aString},$globals.BehaviorBody)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "ownMethodsInProtocol: aString\x0a\x09^ (self methodsInProtocol: aString) select: [ :each | each methodClass = self ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["select:", "methodsInProtocol:", "=", "methodClass"]
 }),
 $globals.BehaviorBody);
 

+ 7 - 2
src/Kernel-Classes.st

@@ -72,14 +72,19 @@ organization
 !
 
 ownMethods
-	"Answer the methods of the receiver that are not package extensions"
+	"Answer the methods of the receiver that are not package extensions
+	nor obtained via trait composition"
 
 	^ (self ownProtocols 
 		inject: OrderedCollection new
-		into: [ :acc :each | acc, (self methodsInProtocol: each) ])
+		into: [ :acc :each | acc, (self ownMethodsInProtocol: each) ])
 			sorted: [ :a :b | a selector <= b selector ]
 !
 
+ownMethodsInProtocol: aString
+	^ (self methodsInProtocol: aString) select: [ :each | each methodClass = self ]
+!
+
 ownProtocols
 	"Answer the protocols of the receiver that are not package extensions"
 

+ 50 - 6
src/Platform-ImportExport.js

@@ -639,17 +639,25 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._exportProtocolPrologueOf_on_(aProtocol,aStream);
-$recv($recv(aProtocol)._methods())._do_((function(method){
+$recv($recv(aProtocol)._ownMethods())._ifNotEmpty_((function(methods){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
+self._exportProtocolPrologueOf_on_(aProtocol,aStream);
+$recv(methods)._do_((function(method){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
 return self._exportMethod_on_(method,aStream);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)});
+}, function($ctx3) {$ctx3.fillBlock({method:method},$ctx2,2)});
+//>>excludeEnd("ctx");
+}));
+return self._exportProtocolEpilogueOf_on_(aProtocol,aStream);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({methods:methods},$ctx1,1)});
 //>>excludeEnd("ctx");
 }));
-self._exportProtocolEpilogueOf_on_(aProtocol,aStream);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"exportProtocol:on:",{aProtocol:aProtocol,aStream:aStream},$globals.ChunkExporter)});
@@ -657,10 +665,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aProtocol", "aStream"],
-source: "exportProtocol: aProtocol on: aStream\x0a\x09self exportProtocolPrologueOf: aProtocol on: aStream.\x0a\x09aProtocol methods do: [ :method | \x0a\x09\x09self exportMethod: method on: aStream ].\x0a\x09self exportProtocolEpilogueOf: aProtocol on: aStream",
+source: "exportProtocol: aProtocol on: aStream\x0a\x09aProtocol ownMethods ifNotEmpty: [ :methods |\x0a\x09\x09self exportProtocolPrologueOf: aProtocol on: aStream.\x0a\x09\x09methods do: [ :method | \x0a\x09\x09\x09self exportMethod: method on: aStream ].\x0a\x09\x09self exportProtocolEpilogueOf: aProtocol on: aStream ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["exportProtocolPrologueOf:on:", "do:", "methods", "exportMethod:on:", "exportProtocolEpilogueOf:on:"]
+messageSends: ["ifNotEmpty:", "ownMethods", "exportProtocolPrologueOf:on:", "do:", "exportMethod:on:", "exportProtocolEpilogueOf:on:"]
 }),
 $globals.ChunkExporter);
 
@@ -2601,6 +2609,42 @@ messageSends: []
 }),
 $globals.ExportMethodProtocol);
 
+$core.addMethod(
+$core.method({
+selector: "ownMethods",
+protocol: "accessing",
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+return $recv($recv(self._theClass())._ownMethodsInProtocol_(self._name()))._sorted_((function(a,b){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$1=$recv(a)._selector();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["selector"]=1;
+//>>excludeEnd("ctx");
+return $recv($1).__lt_eq($recv(b)._selector());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"ownMethods",{},$globals.ExportMethodProtocol)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "ownMethods\x0a\x09^ (self theClass ownMethodsInProtocol: self name)\x0a\x09\x09sorted: [ :a :b | a selector <= b selector ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["sorted:", "ownMethodsInProtocol:", "theClass", "name", "<=", "selector"]
+}),
+$globals.ExportMethodProtocol);
+
 $core.addMethod(
 $core.method({
 selector: "theClass",

+ 10 - 4
src/Platform-ImportExport.st

@@ -212,10 +212,11 @@ exportPackageImportsOf: aPackage on: aStream
 !
 
 exportProtocol: aProtocol on: aStream
-	self exportProtocolPrologueOf: aProtocol on: aStream.
-	aProtocol methods do: [ :method | 
-		self exportMethod: method on: aStream ].
-	self exportProtocolEpilogueOf: aProtocol on: aStream
+	aProtocol ownMethods ifNotEmpty: [ :methods |
+		self exportProtocolPrologueOf: aProtocol on: aStream.
+		methods do: [ :method | 
+			self exportMethod: method on: aStream ].
+		self exportProtocolEpilogueOf: aProtocol on: aStream ]
 !
 
 exportProtocolEpilogueOf: aProtocol on: aStream
@@ -655,6 +656,11 @@ name: aString
 	name := aString
 !
 
+ownMethods
+	^ (self theClass ownMethodsInProtocol: self name)
+		sorted: [ :a :b | a selector <= b selector ]
+!
+
 theClass
 	^ theClass
 !