Skip to content

Commit f15f70d

Browse files
committed
added imports and other fixes
1 parent da4bea6 commit f15f70d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

hscript/Checker.hx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ class Checker {
454454
var allowDefine : Bool;
455455
var hasReturn : Bool;
456456
var callExpr : Expr;
457+
public var imports : Array<String> = [];
457458
public var checkPrivate : Bool = true;
458459
public var allowAsync : Bool;
459460
public var allowReturn : Null<TType>;
@@ -831,7 +832,7 @@ class Checker {
831832
if( f2.opt ) continue;
832833
return false;
833834
}
834-
if( !typeEq(f1.t,f2.t) )
835+
if( !typeEq(f1.t,f2.t) && follow(f1.t) != TDynamic && follow(f2.t) != TDynamic )
835836
return false;
836837
}
837838
return true;
@@ -1420,14 +1421,25 @@ class Checker {
14201421
var acc = getTypeAccess(g, expr, name);
14211422
if( acc != null ) {
14221423
expr.e = acc;
1423-
return checkField(f,c,[for( a in f.params ) makeMono()], forWrite, expr);
1424+
var prev = checkPrivate;
1425+
checkPrivate = false;
1426+
var t = checkField(f,c,[for( a in f.params ) makeMono()], forWrite, expr);
1427+
checkPrivate = prev;
1428+
return t;
14241429
}
14251430
}
14261431
default:
14271432
}
14281433
}
14291434
// type path resolution
14301435
var t = types.getType(name);
1436+
if( t.match(TUnresolved(_)) && name.indexOf('.') < 0 ) {
1437+
for( i in imports ) {
1438+
t = types.getType(i+"."+name);
1439+
if( !t.match(TUnresolved(_)) )
1440+
break;
1441+
}
1442+
}
14311443
if( !t.match(TUnresolved(_)) ) {
14321444
var acc = getTypeAccess(t, expr);
14331445
if( acc != null ) {
@@ -1832,8 +1844,8 @@ class Checker {
18321844
typeExpr(e1,Value);
18331845
var ct = typeExpr(e2,Value);
18341846
switch( ct ) {
1835-
case TType(t,_) if( t.name.charCodeAt(0) == "#".code ):
1836-
// type check
1847+
case TInst(c,_) if( c.name.charCodeAt(0) == "#".code ): // class
1848+
case TType(t,_) if( t.name.charCodeAt(0) == "#".code ): // enum
18371849
default:
18381850
error("Should be a type",e2);
18391851
}

0 commit comments

Comments
 (0)