* fix conversion from Objective-C class/protocol to tvarrec (store in

vPointer) (mantis #36362)

git-svn-id: trunk@43594 -
This commit is contained in:
Jonas Maebe 2019-11-26 21:24:56 +00:00
parent cf0716123c
commit 5800ac6213
3 changed files with 37 additions and 3 deletions

1
.gitattributes vendored
View File

@ -15464,6 +15464,7 @@ tests/test/units/classes/ttbits.pp svneol=native#text/pascal
tests/test/units/classes/ttlist.pp svneol=native#text/plain
tests/test/units/classes/tvclcomobject.pp svneol=native#text/plain
tests/test/units/cocoaall/tw35994.pp svneol=native#text/plain
tests/test/units/cocoaall/tw36362.pp svneol=native#text/plain
tests/test/units/cpu/tcpu1.pp svneol=native#text/pascal
tests/test/units/crt/tcrt.pp svneol=native#text/plain
tests/test/units/crt/tctrlc.pp svneol=native#text/plain

View File

@ -843,10 +843,12 @@ implementation
if iscvarargs then
p:=ctypeconvnode.create(p,voidpointertype);
objectdef :
if (iscvarargs and
not is_objc_class_or_protocol(p.resultdef)) or
if is_objc_class_or_protocol(p.resultdef) then
p:=ctypeconvnode.create(p,voidpointertype)
else if iscvarargs or
is_object(p.resultdef) then
CGMessagePos1(p.fileinfo,type_e_wrong_type_in_array_constructor,p.resultdef.typename);
CGMessagePos1(p.fileinfo,type_e_wrong_type_in_array_constructor,p.resultdef.typename)
else
else
CGMessagePos1(p.fileinfo,type_e_wrong_type_in_array_constructor,p.resultdef.typename);
end;

View File

@ -0,0 +1,31 @@
{$mode objfpc}
{$modeswitch objectivec2}
program test;
uses
CocoaAll;
type
tc = objcclass(NSObject)
a: char;
end;
operator := (const right: array of const): NSMutableArray;
begin
if tc(right[0].vPointer).a<>'a' then
halt(1);
result:=NSMutableArray.alloc.initWithCapacity(1);
result.addObject(tc(right[0].vPointer));
end;
var
c: tc;
a: NSMutableArray;
begin
c:=tc.alloc.init;
c.a:='a';
a := [c];
for c in a do
if c.a<>'a' then
halt(2);
end.