diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index aafa49f37f..bb6f45ae67 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -990,7 +990,8 @@ implementation pd : tprocdef; locationstr: string; old_parse_generic, - popclass : boolean; + popclass: boolean; + old_current_objectdef: tobjectdef; begin locationstr:=''; pd:=nil; @@ -1016,10 +1017,15 @@ implementation symtablestack.push(pd._class.symtable); popclass:=true; parse_generic:=(df_generic in pd._class.defoptions); + old_current_objectdef:=current_objectdef; + current_objectdef:=pd._class; end; single_type(pd.returndef,false,false); if popclass then - symtablestack.pop(pd._class.symtable); + begin + current_objectdef:=old_current_objectdef; + symtablestack.pop(pd._class.symtable); + end; dec(testcurobject); parse_generic:=old_parse_generic; diff --git a/tests/test/tclass12c.pp b/tests/test/tclass12c.pp index 3aec751ea3..eaa230d9b2 100644 --- a/tests/test/tclass12c.pp +++ b/tests/test/tclass12c.pp @@ -15,6 +15,7 @@ type FPrivateField: PrivateType; public procedure DoSomething(Value: PrivateType = PrivateConst); + function ReturnSomething: PrivateType; property SomeProp: PrivateType read FPrivateField write FPrivateField default PrivateConst; end; @@ -22,5 +23,10 @@ type begin end; + function TSomeClass.ReturnSomething: PrivateType; + begin + Result := PrivateConst; + end; + begin end. \ No newline at end of file