mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 09:59:08 +02:00
* do not automatically resolve constructor calls to constructors of parent
Java classes in case it is not declared in the specified Java class, because that will create an instance of such a parent class (in the future, we can may automatically clone inherited constructors) git-svn-id: branches/jvmbackend@18425 -
This commit is contained in:
parent
e58d783211
commit
b6bae1e2e7
@ -375,7 +375,7 @@ scanner_e_illegal_alignment_directive=02088_E_Illegal alignment directive
|
|||||||
#
|
#
|
||||||
# Parser
|
# Parser
|
||||||
#
|
#
|
||||||
# 03316 is the last used one
|
# 03317 is the last used one
|
||||||
#
|
#
|
||||||
% \section{Parser messages}
|
% \section{Parser messages}
|
||||||
% This section lists all parser messages. The parser takes care of the
|
% This section lists all parser messages. The parser takes care of the
|
||||||
@ -1411,6 +1411,11 @@ parser_e_no_typed_const=03316_E_Typed constants are not allowed here, only forma
|
|||||||
% Java interfaces define a namespace in which formal constant can be defined,
|
% Java interfaces define a namespace in which formal constant can be defined,
|
||||||
% but since they define no storage it is not possible to define typed constants
|
% but since they define no storage it is not possible to define typed constants
|
||||||
% in them (those are more or less the same as initialised class fields).
|
% in them (those are more or less the same as initialised class fields).
|
||||||
|
parser_e_java_no_inherited_constructor=03317_E_Constructors are not automatically inherited in the JVM; explicitly add a constructor that calls the inherited one if you need it
|
||||||
|
% Java does not automatically add inherited constructors to child classes, so that they can be hidden.
|
||||||
|
% For compatibility with external Java code, FPC does the same. If you require access to the same
|
||||||
|
% constructors in a child class, define them in the child class and call the inherited one from
|
||||||
|
% there.
|
||||||
% \end{description}
|
% \end{description}
|
||||||
# Type Checking
|
# Type Checking
|
||||||
#
|
#
|
||||||
|
@ -408,6 +408,7 @@ const
|
|||||||
parser_e_final_only_const_var=03314;
|
parser_e_final_only_const_var=03314;
|
||||||
parser_e_final_only_external=03315;
|
parser_e_final_only_external=03315;
|
||||||
parser_e_no_typed_const=03316;
|
parser_e_no_typed_const=03316;
|
||||||
|
parser_e_java_no_inherited_constructor=03317;
|
||||||
type_e_mismatch=04000;
|
type_e_mismatch=04000;
|
||||||
type_e_incompatible_types=04001;
|
type_e_incompatible_types=04001;
|
||||||
type_e_not_equal_types=04002;
|
type_e_not_equal_types=04002;
|
||||||
@ -905,9 +906,9 @@ const
|
|||||||
option_info=11024;
|
option_info=11024;
|
||||||
option_help_pages=11025;
|
option_help_pages=11025;
|
||||||
|
|
||||||
MsgTxtSize = 61353;
|
MsgTxtSize = 61491;
|
||||||
|
|
||||||
MsgIdxMax : array[1..20] of longint=(
|
MsgIdxMax : array[1..20] of longint=(
|
||||||
26,89,317,105,85,54,111,23,202,63,
|
26,89,318,105,85,54,111,23,202,63,
|
||||||
49,20,1,1,1,1,1,1,1,1
|
49,20,1,1,1,1,1,1,1,1
|
||||||
);
|
);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1220,10 +1220,19 @@ implementation
|
|||||||
{ calling using classref? }
|
{ calling using classref? }
|
||||||
if isclassref and
|
if isclassref and
|
||||||
(p1.nodetype=calln) and
|
(p1.nodetype=calln) and
|
||||||
assigned(tcallnode(p1).procdefinition) and
|
assigned(tcallnode(p1).procdefinition) then
|
||||||
not(po_classmethod in tcallnode(p1).procdefinition.procoptions) and
|
begin
|
||||||
not(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) then
|
if not(po_classmethod in tcallnode(p1).procdefinition.procoptions) and
|
||||||
Message(parser_e_only_class_members_via_class_ref);
|
not(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) then
|
||||||
|
Message(parser_e_only_class_members_via_class_ref);
|
||||||
|
{ in Java, constructors are not automatically inherited
|
||||||
|
-> calling a constructor from a parent type will create
|
||||||
|
an instance of that parent type! }
|
||||||
|
if is_javaclass(structh) and
|
||||||
|
(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) and
|
||||||
|
(tcallnode(p1).procdefinition.owner.defowner<>find_real_class_definition(tobjectdef(structh),false)) then
|
||||||
|
Message(parser_e_java_no_inherited_constructor);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
fieldvarsym:
|
fieldvarsym:
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user