-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Description
@:generic methods fails when used in macros
Code examples
Direct use with thx import
using thx.Arrays;
class Test {
static function main() {
trace(checkCount());
}
macro static function checkCount() {
final arr = ['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
final count = thx.Arrays.count(arr);
return haxe.macro.Context.makeExpr(count, haxe.macro.Context.currentPos());
}
}fails with:
[ERROR] (unknown position)
| Field index for count_String not found on prototype thx.Arrays
Direct use with thx import (but different class)
using thx.Strings;
class Test {
static function main() {
trace(checkCount());
}
macro static function checkCount() {
final arr = ['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
final count = thx.Arrays.count(arr);
return haxe.macro.Context.makeExpr(count, haxe.macro.Context.currentPos());
}
}fails with:
[ERROR] (unknown position)
| Field index for count_String not found on prototype thx.Arrays
import + static extension
using thx.Arrays;
class Test {
static function main() {
trace(checkCount());
}
macro static function checkCount() {
final arr = ['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
final count = arr.count();
return haxe.macro.Context.makeExpr(count, haxe.macro.Context.currentPos());
}
}fails with:
[ERROR] (unknown position)
| Field index for count_String not found on prototype thx.Arrays
direct use without import
class Test {
static function main() {
trace(checkCount());
}
macro static function checkCount() {
final arr = ['a', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd'];
final count = thx.Arrays.count(arr);
return haxe.macro.Context.makeExpr(count, haxe.macro.Context.currentPos());
}
}success:
Test.hx:4:,[d => 4,c => 3,b => 2,a => 1]
Expected behavior
Method works direct and as static extension in macros, when importing any thx class
Metadata
Metadata
Assignees
Labels
No labels