Столкнулся с проблемой явной реализации интерфейсов в генерируемых типах.
Использование такого макроса:
using Nemerle;
using Nemerle.Compiler;
using PT = Nemerle.Compiler.Parsetree;
namespace MacroLibrary1
{
public macro Macro1()
{
Macro1Impl.BuildMacro1(Macros.ImplicitCTX())
}
module Macro1Impl
{
public BuildMacro1(typer : Typer) : PT.PExpr
{
def name = Macros.NewSymbol("ty");
def ty = typer.Env.Define(<[ decl:
internal class $(name : name) { }
]>);
ty.AddImplementedInterface(<[ MacroLibrary1.ITest ]>);
ty.Define(<[ decl:
Str : string implements MacroLibrary1.ITest { get { $(name.Id : string) } }
]>);
ty.Compile();
<[ $(name : name)( ) : MacroLibrary1.ITest ]>
}
}
public interface ITest {
Str : string { get; }
}
}
using System;
using System.Console;
using Nemerle.Utility;
module Program
{
Main() : void
{
def t = MacroLibrary1.Macro1();
WriteLine(t.Str);
}
}
Сносит башку компилятору с криком:
------ Rebuild All started: Project: MacroLibrary1, Configuration: Debug Any CPU ------
ReBuild succeeded -- 0 warnings. Build took: 00:00:00.8864445.
------ Rebuild All started: Project: ConsoleApplication40, Configuration: Debug Any CPU ------
C:\Documents and Settings\smatveev\My Documents\Visual Studio 2008\Projects\ConsoleApplication40\ConsoleApplication40\Main.n(9,13):Error: AssertionException has occurred when expanding macro 'MacroLibrary1.Macro1'
C:\Documents and Settings\smatveev\My Documents\Visual Studio 2008\Projects\ConsoleApplication40\ConsoleApplication40\Main.n(9,13):Error: AssertionException has occurred when expanding macro 'MacroLibrary1.Macro1'
C:\Documents and Settings\smatveev\My Documents\Visual Studio 2008\Projects\ConsoleApplication40\ConsoleApplication40\Main.n(9,13):Error: the meaning of 'MacroLibrary1.Macro1' does not allow this operation
ReBuild failed -- 3 errors, 0 warnings. Build took: 00:00:01.4749930.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========