Browse Source

ChunkExporter: fix bug in exportPackageExtensionsOf:on:

The methods were not exported with the correct class
instance.
The variable each was used instead of aClass.
This leads to class methods being exported as
instance methods.
mkroehnert 13 năm trước cách đây
mục cha
commit
9f4d20ea77
3 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 1 1
      js/Compiler.deploy.js
  2. 2 2
      js/Compiler.js
  3. 1 1
      st/Compiler.st

+ 1 - 1
js/Compiler.deploy.js

@@ -276,7 +276,7 @@ var name=nil;
 var map=nil;
 (name=smalltalk.send(package, "_name", []));
 smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_sortedClasses_", [smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_classes", [])]), "_do_", [(function(each){return smalltalk.send([each,smalltalk.send(each, "_class", [])], "_do_", [(function(aClass){(map=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));smalltalk.send(aClass, "_protocolsDo_", [(function(category, methods){return ((($receiver = smalltalk.send(category, "_match_", [smalltalk.send(unescape("%5E%5C*"), "__comma", [name])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(map, "_at_put_", [category, methods]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(map, "_at_put_", [category, methods]);})]));})]);return smalltalk.send(smalltalk.send(smalltalk.send(map, "_keys", []), "_sorted_", [(function(a, b){return ((($receiver = a).klass === smalltalk.Number) ? $receiver <=b : smalltalk.send($receiver, "__lt_eq", [b]));})]), "_do_", [(function(category){var methods=nil;
-(methods=smalltalk.send(map, "_at_", [category]));return smalltalk.send(self, "_exportMethods_category_of_on_", [methods, category, each, aStream]);})]);})]);})]);
+(methods=smalltalk.send(map, "_at_", [category]));return smalltalk.send(self, "_exportMethods_category_of_on_", [methods, category, aClass, aStream]);})]);})]);})]);
 return self;}
 }),
 smalltalk.ChunkExporter);

+ 2 - 2
js/Compiler.js

@@ -382,10 +382,10 @@ var name=nil;
 var map=nil;
 (name=smalltalk.send(package, "_name", []));
 smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_sortedClasses_", [smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_classes", [])]), "_do_", [(function(each){return smalltalk.send([each,smalltalk.send(each, "_class", [])], "_do_", [(function(aClass){(map=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));smalltalk.send(aClass, "_protocolsDo_", [(function(category, methods){return ((($receiver = smalltalk.send(category, "_match_", [smalltalk.send(unescape("%5E%5C*"), "__comma", [name])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(map, "_at_put_", [category, methods]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(map, "_at_put_", [category, methods]);})]));})]);return smalltalk.send(smalltalk.send(smalltalk.send(map, "_keys", []), "_sorted_", [(function(a, b){return ((($receiver = a).klass === smalltalk.Number) ? $receiver <=b : smalltalk.send($receiver, "__lt_eq", [b]));})]), "_do_", [(function(category){var methods=nil;
-(methods=smalltalk.send(map, "_at_", [category]));return smalltalk.send(self, "_exportMethods_category_of_on_", [methods, category, each, aStream]);})]);})]);})]);
+(methods=smalltalk.send(map, "_at_", [category]));return smalltalk.send(self, "_exportMethods_category_of_on_", [methods, category, aClass, aStream]);})]);})]);})]);
 return self;},
 args: ["package", "aStream"],
-source: unescape('exportPackageExtensionsOf%3A%20package%20on%3A%20aStream%0A%09%22We%20need%20to%20override%20this%20one%20too%20since%20we%20need%20to%20group%0A%09all%20methods%20in%20a%20given%20protocol%20under%20a%20leading%20methodsFor%3A%20chunk%0A%09for%20that%20class.%22%0A%0A%09%22Issue%20%23143%3A%20sort%20protocol%20alphabetically%22%0A%0A%09%7C%20name%20map%20%7C%0A%09name%20%3A%3D%20package%20name.%0A%09%28Package%20sortedClasses%3A%20Smalltalk%20current%20classes%29%20do%3A%20%5B%3Aeach%20%7C%0A%09%09%7Beach.%20each%20class%7D%20do%3A%20%5B%3AaClass%20%7C%0A%09%09%09map%20%3A%3D%20Dictionary%20new.%0A%09%09%09aClass%20protocolsDo%3A%20%5B%3Acategory%20%3Amethods%20%7C%20%0A%09%09%09%09%28category%20match%3A%20%27%5E%5C*%27%2C%20name%29%20ifTrue%3A%20%5B%20map%20at%3A%20category%20put%3A%20methods%20%5D%5D.%0A%09%09%09%28map%20keys%20sorted%3A%20%5B%3Aa%20%3Ab%20%7C%20a%20%3C%3D%20b%20%5D%29%20do%3A%20%5B%3Acategory%20%7C%20%7C%20methods%20%7C%0A%09%09%09%09methods%20%3A%3D%20map%20at%3A%20category.%09%0A%09%09%09%09self%20exportMethods%3A%20methods%20category%3A%20category%20of%3A%20each%20on%3A%20aStream%20%5D%5D%5D'),
+source: unescape('exportPackageExtensionsOf%3A%20package%20on%3A%20aStream%0A%09%22We%20need%20to%20override%20this%20one%20too%20since%20we%20need%20to%20group%0A%09all%20methods%20in%20a%20given%20protocol%20under%20a%20leading%20methodsFor%3A%20chunk%0A%09for%20that%20class.%22%0A%0A%09%22Issue%20%23143%3A%20sort%20protocol%20alphabetically%22%0A%0A%09%7C%20name%20map%20%7C%0A%09name%20%3A%3D%20package%20name.%0A%09%28Package%20sortedClasses%3A%20Smalltalk%20current%20classes%29%20do%3A%20%5B%3Aeach%20%7C%0A%09%09%7Beach.%20each%20class%7D%20do%3A%20%5B%3AaClass%20%7C%0A%09%09%09map%20%3A%3D%20Dictionary%20new.%0A%09%09%09aClass%20protocolsDo%3A%20%5B%3Acategory%20%3Amethods%20%7C%20%0A%09%09%09%09%28category%20match%3A%20%27%5E%5C*%27%2C%20name%29%20ifTrue%3A%20%5B%20map%20at%3A%20category%20put%3A%20methods%20%5D%5D.%0A%09%09%09%28map%20keys%20sorted%3A%20%5B%3Aa%20%3Ab%20%7C%20a%20%3C%3D%20b%20%5D%29%20do%3A%20%5B%3Acategory%20%7C%20%7C%20methods%20%7C%0A%09%09%09%09methods%20%3A%3D%20map%20at%3A%20category.%09%0A%09%09%09%09self%20exportMethods%3A%20methods%20category%3A%20category%20of%3A%20aClass%20on%3A%20aStream%20%5D%5D%5D'),
 messageSends: ["name", "do:", "sortedClasses:", "classes", "current", "class", "new", "protocolsDo:", "ifTrue:", "match:", unescape("%2C"), "at:put:", "sorted:", "keys", unescape("%3C%3D"), "at:", "exportMethods:category:of:on:"],
 referencedClasses: ["Package", "Smalltalk", "Dictionary"]
 }),

+ 1 - 1
st/Compiler.st

@@ -284,7 +284,7 @@ exportPackageExtensionsOf: package on: aStream
 				(category match: '^\*', name) ifTrue: [ map at: category put: methods ]].
 			(map keys sorted: [:a :b | a <= b ]) do: [:category | | methods |
 				methods := map at: category.	
-				self exportMethods: methods category: category of: each on: aStream ]]]
+				self exportMethods: methods category: category of: aClass on: aStream ]]]
 ! !
 
 Exporter subclass: #StrippedExporter