patch 8.2.4575: Vim9: test for profiling still fails

Problem:    Vim9: test for profiling still fails.
Solution:   Update flags for profiling and breakpoints when obtaining the
            compile type.  Do not set the FC_CLOSURE flag for a toplevel
            function.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index d8119c5..fa5f067 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -913,8 +913,7 @@
 	}
     }
 
-    update_has_breakpoint(ufunc);
-    compile_type = COMPILE_TYPE(ufunc);
+    compile_type = get_compile_type(ufunc);
 #ifdef FEAT_PROFILE
     // If the outer function is profiled, also compile the nested function for
     // profiling.
@@ -2475,6 +2474,30 @@
     return r;
 }
 
+/*
+ * Get the compilation type that should be used for "ufunc".
+ * Keep in sync with INSTRUCTIONS().
+ */
+    compiletype_T
+get_compile_type(ufunc_T *ufunc)
+{
+    // Update uf_has_breakpoint if needed.
+    update_has_breakpoint(ufunc);
+
+    if (debug_break_level > 0 || may_break_in_function(ufunc))
+	return CT_DEBUG;
+#ifdef FEAT_PROFILE
+    if (do_profiling == PROF_YES)
+    {
+	if (!ufunc->uf_profiling && has_profiling(FALSE, ufunc->uf_name, NULL))
+	    func_do_profile(ufunc);
+	if (ufunc->uf_profiling)
+	    return CT_PROFILE;
+    }
+#endif
+    return CT_NONE;
+}
+
 
 /*
  * Add a function to the list of :def functions.