Skip to content

Commit

Permalink
Fixing the creation of traits when the loaded traits are in the same …
Browse files Browse the repository at this point in the history
…package as trait support.

The extension methods are loaded after traits and classes. So, the build process cannot relly in the extension methods.
  • Loading branch information
tesonep committed Mar 10, 2021
1 parent 9c82410 commit 1e5dbd8
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/Hermes/HEInstaller.class.st
Expand Up @@ -84,21 +84,34 @@ HEInstaller >> buildTrait: aTraitDefinition [

(self existingTrait: aTraitDefinition) ifNotNil: [:x | ^ x ].

traitComposition := (aTraitDefinition traitComposition asLiteralIn: environment) asTraitComposition.

traitClass := Smalltalk globals at: #Trait ifAbsent: [ self error: 'Trait support is not installed' ].

traitComposition := self buildTraitCompositionFor: aTraitDefinition traitComposition.

newTrait := traitClass
named: aTraitDefinition traitName
uses: traitComposition
package: aTraitDefinition category
env: environment.

newTrait classTrait traitComposition: (aTraitDefinition classTraitComposition asLiteralIn: environment) asTraitComposition.
newTrait classTrait traitComposition: (self buildTraitCompositionFor: aTraitDefinition classTraitComposition).

^ newTrait
]

{ #category : #'creating traits' }
HEInstaller >> buildTraitCompositionFor: traitComposition [

| aLiteral |

aLiteral := (traitComposition asLiteralIn: environment).
aLiteral isArray
ifTrue: [ ^ aLiteral
ifEmpty: [ TaEmptyComposition new ]
ifNotEmpty: [ TaSequence withAll: (aLiteral collect: [:each | each asTraitComposition]) ] ]
ifFalse: [ ^ aLiteral asTraitComposition ]
]

{ #category : #accessing }
HEInstaller >> classNamed: aSymbol [
aSymbol ifNil: [ ^ nil ].
Expand Down Expand Up @@ -220,8 +233,8 @@ HEInstaller >> processTraitsFrom: aHEClass in: newClass [

hasTraits ifFalse: [ ^ self ].

newClass setTraitComposition: (aHEClass traitComposition asLiteralIn: environment) asTraitComposition.
newClass class setTraitComposition: (aHEClass classTraitComposition asLiteralIn: environment) asTraitComposition.
newClass setTraitComposition: (self buildTraitCompositionFor: aHEClass traitComposition).
newClass class setTraitComposition: (self buildTraitCompositionFor: aHEClass classTraitComposition).

]

Expand Down

0 comments on commit 1e5dbd8

Please sign in to comment.