Browse Source

* raise an exception if routine to be invoked isn't static, but there's no parameter to be used as Self

git-svn-id: trunk@37386 -
svenbarth 7 years ago
parent
commit
98bb449945
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/rtl-objpas/src/inc/rtti.pp

+ 4 - 2
packages/rtl-objpas/src/inc/rtti.pp

@@ -341,6 +341,7 @@ resourcestring
   SErrCallConvNotSupported = 'Calling convention not supported: %s';
   SErrTypeKindNotSupported = 'Type kind is not supported: %s';
   SErrCallbackHandlerNil = 'Callback handler is Nil';
+  SErrMissingSelfParam = 'Missing self parameter';
 
 implementation
 
@@ -545,10 +546,11 @@ begin
   if aIsConstructor then
     raise ENotImplemented.Create(SErrInvokeNotImplemented);
 
-  { ToDo: what exactly is the purpose of IsStatic? }
   flags := [];
   if aIsStatic then
-    Include(flags, fcfStatic);
+    Include(flags, fcfStatic)
+  else if Length(aArgs) = 0 then
+    raise EInvocationError.Create(SErrMissingSelfParam);
 
   SetLength(funcargs, Length(aArgs));
   for i := Low(aArgs) to High(aArgs) do begin