[Mono-list] NullException with mcs compiled code that has complex inheritance from interfaces --> mcs bug?

Dominik Fretz lists@roboto.ch
Wed, 14 May 2003 17:02:54 +0200


This is a multi-part message in MIME format.
--------------040804000508010701080307
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi

Working on the task to get #D running on mono I encounterd a problem 
with the complex inheritance of interfaces.

I have two interfaces and two abstract classes.

Interfaces:
ICommand is the base interface
ISubCommand inherit's from ICommand

Abstract Classes:
AbstractCommand inherits from ICommand
AbstractSubCommand inherit's from AbstractCommand and from ISubCommand

Classes:
TestCommand inherits from AbstractSubCommand
So TestCommand iherits 2 times from ICommand, once over 
AbstractSubCommand->ISubCommand->ICommand and once over 
AbstractSubCommand->AbstractCommand->ICommand

If i now create a instance foo of TestCommand:
TestCommand foo = new TestCommand();

and then call:
((ICommand)foo).Run();

there is a exception.
This only happens if I compile this with mcs.
A exe from windows/.net works on mono.

Find attached a demo source for this problem.

I also submited a bug (#42973) on this issue.

I currently work with mono/mcs from CVS (from 13. May 2003).

Hope someone can find and fix this.

thx

Dominik

--------------040804000508010701080307
Content-Type: text/plain;
 name="Class1.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Class1.cs"

  using System;

  namespace ConsoleApplication
  {
    public interface ICommand {
      void Run();
    }

    public interface ISubCommand : ICommand {}

    public abstract class AbstractCommand : ICommand {
      public abstract void Run();
    }

    public abstract class AbstractSubCommand : AbstractCommand, ISubCommand {}

    public class TestCommand : AbstractSubCommand {
      public override void Run() {
        Console.WriteLine("Hello from: TestCommand");
      }
    }

	  class Class1
	  {
		  static void Main(string[] args) {
        TestCommand foo =  new TestCommand();
        ((ICommand)foo).Run();
        Console.ReadLine();
		  }
	  }
  }

--------------040804000508010701080307--