[ruby-cvs:78361] a0579f3606 (master): Make prepending a refined module after inclusion not break refinements

"Jeremy Evans" <[email protected]>
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
Jeremy Evans	2019-10-12 17:02:51 +0900 (Sat, 12 Oct 2019)

  New Revision: a0579f3606

  https://github.com/ruby/ruby/commit/a0579f3606

  Log:
    Make prepending a refined module after inclusion not break refinements
    
    After the previous commit, this was still broken. The reason it
    was broken is that a refined module that hasn't been prepended to
    yet keeps the refined methods in the module's method table. When
    prepending, the module's method table is moved to the origin
    iclass, and then the refined methods are moved from the method
    table to a new method table in the module itself.
    
    Unfortunately, that means that if a class has included the module,
    prepending breaks the refinements, because when the methods are
    moved from the origin iclass method table to the module method
    table, they are removed from the method table from the iclass
    created when the module was included earlier.
    
    Fix this by always creating an origin class when including a
    module that has any refinements, even if the refinements are
    not currently used.  I wasn't sure the best way to do that.
    The approach I choose was to use an object flag. The flag is
    set on the module when Module#refine is called, and if the
    flag is present when the module is included in another module
    or class, an origin iclass is created for the module.
    
    Fixes [Bug #13446]

  Modified files:
    class.c
    eval.c
    internal.h
    test/ruby/test_refinement.rb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.