Miguel de Icaza wrote:

Hello,


Which is fine except that in the book the output of csc looks even smarter. The error used is CS 0111 and states that it is not possible to implement these interface at the same time. It would be nice if mcs could do the same...

Please file a `wish list' bug in bugzilla.ximian.com

Well that is not needed after all !

After spending some more time on it, here is another code sample :

$ cat InterfaceCollision.cs
using System;

interface I1 { void F(); }
interface I2 { int F(); }

public class TestClass : I1, I2
{
void F() {}
int F() {}
}
$ mcs InterfaceCollision.cs
InterfaceCollision.cs(9) error CS0111: Class `TestClass' already defines a member called `F' with the same parameter types
Compilation failed: 1 error(s), 0 warnings

This time, I get the expected CS0111 error. The difference is that this time, both methods have been implemented in "TestClass" which was not the case previously. After rereading Thinking in C#, the behaviour is the same for mcs, that's to say :

+ if methods are not implemented -> CS0536 (no checking wether there could be conflicts with overloading without explicit implementation by prepending the name of the class to the method ie I1.F)
+ if methods are implemented and a conflict exists -> CS0111

Sorry, my first tests were too simple to fully understand the problem. As said in the book, these a cases were "implementation and overloading get unpleasantly mixed".


Note that its possible to implement the interface methods if you use
explicit interface implementation.

Yes, Jonathan also pointed this to me. It is also covered by the book and I was not familiar with this syntax !

One must be brave to implement compilers ;)

To sum up, I will only fill a low priority bug for the parser error (unexpected key word public in interfaces)

Many thx for the support !


Quentin





_______________________________________________
Mono-list maillist - [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to