Issue 4920 in pharo: Copying a trait fails

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 4920 in pharo: Copying a trait fails

pharo
Status: New
Owner: ----

New issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

Copying a trait raises an error: 'name is multiply defined'.

Pharo image: Web
Pharo core version: Pharo1.3, #13315
Virtual machine used: Squeak 4.2.2beta1U.app
Class browser used if applicable: OBSystemBrowserAdaptor

Steps to reproduce:
1. Copy a trait


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo
Updates:
        Labels: Milestone-1.4

Comment #1 on issue 4920 by marianopeck: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

Yes, I could reproduce it. It would be nice to fix it.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo
Updates:
        Status: Accepted
        Labels: Type-Bug

Comment #2 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo

Comment #3 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

The browser is sending #duplicateClassWithNewName: to traits and  
classes...  So, traits should implement them, and we have to rename that  
also!


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo

Comment #4 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

Adding the following method in Trait:

duplicateClassWithNewName: aSymbol
        | copysName class newDefinition |
        copysName := aSymbol asSymbol.
        copysName = self name
                ifTrue: [ ^ self ].
        (Smalltalk globals includesKey: copysName)
                ifTrue: [ ^ self error: copysName , ' already exists' ].
        newDefinition := self definition copyReplaceAll: '#' , self name asString  
with: '#' , copysName asString.
        class := self class evaluatorClass evaluate: newDefinition logged: true.
       
        class copyAllCategoriesFrom: self.
        class class copyAllCategoriesFrom: self class.
        ^ class


does the trick, But I don't like the duplication between this and the Class  
one.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo
Updates:
        Status: FixReviewNeeded

Comment #5 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

Name: SLICE-Issue-4920-Copying-a-trait-fails-GuillermoPolito.1
Author: GuillermoPolito
Time: 2 November 2011, 4:11:51 pm
UUID: b321972a-fb8b-4fbd-a623-32ad12f26f62
Ancestors:
Dependencies: Traits-GuillermoPolito.400, Kernel-GuillermoPolito.958

Added copying trait for duplicating classes and traits


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo

Comment #6 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

I do not think it really makes sense to have a trait for only one method (  
and one hidden requirement never sent) and only two users, especially when  
you know that there will never have more than those 2 ones.

So I am in favor of code duplication here.

Attached a fix that duplicate the method from Class (as suggested above)

Attachments:
        4920-TraitDuplication.1.cs  769 bytes


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo
Updates:
        Status: FixToInclude

Comment #7 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo
Updates:
        Status: Integrated

Comment #8 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

in 14260


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4920 in pharo: Copying a trait fails

pharo

Comment #9 on issue 4920 by [hidden email]: Copying a trait fails
http://code.google.com/p/pharo/issues/detail?id=4920

Thanks!


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker