Ver Fonte

Lua: Add extra check for Reflect.callMethod to see if the object argument is in fact a class

Justin Donaldson há 9 anos atrás
pai
commit
1ca5de338c
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      std/lua/_std/Reflect.hx

+ 4 - 2
std/lua/_std/Reflect.hx

@@ -66,8 +66,10 @@ import lua.Boot;
 			return func(o);
 			return func(o);
 		} else {
 		} else {
 			var new_args:lua.Table<Int,String> = untyped __lua_table__(o);
 			var new_args:lua.Table<Int,String> = untyped __lua_table__(o);
-			// Lua's table concat will skip the first element since it starts from 1
-			if (o != null){
+			if (o != null && Type.getClass(o) != null){
+				// if o is not null, it means we need to pass it as the "self"
+				// parameter.  However, we should also check to see if it's
+				// a valid class instance in the first place.
 				new_args[2] = args[0];
 				new_args[2] = args[0];
 			} else {
 			} else {
 				new_args[1] = args[0];
 				new_args[1] = args[0];