* use iscurrentunit only when there isn't a suitable def that the moduleid of the symtables can be compared to

This commit is contained in:
Sven/Sarah Barth 2024-02-09 17:22:46 +01:00
parent ddc2259e5e
commit ed8a05d697

View File

@ -3245,6 +3245,22 @@ implementation
objfield.fieldname:=1 -> contextobjdef = def of objfield objfield.fieldname:=1 -> contextobjdef = def of objfield
} }
function is_visible_for_object(symst:tsymtable;symvisibility:tvisibility;contextobjdef:tabstractrecorddef):boolean; function is_visible_for_object(symst:tsymtable;symvisibility:tvisibility;contextobjdef:tabstractrecorddef):boolean;
function is_current_unit(st:tsymtable):boolean;
begin
result :=
(
(
assigned(current_structdef) and
(st.moduleid=current_structdef.symtable.moduleid)
) or
(
not assigned(current_structdef) and
st.iscurrentunit
)
);
end;
var var
symownerdef : tabstractrecorddef; symownerdef : tabstractrecorddef;
nonlocalst : tsymtable; nonlocalst : tsymtable;
@ -3276,7 +3292,7 @@ implementation
module as they are defined } module as they are defined }
result:=( result:=(
(nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and (nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and
(nonlocalst.iscurrentunit) is_current_unit(nonlocalst)
) or ) or
( // the case of specialize inside the generic declaration and nested types ( // the case of specialize inside the generic declaration and nested types
(nonlocalst.symtabletype in [objectsymtable,recordsymtable]) and (nonlocalst.symtabletype in [objectsymtable,recordsymtable]) and
@ -3284,7 +3300,7 @@ implementation
assigned(current_structdef) and assigned(current_structdef) and
( (
(current_structdef=symownerdef) or (current_structdef=symownerdef) or
(current_structdef.owner.iscurrentunit) (current_structdef.owner.moduleid=symownerdef.symtable.moduleid)
) )
) or ) or
( (
@ -3345,12 +3361,12 @@ implementation
result:=( result:=(
( (
(nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and (nonlocalst.symtabletype in [globalsymtable,staticsymtable]) and
(nonlocalst.iscurrentunit) is_current_unit(nonlocalst)
) or ) or
( (
assigned(contextobjdef) and assigned(contextobjdef) and
(contextobjdef.owner.symtabletype in [globalsymtable,staticsymtable,ObjectSymtable,recordsymtable,localsymtable]) and (contextobjdef.owner.symtabletype in [globalsymtable,staticsymtable,ObjectSymtable,recordsymtable,localsymtable]) and
(contextobjdef.owner.iscurrentunit) and is_current_unit(contextobjdef.owner) and
def_is_related(contextobjdef,symownerdef) def_is_related(contextobjdef,symownerdef)
) or ) or
( // the case of specialize inside the generic declaration and nested types ( // the case of specialize inside the generic declaration and nested types
@ -3359,7 +3375,7 @@ implementation
assigned(current_structdef) and assigned(current_structdef) and
( (
(current_structdef=symownerdef) or (current_structdef=symownerdef) or
(current_structdef.owner.iscurrentunit) (current_structdef.owner.moduleid=symownerdef.symtable.moduleid)
) )
) or ) or
( (