Nested interface

Read Bixby rbixby at hotmail.com
Sun Apr 1 09:40:53 PDT 2012


I was working on a small personal project, and ran across 
something I think might (or might not) be a bug.  I'm posting in 
this particular group just in case it's a restriction somewhere 
that I just don't know about, or maybe just the way that 
covariance gets resolved.  The obvious workaround is to return 
NestedInterface from the two methods of the derived class rather 
than NestedImplementation, but I was kind of surprised it didn't 
compile (in the actual code, both the nested interface and the 
nested implementation were called "Node" which was stupid on my 
part).  I got the error message:  "Error: class 
Implementation.NestedImplementation ambiguous virtual function 
getNext"

Is this something anyone is likely to care about?

shared interface Interface
{
	public static shared interface NestedInterface
	{
		public shared(NestedInterface) getNext();
		public shared(const(NestedInterface)) getNext() const;
	}
}

shared class Implementation : Interface
{
	public static shared class NestedImplementation : 
Interface.NestedInterface
	{
		public override shared(NestedImplementation) getNext()
		{
			return null;
		}

		public override shared(const(NestedImplementation)) getNext() 
const
		{
			return null;
		}
	}
}



More information about the Digitalmars-d-learn mailing list