Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class converted to trait is unusable #3147

Open
khinsen opened this Issue Apr 9, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@khinsen
Copy link
Contributor

khinsen commented Apr 9, 2019

When you start writing a class and then convert it to a trait, the first use of that trait in a class definition will raise an error ("add: should not have been implemented in Array").

Example (execute the first two statements before attempting the third one):

Object subclass: #AClassBecomingATrait instanceVariableNames: '' classVariableNames: ''  category: '_UnpackagedPackage'.

Trait named: #AClassBecomingATrait
	 uses: {}
	 category: '_UnpackagedPackage'.

Object subclass: #ATestClass
            uses: AClassBecomingATrait
	    instanceVariableNames: ''
	   classVariableNames: ''
           package: '_UnpackagedPackage'.

Reason: The trait retains the class' instance variable 'user', which is an array, whereas for a trait it should be an IdentitySet.

@khinsen

This comment has been minimized.

Copy link
Contributor Author

khinsen commented Apr 9, 2019

Here is a test case for the bug (I had to add a .txt extension to please GitHub). I managed to make testClassMigratedToTraitHasIdentitySetForUsers green with a small fix to TraitBuilderEnhancer>>#beforeMigratingClass:installer:, but the second test remains red and I have no idea why. This is a job for a trait expert!

T2MigratingClassToTrait.st.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.