Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:27:17+00:00 2026-05-27T08:27:17+00:00

I am using Delphi XE. The following unit fails to compile with this error:

  • 0

I am using Delphi XE.

The following unit fails to compile with this error:

[DCC Error] GTSJSONSerializer.pas(27): E2506 Method of parameterized type declared 
   in interface section must not use 
   local symbol 'TSuperRttiContext.AsJson<GTSJSONSerializer.TGTSJSONSerializer<T>.T>'

Why is that? Is there a workaround?

unit GTSJSONSerializer;

interface

type
   TGTSJSONSerializer<T> = class
     class function SerializeObjectToJSON(const aObject: T): string;
     class function DeserializeJSONToObject(const aJSON: string): T;
   end;

implementation

uses
        SuperObject
      ;

class function TGTSJSONSerializer<T>.SerializeObjectToJSON(const aObject: T): string;
var
  SRC: TSuperRttiContext;
begin
  SRC := TSuperRttiContext.Create;
  try
    Result := SRC.AsJson<T>(aObject).AsString;
  finally
    SRC.Free;
  end;
end;

class function TGTSJSONSerializer<T>.DeserializeJSONToObject(const aJSON: string): T;
var
  LocalSO: ISuperObject;
  SRC: TSuperRttiContext;
begin
  SRC := TSuperRttiContext.Create;
  try
    LocalSO :=  SO(aJSON);
    Result := SRC.AsType<T>(LocalSO);
  finally
    SRC.Free;
  end;
end;

end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:27:17+00:00Added an answer on May 27, 2026 at 8:27 am

    From the XE2 DocWiki:

    This happens when trying to assign a literal value to a generics data field.

    program E2506;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils;
    
    type
      TRec<T> = record
      public
        class var x: Integer;
        class constructor Create;
      end;
    
    class constructor TRec<T>.Create;
    begin
      x := 4; // <-- e2506 Fix: overload the Create method to 
              // take one parameter x and assign it to the x field.
    end;
    
    begin
       Writeln('E2506 Method of parameterized type declared' +
               ' in interface section must not use local symbol');
    end.
    

    I can’t tell which of the local variables it might be objecting to, though; you have one local in SerialObjectToJSON and two in DeserializeJSONToObject. I’m also not sure based on the linked fix exactly how that applies to the code you posted. Could it be related to TSuperRTTIContext?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is for Delphi Prism. Say, I have the following enum SET type that
Please forgive the verbosity of the following code example. Using Delphi 2009, I created
I'm trying to get the Global Interface Table by using the following code (Delphi):
I am using Delphi TApplication.OnException Event to catch unhandled exceptions This works well but
Using Delphi 2007 I can write the following code: interface TTestType = (ttTest1, ttTest2);
I have a file that was written with the following Delphi declaration ... Type
I am using Delphi, but this is a simple and general problem: I'm doing
(Using Delphi 5) I am attempting to open a log file using the following
I'm translating the following C++ component to Delphi: http://borland.newsgroups.archived.at/public.delphi.vcl.components.using.win32/200708/0708225318.html But it's not working... I'm
I'm using Delphi 2007 and I wonder how the following problem can be solved:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.