This commit is contained in:
Ivan Bondarev 2021-04-05 11:41:31 +02:00
parent 88e638308a
commit f4558af026
5 changed files with 2176 additions and 2139 deletions

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-2BJCJ7I
// DateTime: 03.04.2021 17:04:09
// DateTime: 05.04.2021 11:40:44
// UserName: ibond
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -3228,6 +3228,8 @@ expr_with_func_decl_lambda
{ $$ = $1; }
| func_decl_lambda
{ $$ = $1; }
| tkInherited
{ $$ = new inherited_ident("", @$); }
;
expr
@ -4175,6 +4177,7 @@ variable
{
$$ = new inherited_ident($2.name, @$);
}
| tkRoundOpen expr tkRoundClose
{
if (!parsertools.build_tree_for_formatter)

File diff suppressed because it is too large Load diff

16
TestSuite/inherited4.pas Normal file
View file

@ -0,0 +1,16 @@
type
t0 = class
function f1(i: integer); virtual := i;
end;
t1 = class(t0)
function f1(i: integer): integer; override;
begin
Result := inherited; // не разрешает
end;
end;
begin
var a := new t1;
assert(a.f1(5) = 5);
end.

View file

@ -2508,7 +2508,17 @@ namespace PascalABCCompiler.TreeConverter
switch (mot)
{
case motivation.address_receiving: return_addressed_value(inherited_ident_address_reciving(_inherited_ident)); break;
case motivation.expression_evaluation: return_value(inherited_ident_value_reciving(_inherited_ident)); break;
case motivation.expression_evaluation:
if (string.IsNullOrEmpty(_inherited_ident.name))
{
inherited_message msg = new inherited_message();
msg.source_context = _inherited_ident.source_context;
return_value(inherited_message_value_reciving(new inherited_message()));
}
else
return_value(inherited_ident_value_reciving(_inherited_ident));
break;
//case motivation.symbol_info_reciving: return_symbol_value(blocks.find(_ident.name));break;
case motivation.semantic_node_reciving: return_semantic_value(inherited_ident_semantic_reciving(_inherited_ident)); break;
}
@ -17096,14 +17106,17 @@ namespace PascalABCCompiler.TreeConverter
{
AddError(get_location(ident), "NO_BASE_CLASS_DEFINED_BUT_INHERITED_MEET");
}
List<SymbolInfo> sil = context.converted_type.base_type.find_in_type(ident.name, context.CurrentScope);
string name = ident.name;
if (string.IsNullOrEmpty(name))
name = context.converted_func_stack.first().name;
List<SymbolInfo> sil = context.converted_type.base_type.find_in_type(name, context.CurrentScope);
if (sil == null)
{
sil = context.converted_namespace.find(ident.name);
sil = context.converted_namespace.find(name);
if (sil != null)
AddError(get_location(ident), "CLASS_MEMBER_{0}_EXPECTED", ident.name);
AddError(get_location(ident), "CLASS_MEMBER_{0}_EXPECTED", name);
else
AddError(new UndefinedNameReference(ident.name, get_location(ident)));
AddError(new UndefinedNameReference(name, get_location(ident)));
}
return sil;
}