[Issue 1728] alias hides mixin member func?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 9 03:13:34 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1728


bugzilla at digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #3 from bugzilla at digitalmars.com  2008-12-09 05:13 -------
This is not a bug.

The mixin establishes its own scope that is nested inside B's scope. If there
is no print in B's scope, it will look in the mixin. If there is a print in B's
scope, it will not look in the mixin.

This works exactly the same as imports and symbols at module scope.

The solution is to bring the desired members of mixtem up into B's scope. An
alias will accomplish this, so rewriting B as:

class B:A,mix 
{
        alias A.print print;    
        mixin mixtem M;        // give scope the name 'M'
        alias M.print print;   // and bring M's print into B's scope
        void pr() 
        { 
                super.print(); 
                super.print(18); 
                print("OK");   // this should call mixin member func
                writefln("B"); 
        } 
}

should work.


-- 



More information about the Digitalmars-d-bugs mailing list