From 410094c1b835977f1ab043e4ed2b719dce0df2b8 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 07:56:33 +0000 Subject: [PATCH] * allow constants and final class vars in Java interfaces (required to parse external interfaces) git-svn-id: branches/jvmbackend@18401 - --- compiler/pdecobj.pas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/pdecobj.pas b/compiler/pdecobj.pas index 8e9a63a450..4e7c086185 100644 --- a/compiler/pdecobj.pas +++ b/compiler/pdecobj.pas @@ -774,7 +774,10 @@ implementation procedure parse_var; begin - if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass]) then + if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass]) and + { Java interfaces can contain static final class vars } + not((current_objectdef.objecttype=odt_interfacejava) and + is_final and is_classdef) then Message(parser_e_type_var_const_only_in_records_and_classes); consume(_VAR); fields_allowed:=true; @@ -796,8 +799,11 @@ implementation if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then Message(parser_e_procedure_or_function_expected); + { Java interfaces can contain final class vars } if is_interface(current_structdef) or - is_javainterface(current_structdef) then + (is_javainterface(current_structdef) and + (not(is_final) or + (token<>_VAR))) then Message(parser_e_no_static_method_in_interfaces) else { class methods are also allowed for Objective-C protocols } @@ -851,7 +857,7 @@ implementation case token of _TYPE : begin - if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass]) then + if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass,odt_interfacejava]) then Message(parser_e_type_var_const_only_in_records_and_classes); consume(_TYPE); object_member_blocktype:=bt_type; @@ -948,7 +954,8 @@ implementation if is_interface(current_structdef) or is_objc_protocol_or_category(current_structdef) or is_objectpascal_helper(current_structdef) or - is_javainterface(current_structdef) then + (is_javainterface(current_structdef) and + not(class_fields and final_fields)) then Message(parser_e_no_vars_in_interfaces); if (current_structdef.symtable.currentvisibility=vis_published) and