patch 9.0.1888: Vim9: Problem trying to invoke class method

Problem:  Vim9: Problem trying to invoke class method
Solution: Lookup the class method insider other classes

closes: #13055

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 3817e38..883219e 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -775,6 +775,8 @@
 	    }
 	    else if ((idx = class_member_index(*arg, len, &cl, cctx)) >= 0)
 	    {
+		// Referencing a class member without the class name.  Infer
+		// the class from the def function context.
 		res = generate_CLASSMEMBER(cctx, TRUE, cl, idx);
 	    }
 	    else
@@ -1118,6 +1120,9 @@
     if (lookup_local(namebuf, varlen, NULL, cctx) == FAIL
 	    && arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK)
     {
+	class_T		*cl = NULL;
+	int		mi = 0;
+
 	// If we can find the function by name generate the right call.
 	// Skip global functions here, a local funcref takes precedence.
 	ufunc = find_func(name, FALSE);
@@ -1136,6 +1141,16 @@
 		goto theend;
 	    }
 	}
+	else if ((mi = class_method_index(name, varlen, &cl, cctx)) >= 0)
+	{
+	    // Class method invocation without the class name.  The
+	    // generate_CALL() function expects the class type at the top of
+	    // the stack.  So push the class type to the stack.
+	    push_type_stack(cctx, &t_class);
+	    res = generate_CALL(cctx, cl->class_class_functions[mi], NULL, 0,
+							type, argcount);
+	    goto theend;
+	}
     }
 
     // If the name is a variable, load it and use PCALL.