I have a code that fails to compile (boo from SVN):
======
import System;
class MyAttribute(Attribute):
def constructor(t):
pass
class K:
pass
[assembly:MyAttribute(typeof(K))]
======
BCE0015: Node 'K' has not been correctly processed.
When I replace typeof(K) with some string or integer literal - it
works.
When I replace typeof(K) with K, it works as well...
... BUT ...
The code presented is actually generated from a code generator that is based on CodeDOM. Boo's CodeGenerator produces "typeof(T)" for CodeTypeOfExpression(typeof(T)).
When I modify the CodeDOM provider to emit just "T" in this case:
Index: BooCodeGenerator.boo
===================================================================
— BooCodeGenerator.boo (revision 2308)
+++ BooCodeGenerator.boo (working copy)
@@ -92,6 +92,9 @@
protected override def GenerateBaseReferenceExpression(e as CodeBaseReferenceExpression) :
Output.Write("super")
+ protected override def GenerateTypeOfExpression(e as CodeTypeOfExpression) :
+ OutputType(e.Type)
+
protected override def GenerateCastExpression(e as CodeCastExpression) :
Output.Write("cast(")
OutputType(e.TargetType)
It works here but starts to fail in other places. The expression "typeof(K).Assembly" (written in C# syntax) becomes indistinguishable from K.Assembly which obviously fails, because K doesn't have a property named Assembly.
I'm not sure if this is a CodeDOM bug or compiler bug so I'm filing in both categories.