Skip to content

Commit

Permalink
- move extentions from Slot-Core to Behavior/Class/ClassDescription
Browse files Browse the repository at this point in the history
- make sure that we never call methods only defined in the subclass 

fixes pharo-project#6504
  • Loading branch information
MarcusDenker committed Jun 23, 2020
1 parent f36e381 commit 2554033
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 53 deletions.
28 changes: 28 additions & 0 deletions src/Kernel/Behavior.class.st
Expand Up @@ -538,6 +538,23 @@ Behavior >> classDepth [
^ self superclass classDepth + 1
]

{ #category : #accessing }
Behavior >> classLayout [
^ layout
ifNil: [
| superLayout scope |
superLayout := superclass
ifNil: [ FixedLayout new slotScope: LayoutEmptyScope instance] "happened in the bootrap"
ifNotNil: [:sl | sl classLayout].
scope := superLayout slotScope extend.
layout := superLayout class extending: superLayout scope: scope host: self ]
]

{ #category : #accessing }
Behavior >> classLayout: aClassLayout [
layout := aClassLayout
]

{ #category : #'accessing instances and variables' }
Behavior >> classVarNames [
"Answer a collection of the receiver's class variable names."
Expand Down Expand Up @@ -835,6 +852,17 @@ Behavior >> hasSelectorReferringTo: literal [
^self methods anySatisfy: [ :method | method hasLiteral: literal ]
]

{ #category : #testing }
Behavior >> hasSpecificLayout [
"Return true whether the receiver has a layout that is not a fixed one (which is the default linear layout for default classes."
"Point hasSpecificLayout >>> false"
"Array hasSpecificLayout >>> true"

^ (self classLayout isKindOf: FixedLayout) not


]

{ #category : #'testing class hierarchy' }
Behavior >> includesBehavior: aClass [

Expand Down
13 changes: 13 additions & 0 deletions src/Kernel/Class.class.st
Expand Up @@ -363,6 +363,12 @@ Class >> classVariables [
^self classPool associations
]

{ #category : #slots }
Class >> classVariablesNeedFullDefinition [

^ self classVariables anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #'accessing class hierarchy' }
Class >> commonSuperclassWith: aClass [
"return the next common superclass between me and aClass. If I am the superclass of aClass, that is me"
Expand Down Expand Up @@ -711,6 +717,13 @@ Class >> name [
^ name ifNil: [ super name ]
]

{ #category : #slots }
Class >> needsSlotClassDefinition [
"return true if we define something else than InstanceVariableSlots or normal class variables"

^ super needsSlotClassDefinition or: [ self classVariablesNeedFullDefinition ]
]

{ #category : #'subclass creation' }
Class >> newAnonymousSubclass [

Expand Down
26 changes: 16 additions & 10 deletions src/Kernel/ClassDescription.class.st
Expand Up @@ -320,12 +320,6 @@ ClassDescription >> classThatDefinesInstVarNamed: instVarName [
ifNone: nil
]

{ #category : #slots }
ClassDescription >> classVariablesNeedFullDefinition [

^ self classVariables anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #printing }
ClassDescription >> classVariablesString [
"Answer a string of my class variable names separated by spaces."
Expand Down Expand Up @@ -563,6 +557,20 @@ ClassDescription >> copyCategory: cat from: aClass classified: newCat [
classified: newCat
]

{ #category : #slots }
ClassDescription >> definesSlot: aSlot [
"Return true whether the receiver defines an instance variable named aString"

^ self slots identityIncludes: aSlot
]

{ #category : #slots }
ClassDescription >> definesSlotNamed: aString [
"Return true whether the receiver defines an instance variable named aString."

^ self slotNames includes: aString
]

{ #category : #'file in/out' }
ClassDescription >> definition [
"Answer a String that defines the receiver."
Expand Down Expand Up @@ -884,9 +892,7 @@ ClassDescription >> methodsTaggedWith: aSymbol [
ClassDescription >> needsSlotClassDefinition [
"return true if we define something else than InstanceVariableSlots or normal class variables"

^ self slotsNeedFullDefinition
or: [ self class slotsNeedFullDefinition
or: [ self classVariablesNeedFullDefinition ] ]
^ self slotsNeedFullDefinition or: [ self class slotsNeedFullDefinition ]
]

{ #category : #private }
Expand Down Expand Up @@ -1230,7 +1236,7 @@ ClassDescription >> slotNames [
^self slots collect: [ :each | each name ]
]

{ #category : #slots }
{ #category : #accessing }
ClassDescription >> slots [
^self classLayout visibleSlots
]
Expand Down
43 changes: 0 additions & 43 deletions src/Slot-Core/Behavior.extension.st

This file was deleted.

0 comments on commit 2554033

Please sign in to comment.