The main function has following:

- main.d -

        import test;
        auto t = new shared test.Test();
auto sock = new std.socket.TcpSocket( std.socket.AddressFamily.INET6 );
        t.setIt( sock );


- test.d -

module test;

import std.socket;

public class Test{
        private std.socket.Socket s;

        public void setIt(S)( S sock) shared
                if(
                        is(S: std.socket.Socket) ||
                        is(S: shared(std.socket.Socket))
                )
        {
                s = cast( typeof( s ) )sock;
        }
}


Above code works properly (I mean there is no error at all).

=====

Then I change the "Test.setIt" method as follows:

                import std.stdio;
                s = cast( typeof( s ) )sock;


Error on "s = cast..." line:
cannot cast module socket of type void to shared(Socket)

===

What is casting a module? How is this happening? Is this a bird, superman, or a bug?

Reply via email to