waneck / testrepo

0 stars 0 forks source link

Issue 1843 - Context.getType fails inside of macro when "using" macro on a reference to the same class - haxe #1843

Open waneck opened 11 years ago

waneck commented 11 years ago

[Google Issue #1843 : http://code.google.com/haxe/issues/detail?id=1843] by domdelor...@gmail.com, at 2013-05-23T09:26:08.000Z What steps will reproduce the problem?

  1. Create a macro that takes an ExprOf<Class<T> and uses the value to look up the Type using Context.getType
  2. execute the macro on a Class reference via "using"

What is the expected output? What do you see instead?

The qualified name of the class expression is correctly identified from the expr, however the same class is not found within the Context.

Instead, throws compiler error:

/usr/lib/haxe/std/haxe/macro/Context.hx:133: characters 9-46 : Type not found 'Test.SomeClass'

Please complete the following class with minimal code reproducing the problem :

package;

if macro

import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; using haxe.macro.Tools;

end

using Test.SomeMacro;

class Test { public static function main() { SomeMacro.test(SomeClass);//works SomeClass.test();//fails } }

class SomeClass { public function new() {

} }

class SomeMacro { macro public static function test<T>(expr:ExprOf<Class<T>>):Expr { var id = expr.toString(); trace(id); trace(Context.getType(id)); return expr; } }

Please provide any additional information below.

Haxe3 RC2, OSX 10.8

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-05-23T10:15:13.000Z] Note that even without Context.getType this fails because the returned expression is "Test.SomeClass", which the resolution algorithm does not handle.

It's a bit too late to fix that for 3.0 sadly.