[Mono-list] Interface collisions

Quentin DELANCE quentin.delance@insalien.org
Tue, 10 Dec 2002 14:01:05 +0100


Hi all,


While reading the excellent "Thinking in C#", I decided to test an 
interesting case with mono. It consists in implementing many interfaces 
with method conflicting due to their return value (page 308 for those 
who have the book).

My example  (InterfaceClash.cs) :

---
$ cat InterfaceClash.cs
using System;

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

public class TestClass : I1, I2 {}
---

(It is not possible to implement void F() and int F() at the same time)

Now let's compile it :

---
$ mcs InterfaceClash.cs
InterfaceClash.cs(6) error CS0536: `TestClass' does not implement 
interface member `I1.F'
InterfaceClash.cs(6) error CS0536: `TestClass' does not implement 
interface member `I2.F'
Compilation failed: 2 error(s), 0 warnings
---

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...

Moreover, as I was playing with interfaces, I discovered the following 
case :

---
$ cat Error.cs
using System;

interface I { public void F(); }

public class TestClass : I {}
---

(the visibility is explicitily set to "public")

which produce the following message

---
$ mcs Error.cs
syntax error, expecting BOOL BYTE CHAR DECIMAL DOUBLE EVENT FLOAT INT 
LONG NEW OBJECT SBYTE SHORT STRING UINT ULONG USHORT VOID CLOSE_BRACE 
OPEN_BRACKET IDENTIFIER
Error.cs (3,17), Token: PUBLIC   : Parsing error
Mono.CSharp.yyParser.yyException: irrecoverable syntax error
in <0x006fa> 00 Mono.CSharp.CSharpParser:yyparse 
(Mono.CSharp.yyParser.yyInput)
in <0x0006f> 00 Mono.CSharp.CSharpParser:parse ()

error CS5001: Program Error.exe does not have an entry point defined
Compilation failed: 1 error(s), 0 warnings
---

Is there anything wrong there ? Should I fill a bug (haven't found 
anything relatedin bugzilla) ?

Anyway thanks for your great work etc etc


     Quentin