diff --git a/src/TraitsV2-Tests/T2AbstractTest.class.st b/src/TraitsV2-Tests/T2AbstractTest.class.st index 92b24ad168a..0f2ed76b92c 100644 --- a/src/TraitsV2-Tests/T2AbstractTest.class.st +++ b/src/TraitsV2-Tests/T2AbstractTest.class.st @@ -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 [ diff --git a/src/TraitsV2-Tests/T2TraitTest.class.st b/src/TraitsV2-Tests/T2TraitTest.class.st index dad003088a2..bfa5750837f 100644 --- a/src/TraitsV2-Tests/T2TraitTest.class.st +++ b/src/TraitsV2-Tests/T2TraitTest.class.st @@ -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 | diff --git a/src/TraitsV2/ClassDescription.extension.st b/src/TraitsV2/ClassDescription.extension.st index 80a6cf9a5fd..683def7ea4a 100644 --- a/src/TraitsV2/ClassDescription.extension.st +++ b/src/TraitsV2/ClassDescription.extension.st @@ -16,6 +16,11 @@ ClassDescription >> baseComposition [ ^ TaEmptyComposition new ] +{ #category : #'*TraitsV2' } +ClassDescription >> selectorsWithExplicitOrigin [ + ^self traitComposition selectors , self localSelectors +] + { #category : #'*TraitsV2' } ClassDescription >> traitComposition [ ^ TaEmptyComposition new