diff --git a/rtl/objpas/typinfo.pp b/rtl/objpas/typinfo.pp index ca141875e1..5499f143ba 100644 --- a/rtl/objpas/typinfo.pp +++ b/rtl/objpas/typinfo.pp @@ -4622,7 +4622,7 @@ begin if Index >= ParamCount then Result := Nil else - Result := PVmtMethodParamArray(@params)[Index]; + Result := PVmtMethodParam(@params) + Index; end; function TVMTMethodExEntry.GetResultLocs: PParameterLocations; diff --git a/tests/webtbs/tw40595.pp b/tests/webtbs/tw40595.pp new file mode 100644 index 0000000000..d5714f0fb1 --- /dev/null +++ b/tests/webtbs/tw40595.pp @@ -0,0 +1,74 @@ +Program tw40595; + +{$mode OBJFPC}{$H+}{$M+} +{$Modeswitch advancedrecords} +{$RTTI EXPLICIT PROPERTIES([vcPrivate,vcProtected,vcPublic,vcPublished])} +{$RTTI EXPLICIT FIELDS([vcPrivate,vcProtected,vcPublic,vcPublished])} +{$RTTI EXPLICIT METHODS([vcPrivate,vcProtected,vcPublic,vcPublished])} + +Uses + SysUtils, + TypInfo; + +Type + { TUser } + + TUser = Class + Private + FName: string; + FID: Integer; + Public + Procedure PrintID; + Constructor Create; + Procedure PrintName; + Published + Property ID: Integer read FID write FID; + Property Name: string read FName write FName; + End; + + { TUser } + + Constructor TUser.Create; + Begin + FName := 'TUser.Name: ' + WChar($20A1) + ' ' + WChar($2211); + End; + + Procedure TUser.PrintID; + Begin + WriteLn('User ID : ', ID); + End; + + Procedure TUser.PrintName; + Begin + WriteLn('User Name : ', Name); + End; + +const + MethodNames: array of String = ( + 'PrintID', + 'Create', + 'PrintName' + ); +Var + I: Integer; + Count: LongInt; + Method: PVmtMethodExEntry; + Methods: PExtendedMethodInfoTable; +Begin + Count := GetMethodList(TUser, Methods, []); + If Methods <> nil Then + Begin + if Count <> Length(MethodNames) then + Halt(2); + For I := 0 To Pred(Count) Do + Begin + Method := Methods^[I]; + if Method^.Name <> MethodNames[i] then + Halt(3 + i); + WriteLn(Format('%-10s - %d', [Method^.Name, Method^.Kind])); + End; + Freemem(Methods); + End else + Halt(1); +End. +