[nem-bug] [Nemerle 0000776]: Can't Define virtual & override methods (in macro)

feedback at nemerle.org feedback at nemerle.org
Sun Oct 8 15:51:40 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=776> 
======================================================================
Reported By:                VladD2
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   776
Category:                   Compiler (type engine)
Reproducibility:            always
Severity:                   block
Priority:                   urgent
Status:                     new
======================================================================
Date Submitted:             10-05-2006 01:59 CEST
Last Modified:              10-08-2006 15:51 CEST
======================================================================
Summary:                    Can't Define virtual & override methods (in macro)
Description: 
Macro code:
----------------------------------------------------------------------------
using Nemerle.Compiler;

[Nemerle.MacroUsage (Nemerle.MacroPhase.WithTypedMembers,
                     Nemerle.MacroTargets.Class)]
macro AddVirtualTestImpl (tb : TypeBuilder)
{
  tb.Define (<[ decl: 
    internal virtual TestImpl () : void
    {
    }
  ]>);
}

[Nemerle.MacroUsage (Nemerle.MacroPhase.WithTypedMembers,
                     Nemerle.MacroTargets.Class)]
macro AddOverrideTestImpl (tb : TypeBuilder)
{
  tb.Define (<[ decl: 
    internal override TestImpl () : void
    {
    }
  ]>);
}
----------------------------------------------------------------------------
Code use macro:
----------------------------------------------------------------------------
[AddVirtualTestImpl]
class A { }

[AddOverrideTestImpl]
class B : A { }
----------------------------------------------------------------------------
Error message:
----------------------------------------------------------------------------
Main.n(4,2,4,21): error : `override' specified on method B.TestImpl() :
void, but there is no such member in parent to override
======================================================================

----------------------------------------------------------------------
 malekith - 10-05-06 07:46 
----------------------------------------------------------------------
It's by design.

You need to add virtual memebers in the BeforeInheritance stage, not
WithTypedMembers. Otherwise they are not visible in derived class.

We can maybe turn this issue into feature request to allow this also at
later stages. Is BeforeInheritenance a problem for you?

----------------------------------------------------------------------
 nazgul - 10-08-06 15:51 
----------------------------------------------------------------------
I agree, we do not allow adding virtual members during WithTypedMembers
stage. Changing this would require lots of refactoring of "override" and
virtual methods handling.
And the solution is quite simple - just add virtual members in
BeforeTypedMembers stage.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
10-05-06 01:59 VladD2         New Issue                                    
10-05-06 07:46 malekith       Note Added: 0001467                          
10-08-06 15:51 nazgul         Note Added: 0001469                          
======================================================================




More information about the bugs mailing list