Error in TValueHelper.TryGetLazyValue

Issue #375 resolved
João Antônio Duarte created an issue

When trying to get the value of an instance of a class of a Lazy type I get the exception 'Interface not supported.'

The code snippet below throws this exception:

var
  lazyType: Lazy<TStringStream>;
  lazyTypeValue: TValue;
  lazyValue: TValue;
begin
  lazyType := Lazy<TStringStream>.Create(
    function: TStringStream
    begin
      Result := TStringStream.Create;
    end, True);
  lazyType.Value.WriteString('Some text');

  lazyTypeValue := TValue.From<Lazy<TStringStream>>(lazyType);
  if IsLazyType(lazyTypeValue.TypeInfo) then
  begin
    lazyTypeValue.TryGetLazyValue(lazyValue); // <- Exception raised here
  end;
end;

Comments (3)

  1. Log in to comment