Skip to content

Commit 276b05e

Browse files
committed
RuleScriptedClass bugfix #2 (inline error)
Fixed bug with override inline methods.
1 parent 2e07e80 commit 276b05e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

rulescript/macro/RuleScriptedClass.hx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,18 @@ class RuleScriptedClass
2222
var curType = Context.getLocalClass().get();
2323

2424
var constructor = curType.constructor?.get();
25+
26+
var inlinedFields:Array<String> = [];
2527
while (curType != null)
2628
{
2729
for (field in curType.fields.get())
2830
{
29-
if (!typefields.exists(field.name) && !field.isFinal && field.kind.match(FMethod(_)) && !field.kind.match(FMethod(MethInline)))
31+
if (!inlinedFields.contains(field.name) && field.kind.match(FMethod(MethInline)))
32+
{
33+
inlinedFields.push(field.name);
34+
}
35+
36+
if (!typefields.exists(field.name) && !field.isFinal && field.kind.match(FMethod(_)) && !inlinedFields.contains(field.name))
3037
typefields.set(field.name, field);
3138
}
3239
curType = curType.superClass?.t.get();

test/scripts/haxe/ScriptedClass.rhx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ class ScriptedClass extends ScriptedClassTest
4343
}
4444

4545
public function stringArray(arg:Array<T>){
46-
return 'Script: stringArray -' + Std.string(arg);
46+
return 'Script: stringArray - ' + Std.string(arg);
4747
}
4848
}

test/src/test/ScriptedClassTest.hx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,12 @@ class SrcClassTest<T:Hello<K>, K>
6767
public static function staticField() {}
6868
}
6969

70-
class SrcClassTest2 extends SrcClassTest<Hello<Dynamic>, Dynamic> {}
70+
class SrcClassTest2 extends SrcClassTest<Hello<Dynamic>, Dynamic>
71+
{
72+
inline override public function t(arg:Hello<Dynamic>):Hello<Dynamic>
73+
{
74+
return arg;
75+
}
76+
}
77+
7178
class ScriptedClassTest implements RuleScriptedClass extends SrcClassTest2 {}

0 commit comments

Comments
 (0)