diff --git a/.gitattributes b/.gitattributes index 496f92b774..8a8756db59 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8191,6 +8191,7 @@ tests/webtbs/tw10757.pp svneol=native#text/plain tests/webtbs/tw10768.pp svneol=native#text/plain tests/webtbs/tw10790.pp svneol=native#text/plain tests/webtbs/tw10791.pp svneol=native#text/plain +tests/webtbs/tw10795.pp svneol=native#text/plain tests/webtbs/tw10800.pp svneol=native#text/plain tests/webtbs/tw10807.pp svneol=native#text/plain tests/webtbs/tw1081.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 7182b96334..8b5c8a7f8c 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1836,7 +1836,7 @@ implementation _LECKKLAMMER: begin - if is_class_or_interface(p1.resultdef) then + if is_class_or_interface_or_object(p1.resultdef) then begin { default property } protsym:=search_default_property(tobjectdef(p1.resultdef)); diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 48276c10b9..4c09e46408 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -673,6 +673,7 @@ interface function is_class(def: tdef): boolean; function is_cppclass(def: tdef): boolean; function is_class_or_interface(def: tdef): boolean; + function is_class_or_interface_or_object(def: tdef): boolean; function is_class_or_interface_or_dispinterface(def: tdef): boolean; @@ -4369,6 +4370,7 @@ implementation (tobjectdef(def).objecttype=odt_class); end; + function is_object(def: tdef): boolean; begin is_object:= @@ -4377,6 +4379,7 @@ implementation (tobjectdef(def).objecttype=odt_object); end; + function is_cppclass(def: tdef): boolean; begin is_cppclass:= @@ -4385,15 +4388,25 @@ implementation (tobjectdef(def).objecttype=odt_cppclass); end; + function is_class_or_interface(def: tdef): boolean; begin - is_class_or_interface:= + result:= assigned(def) and (def.typ=objectdef) and (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba]); end; + function is_class_or_interface_or_object(def: tdef): boolean; + begin + result:= + assigned(def) and + (def.typ=objectdef) and + (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba,odt_object]); + end; + + function is_class_or_interface_or_dispinterface(def: tdef): boolean; begin result:= diff --git a/tests/webtbs/tw10795.pp b/tests/webtbs/tw10795.pp new file mode 100644 index 0000000000..716b643cd6 --- /dev/null +++ b/tests/webtbs/tw10795.pp @@ -0,0 +1,18 @@ +{$mode objfpc} +type + TObj = object + function GetItem(const i :Integer) :Integer; + property Items[i :Integer] :Integer read GetItem; default; + end; + +function TObj.GetItem(const i :Integer) :Integer; +begin + Result := i; +end; + +var + Obj :TObj; + +begin + WriteLn(Obj[0],' ',Obj[10]); +end. \ No newline at end of file