Skip to content

Commit 04e7d65

Browse files
committed
allow access to abstract forwarded fields
1 parent ce81886 commit 04e7d65

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hscript/Checker.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ typedef CAbstract = {> CNamedType,
7979
var t : TType;
8080
var from : Array<TType>;
8181
var to : Array<TType>;
82+
var forwards : Map<String,Bool>;
8283
}
8384

8485
class Completion {
@@ -237,6 +238,7 @@ class CheckerTypes {
237238
t : null,
238239
from : [],
239240
to : [],
241+
forwards : new Map(),
240242
};
241243
addMeta(a,ta);
242244
for( p in a.params )
@@ -250,6 +252,11 @@ class CheckerTypes {
250252
for( t in a.to )
251253
if( t.field == null )
252254
ta.to.push(makeXmlType(t.t));
255+
for( m in a.meta )
256+
if( m.name == ":forward" && m.params != null ) {
257+
for( i in m.params )
258+
ta.forwards.set(i, true);
259+
}
253260
localParams = null;
254261
});
255262
types.set(a.path, CTAbstract(ta));
@@ -855,6 +862,11 @@ class Checker {
855862
case TFun(args, ret):
856863
if( isCompletion )
857864
fields.push({ name : "bind", t : TFun(args,TVoid) });
865+
case TAbstract(a,pl):
866+
for( v in a.forwards.keys() ) {
867+
var t = getField(apply(a.t, a.params, pl), v, null, false);
868+
fields.push({ name : v, t : t});
869+
}
858870
default:
859871
}
860872
return fields;
@@ -899,6 +911,8 @@ class Checker {
899911
if( af.name == f )
900912
return af.t;
901913
return null;
914+
case TAbstract(a,pl) if( a.forwards.exists(f) ):
915+
return getField(apply(a.t, a.params, pl), f, e, forWrite);
902916
default:
903917
return null;
904918
}

0 commit comments

Comments
 (0)