Status: Accepted
Owner: [email protected]
Labels: Milestone-1.3

New issue 3666 by [email protected]: Ensure that classOrTraitNamed: doesn't return globals.
http://code.google.com/p/pharo/issues/detail?id=3666

Ensure that classOrTraitNamed: doesn't return globals.

=============== Diff against System-ul.409 ===============

Item was changed:
----- Method: SystemDictionary>>classOrTraitNamed: (in category 'classes and traits') -----
 classOrTraitNamed: aString
"aString is either a class or trait name or a class or trait name followed by ' class' or 'classTrait' respectively.
       Answer the class or metaclass it names."

+       | meta baseName |
-       | meta baseName baseClass |
       (aString endsWith: ' class')
               ifTrue: [meta := true.
baseName := aString copyFrom: 1 to: aString size - 6]
               ifFalse: [
                       (aString endsWith: ' classTrait')
                               ifTrue: [
                                       meta := true.
baseName := aString copyFrom: 1 to: aString size - 11]
                               ifFalse: [
                                       meta := false.
                                       baseName := aString]].
+
+       ^self at: baseName asSymbol ifPresent:
+               [ :global |
+               global isBehavior ifTrue:
+                       [ meta
+                               ifFalse: [ global ]
+                               ifTrue: [ global classSide ]]]!
-       baseClass := Smalltalk at: baseName asSymbol ifAbsent: [^ nil].
-       meta
-               ifTrue: [^ baseClass classSide]
-               ifFalse: [^ baseClass]!


Reply via email to