Browse Source

Remove try/catch from JS __instanceof.

I had to tweak the patch a bit to get the unit tests to pass. Closes
issue 1685.
Bruno Garcia 12 years ago
parent
commit
04d7c350c5
1 changed files with 3 additions and 4 deletions
  1. 3 4
      std/js/Boot.hx

+ 3 - 4
std/js/Boot.hx

@@ -161,7 +161,9 @@ class Boot {
 
 
 	@:ifFeature("typed_catch") private static function __instanceof(o : Dynamic,cl) {
 	@:ifFeature("typed_catch") private static function __instanceof(o : Dynamic,cl) {
 		untyped {
 		untyped {
-			try {
+			if( cl == null )
+				return false;
+			if( o != null && __js__("typeof(cl)") == "function" ) {
 				if( __js__("o instanceof cl") ) {
 				if( __js__("o instanceof cl") ) {
 					if( cl == Array )
 					if( cl == Array )
 						return (o.__enum__ == null);
 						return (o.__enum__ == null);
@@ -169,9 +171,6 @@ class Boot {
 				}
 				}
 				if( __interfLoop(js.Boot.getClass(o),cl) )
 				if( __interfLoop(js.Boot.getClass(o),cl) )
 					return true;
 					return true;
-			} catch( e : Dynamic ) {
-				if( cl == null )
-					return false;
 			}
 			}
 			switch( cl ) {
 			switch( cl ) {
 			case Int:
 			case Int: