[Pharo-project] Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

pharo at googlecode.com pharo at googlecode.com
Sun Feb 6 12:18:58 CET 2011


Status: Accepted
Owner: stephane... at gmail.com
Labels: Milestone-1.3

New issue 3666 by stephane... at gmail.com: 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]!





More information about the Pharo-project mailing list