[nem-bug] [Nemerle 0000626]: Quoted declaration of method override
results in compile-time error
feedback at nemerle.org
feedback at nemerle.org
Mon May 22 18:05:04 CEST 2006
The following issue has been CLOSED
======================================================================
<http://nemerle.org/bugs/view.php?id=626>
======================================================================
Reported By: OysterDva
Assigned To: nazgul
======================================================================
Project: Nemerle
Issue ID: 626
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: closed
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 02-25-2006 21:23 CET
Last Modified: 05-22-2006 18:05 CEST
======================================================================
Summary: Quoted declaration of method override results in
compile-time error
Description:
Definition of method override using TypeBuilder.Define() and quoting fails
if base class contains generic method with the same name/signature and
value of template parameter type returned.
For example, imagine we have the following class declared in C# (as I
understand, it's impossible to declare such class in Nemerle):
namespace NS
{
public class Test
{
virtual public object DoIt()
{
return null;
}
// Comment this method and error will go away
static public T DoIt<T>()
{
return default(T);
}
}
}
Here we have two methods with name DoIt() and similar signatures - one is
virtual and another one is static method with generic type parameter.
Now look at the following macro code which creates type inherited from
Test:
macro Reproduce1()
{
def ctx = Nemerle.Macros.ImplicitCTX();
def t = ctx.Env.Define(<[ decl: public class TestInherit : NS.Test {}
]>);
// This LOC causes an error to happen
t.Define(<[ decl: override public DoIt() : object { null } ]>);
t.Compile();
<[ () ]>
}
When we're using this macro, the following compile-time error occurs:
"`override' specified on method TestInherit.DoIt() : System.Object, but
there is no method with this signature in parent to override"
If we'll comment static method in Test class then everything will be
compiled without any error.
======================================================================
----------------------------------------------------------------------
nazgul - 02-25-06 21:29
----------------------------------------------------------------------
Does it also happen when you are not using macros, but just define such
class manually?
----------------------------------------------------------------------
OysterDva - 02-25-06 21:33
----------------------------------------------------------------------
Yep - I've just checked it.
Btw, sorry if severity level will be too high - using mantis for the first
time :)
----------------------------------------------------------------------
nazgul - 02-25-06 21:37
----------------------------------------------------------------------
//t.cs
namespace NS
{
public class Test
{
virtual public object DoIt()
{
return null;
}
// Comment this method and error will go away
static public T DoIt<T>()
{
return default(T);
}
}
}
// t.n
public class TestInherit : NS.Test {
override public DoIt() : object { null }
}
Well, actually the problem is that your C# code should compile also under
Nemerle. It doesn't and it is a bug. The fact that compiler cannot
properly use such code is just a side effect of this bug.
----------------------------------------------------------------------
nazgul - 05-01-06 12:23
----------------------------------------------------------------------
Fixed on trunk (r6211).
Issue History
Date Modified Username Field Change
======================================================================
02-25-06 21:23 OysterDva New Issue
02-25-06 21:23 OysterDva File Added: src.txt
02-25-06 21:29 nazgul Note Added: 0001106
02-25-06 21:33 OysterDva Note Added: 0001107
02-25-06 21:37 nazgul Note Added: 0001108
02-25-06 21:37 nazgul Severity crash => minor
02-25-06 21:37 nazgul Category Compiler (parser/macros
engine) => Compiler
02-25-06 21:37 nazgul Description Updated
02-25-06 21:37 nazgul Additional Information Updated
05-01-06 12:23 nazgul Status new => resolved
05-01-06 12:23 nazgul Resolution open => fixed
05-01-06 12:23 nazgul Assigned To => nazgul
05-01-06 12:23 nazgul Note Added: 0001215
05-01-06 12:23 nazgul Description Updated
05-01-06 12:23 nazgul Additional Information Updated
05-22-06 18:05 nazgul Status resolved => closed
======================================================================
More information about the bugs
mailing list