Skip to content

Commit

Permalink
Merge pull request #1856 from bouraqadi/22516-TraitedClass-selectors-…
Browse files Browse the repository at this point in the history
…should-be-filtred-from-other-selectors

Fix for  issue 22516
  • Loading branch information
MarcusDenker committed Oct 4, 2018
2 parents 4e32689 + 41874bc commit ab83f04
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/TraitsV2-Tests/T2AbstractTest.class.st
Expand Up @@ -10,6 +10,11 @@ Class {
#category : #'TraitsV2-Tests-Tests'
}

{ #category : #'instance creation' }
T2AbstractTest >> newClass: aName [
^self newClass: aName with: #() uses: #()
]

{ #category : #'instance creation' }
T2AbstractTest >> newClass: aName superclass: aSuperclass with: slots uses: aComposition [

Expand Down
26 changes: 26 additions & 0 deletions src/TraitsV2-Tests/T2TraitTest.class.st
Expand Up @@ -155,6 +155,32 @@ T2TraitTest >> testMethodsAddedInMetaclassPresentInSubclassesAfterRemovingSuperc

]

{ #category : #tests }
T2TraitTest >> testSelectorsWithExplicitOrigin [
"Obtain the subset of selectors that are defined either locally or inherited from traits. But, exclude selectors of methods from implicit traits such as TraitedClass"
| t1 c1 |

t1 := self newTrait: #T1 with: #().
t1 compile: 'instanceSideMethod'.
t1 class compile: 'classSideMethod'.
c1 := self newClass: #C1 with: #() uses: t1.
self assertCollection: c1 selectorsWithExplicitOrigin hasSameElements: #(instanceSideMethod).
self assertCollection: c1 class selectorsWithExplicitOrigin hasSameElements: #(classSideMethod).

]

{ #category : #tests }
T2TraitTest >> testSelectorsWithExplicitOriginNoTrait [
"Obtain the subset of selectors that are defined either locally or inherited from traits. But, exclude selectors of methods from implicit traits such as TraitedClass"
| c1 |
c1 := self newClass: #C1.
c1 compile: 'instanceSideMethod'.
c1 class compile: 'classSideMethod'.
self assertCollection: c1 selectorsWithExplicitOrigin hasSameElements: #(instanceSideMethod).
self assertCollection: c1 class selectorsWithExplicitOrigin hasSameElements: #(classSideMethod).

]

{ #category : #tests }
T2TraitTest >> testSequence [
| t1 t2 c1 obj |
Expand Down
5 changes: 5 additions & 0 deletions src/TraitsV2/ClassDescription.extension.st
Expand Up @@ -16,6 +16,11 @@ ClassDescription >> baseComposition [
^ TaEmptyComposition new
]

{ #category : #'*TraitsV2' }
ClassDescription >> selectorsWithExplicitOrigin [
^self traitComposition selectors , self localSelectors
]

{ #category : #'*TraitsV2' }
ClassDescription >> traitComposition [
^ TaEmptyComposition new
Expand Down

0 comments on commit ab83f04

Please sign in to comment.