www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Final templated interface method not found

reply Andre <andre s-e-a-p.de> writes:
Hi,

following coding shoud work, or?
It doesn't compile with v2.068.0.

Kind regards
André

interface IfStatement
{
	void execute();
	
	final void execute(T...)(T t)
	{
		execute();
	}
}

class Statement: IfStatement
{
	void execute(){}
}

void main()
{
	new Statement().execute(1,"Hello World");
}
Sep 15 2015
parent reply anonymous <anonymous example.com> writes:
On Wednesday 16 September 2015 06:14, Andre wrote:

 Hi,
 
 following coding shoud work, or?
 It doesn't compile with v2.068.0.
 
 Kind regards
 André
 
 interface IfStatement
 {
 	void execute();
 	
 	final void execute(T...)(T t)
 	{
 		execute();
 	}
 }
 
 class Statement: IfStatement
 {
 	void execute(){}
 }
 
 void main()
 {
 	new Statement().execute(1,"Hello World");
 }
You need to add IfStatement.execute to the overload set like so: ---- class Statement: IfStatement { alias execute = IfStatement.execute; void execute(){} } ----
Sep 15 2015
parent Andre <andre s-e-a-p.de> writes:
Thanks, it works like a charme.

Kind regards
André
Sep 16 2015