mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 15:10:41 +02:00
* properly handle virtual/override for Java classes, instead of semi-forcing
treating all methods as if they are declared virtual on the JVM platform git-svn-id: branches/jvmbackend@18447 -
This commit is contained in:
parent
2514c4ddb1
commit
921b54f9fb
@ -1657,9 +1657,7 @@ begin
|
|||||||
if assigned(tprocdef(pd).struct) and
|
if assigned(tprocdef(pd).struct) and
|
||||||
(oo_is_sealed in tprocdef(pd).struct.objectoptions) then
|
(oo_is_sealed in tprocdef(pd).struct.objectoptions) then
|
||||||
Message(parser_e_sealed_class_cannot_have_abstract_methods)
|
Message(parser_e_sealed_class_cannot_have_abstract_methods)
|
||||||
else if (po_virtualmethod in pd.procoptions) or
|
else if (po_virtualmethod in pd.procoptions) then
|
||||||
{ all Java methods are virtual }
|
|
||||||
is_javaclass(tdef(pd.owner.defowner)) then
|
|
||||||
include(pd.procoptions,po_abstractmethod)
|
include(pd.procoptions,po_abstractmethod)
|
||||||
else
|
else
|
||||||
Message(parser_e_only_virtual_methods_abstract);
|
Message(parser_e_only_virtual_methods_abstract);
|
||||||
@ -1674,9 +1672,7 @@ begin
|
|||||||
if is_objectpascal_helper(tprocdef(pd).struct) and
|
if is_objectpascal_helper(tprocdef(pd).struct) and
|
||||||
(m_objfpc in current_settings.modeswitches) then
|
(m_objfpc in current_settings.modeswitches) then
|
||||||
Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_FINAL].str);
|
Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_FINAL].str);
|
||||||
if (po_virtualmethod in pd.procoptions) or
|
if (po_virtualmethod in pd.procoptions) then
|
||||||
{ all Java methods are virtual }
|
|
||||||
is_javaclass(tdef(pd.owner.defowner)) then
|
|
||||||
include(pd.procoptions,po_finalmethod)
|
include(pd.procoptions,po_finalmethod)
|
||||||
else
|
else
|
||||||
Message(parser_e_only_virtual_methods_final);
|
Message(parser_e_only_virtual_methods_final);
|
||||||
@ -1716,6 +1712,11 @@ var
|
|||||||
pt : tnode;
|
pt : tnode;
|
||||||
{$endif WITHDMT}
|
{$endif WITHDMT}
|
||||||
begin
|
begin
|
||||||
|
if (not assigned(pd.owner.defowner) or
|
||||||
|
not is_java_class_or_interface(tdef(pd.owner.defowner))) and
|
||||||
|
(po_external in pd.procoptions) then
|
||||||
|
Message1(parser_e_proc_dir_conflict,'EXTERNAL');
|
||||||
|
|
||||||
if pd.typ<>procdef then
|
if pd.typ<>procdef then
|
||||||
internalerror(2003042610);
|
internalerror(2003042610);
|
||||||
if (pd.proctypeoption=potype_constructor) and
|
if (pd.proctypeoption=potype_constructor) and
|
||||||
@ -1778,7 +1779,7 @@ begin
|
|||||||
if m_objfpc in current_settings.modeswitches then
|
if m_objfpc in current_settings.modeswitches then
|
||||||
Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_OVERRIDE].str)
|
Message1(parser_e_not_allowed_in_helper, arraytokeninfo[_OVERRIDE].str)
|
||||||
end
|
end
|
||||||
else if not(is_class_or_interface_or_objc(tprocdef(pd).struct)) then
|
else if not(is_class_or_interface_or_objc_or_java(tprocdef(pd).struct)) then
|
||||||
Message(parser_e_no_object_override)
|
Message(parser_e_no_object_override)
|
||||||
else if is_objccategory(tprocdef(pd).struct) then
|
else if is_objccategory(tprocdef(pd).struct) then
|
||||||
Message(parser_e_no_category_override)
|
Message(parser_e_no_category_override)
|
||||||
@ -2498,13 +2499,13 @@ const
|
|||||||
mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
|
mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
|
||||||
),(
|
),(
|
||||||
idtok:_VIRTUAL;
|
idtok:_VIRTUAL;
|
||||||
pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
|
pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord,pd_javaclass];
|
||||||
handler : @pd_virtual;
|
handler : @pd_virtual;
|
||||||
pocall : pocall_none;
|
pocall : pocall_none;
|
||||||
pooption : [po_virtualmethod];
|
pooption : [po_virtualmethod];
|
||||||
mutexclpocall : [pocall_internproc];
|
mutexclpocall : [pocall_internproc];
|
||||||
mutexclpotype : [potype_class_constructor,potype_class_destructor];
|
mutexclpotype : [potype_class_constructor,potype_class_destructor];
|
||||||
mutexclpo : [po_external,po_interrupt,po_exports,po_overridingmethod,po_inline]
|
mutexclpo : [po_interrupt,po_exports,po_overridingmethod,po_inline]
|
||||||
),(
|
),(
|
||||||
idtok:_CPPDECL;
|
idtok:_CPPDECL;
|
||||||
pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
|
pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
|
||||||
|
Loading…
Reference in New Issue
Block a user