@@ -462,6 +462,7 @@ class Checker {
462462 public var allowUntypedMeta : Bool ;
463463 public var allowPrivateAccess : Bool ;
464464 public var allowNew : Bool ;
465+ public var allowGlobalTypes : Bool ;
465466
466467 public function new ( ? types ) {
467468 if ( types == null ) types = new CheckerTypes ();
@@ -1125,7 +1126,7 @@ class Checker {
11251126 return null ;
11261127 }
11271128 var acc = mk (null ,e );
1128- var impl = resolveGlobal (a .impl .name ,acc ,Value ,false );
1129+ var impl = resolveGlobal (a .impl .name ,acc ,null /* skip resolveGlobal */ ,false );
11291130 if ( impl == null )
11301131 return null ;
11311132 var t = checkField (cf ,a ,pl ,forWrite ,e );
@@ -1241,7 +1242,7 @@ class Checker {
12411242 var ft = getField (ot , p .f , p .e , p == path [path .length - 1 ] ? forWrite : false );
12421243 if ( ft == null ) {
12431244 switch ( ot ) {
1244- case TInst (c , _ ) if ( c .name == " #Std" ):
1245+ case TInst (c , _ ) if ( c .name == " #Std" && allowGlobalTypes ):
12451246 // these two methods are extern in HL and we must provide
12461247 // some stubs so they both type and execute
12471248 switch ( p .f ) {
@@ -1378,7 +1379,7 @@ class Checker {
13781379 return TDynamic ;
13791380 default :
13801381 #if hscriptPos
1381- var wt = switch ( withType ) { case WithType (t ): follow (t ); default : null ; };
1382+ var wt = switch ( withType ) { case null : null ; case WithType (t ): follow (t ); default : null ; };
13821383 switch ( wt ) {
13831384 case null :
13841385 // enum constructor resolution
@@ -1400,7 +1401,7 @@ class Checker {
14001401 return wt ;
14011402 default :
14021403 }
1403- // this variable resolution
1404+ // this variable resolution : if we have a this, we can access it
14041405 var g = locals .get (" this" );
14051406 if ( g == null ) g = globals .get (" this" );
14061407 if ( g != null ) {
@@ -1440,7 +1441,7 @@ class Checker {
14401441 break ;
14411442 }
14421443 }
1443- if ( ! t .match (TUnresolved (_ )) ) {
1444+ if ( ! t .match (TUnresolved (_ )) && ( allowGlobalTypes || withType == null ) ) {
14441445 var acc = getTypeAccess (t , expr );
14451446 if ( acc != null ) {
14461447 expr .e = acc ;
@@ -1460,7 +1461,14 @@ class Checker {
14601461 }
14611462
14621463 function getTypeAccess ( t : TType , expr : Expr , ? field : String ) : ExprDef {
1463- return null ;
1464+ var path = switch ( t ) {
1465+ case TInst (c ,_ ): c .name ;
1466+ case TEnum (e ,_ ): e .name ;
1467+ default : return null ;
1468+ }
1469+ var e : hscript. Expr . ExprDef = ECall (mk (EIdent (" $resolve" ),expr ),[mk (EConst (CString (path )),expr )]);
1470+ if ( field != null ) e = EField (mk (e ,expr ),field );
1471+ return e ;
14641472 }
14651473
14661474 function unifyCallParams ( args : Array <{ name : String , opt : Bool , t : TType }>, params : Array <Expr >, pos : Expr ) {
0 commit comments