From 60cd47f77033ae83b4197abd58e53d289e7515a1 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Fri, 13 Oct 2023 11:42:25 +0200 Subject: [PATCH] Use shift class builder to build traits --- .../HEInstallerSimpleTest.class.st | 2 +- src/Hermes/HEInstaller.class.st | 26 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Hermes-Tests/HEInstallerSimpleTest.class.st b/src/Hermes-Tests/HEInstallerSimpleTest.class.st index f7d1cd1..3ba36b5 100644 --- a/src/Hermes-Tests/HEInstallerSimpleTest.class.st +++ b/src/Hermes-Tests/HEInstallerSimpleTest.class.st @@ -253,7 +253,7 @@ HEInstallerSimpleTest >> testUndeclared [ | exportedClass | "If we run the test multiple times we need to do this to be sure #AnUndeclaredClass is not in the Undeclared dictionary anymore." - Undeclared removeUnreferencedKeys. + Smalltalk image cleanOutUndeclared. [ UndefinedObject compile: 'xxx ^ AnUndeclaredClass'. diff --git a/src/Hermes/HEInstaller.class.st b/src/Hermes/HEInstaller.class.st index 5444780..fa2cf1d 100644 --- a/src/Hermes/HEInstaller.class.st +++ b/src/Hermes/HEInstaller.class.st @@ -60,23 +60,19 @@ HEInstaller >> build: aHEClass [ { #category : 'creating traits' } HEInstaller >> buildTrait: aTraitDefinition [ - | newTrait traitComposition traitClass| - - (self existingTrait: aTraitDefinition) ifNotNil: [:x | ^ x ]. - - 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: (self buildTraitCompositionFor: aTraitDefinition classTraitComposition). + (self existingTrait: aTraitDefinition) ifNotNil: [ :x | ^ x ]. + + self supportsTraits ifFalse: [ self error: 'Trait support is not installed' ]. - ^ newTrait + ^ self class classInstaller make: [ :builder | + builder + beTrait; + name: aTraitDefinition traitName; + uses: (self buildTraitCompositionFor: aTraitDefinition traitComposition); + classTraitComposition: (self buildTraitCompositionFor: aTraitDefinition classTraitComposition); + package: aTraitDefinition category; + environment: environment ] ] { #category : 'creating traits' }