Index: generic/nsf.c =================================================================== diff -u -r86becbe05373b722fe093ffe5a4a1c19d1ebd76d -r4e48f1044506977558e55e4e40138cf876b9609f --- generic/nsf.c (.../nsf.c) (revision 86becbe05373b722fe093ffe5a4a1c19d1ebd76d) +++ generic/nsf.c (.../nsf.c) (revision 4e48f1044506977558e55e4e40138cf876b9609f) @@ -13294,6 +13294,47 @@ subMethodCmd = NULL; } +#if 1 + if (subMethodCmd != NULL) { + unsigned long cmdFlags = (unsigned long)Tcl_Command_flags(subMethodCmd); + if (unlikely((cmdFlags & NSF_CMD_CALL_PROTECTED_METHOD) != 0u)) { + NsfObject *lastSelf; + Tcl_CallFrame *framePtr; + int withinEnsemble = ((cscPtr->frameType & NSF_CSC_TYPE_ENSEMBLE) != 0u); + + if (withinEnsemble) { + Tcl_CallFrame *framePtr1; + /* Alternatively: (void)NsfCallStackFindLastInvocation(interp, 0, &framePtr1); */ + (void)CallStackGetTopFrame(interp, &framePtr); + (void)CallStackFindEnsembleCsc(framePtr, &framePtr1); + /* NsfShowStack(interp); + fprintf(stderr, "framePtr %p\n", framePtr1);*/ + if (framePtr1 != NULL) { + lastSelf = GetSelfObj2(interp, framePtr1); + } else { + lastSelf = NULL; + } + } else { + lastSelf = GetSelfObj(interp); + } + + + /* fprintf(stderr, "'%s (%s) == %s == %s? for %s\n", lastSelf != NULL ? ObjectName(lastSelf): "n/a", + ObjectName(GetSelfObj(interp)), ObjectName(actualSelf), ObjectName(invokedObject), subMethodName); */ + + if (actualSelf != lastSelf) { + const char *path = withinEnsemble ? ObjStr(NsfMethodNamePath(interp, framePtr, methodName)) : methodName; + + NsfLog(interp, NSF_LOG_WARN, "'%s %s %s' fails since method %s.%s %s is protected", + ObjectName(actualSelf), path, subMethodName, (actualClass != NULL) ? + ClassName(actualClass) : ObjectName(actualSelf), path, subMethodName); + subMethodCmd = NULL; + } + } + } +#endif + + /* * Make sure, that the current call is marked as an ensemble call, both * for dispatching to the default-method and for dispatching the method