bug fix #735
This commit is contained in:
parent
1936533394
commit
314ae55066
11
TestSuite/extensionmethods27.pas
Normal file
11
TestSuite/extensionmethods27.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
procedure Add<T>(self:List<T>; item: T; b: boolean); extensionmethod;
|
||||
begin
|
||||
self.Add(item);
|
||||
end;
|
||||
|
||||
begin
|
||||
var l: List<integer> := new List<integer>;
|
||||
l.Add(1, true);
|
||||
l.Add(6);
|
||||
assert(l[0] = 1);
|
||||
end.
|
||||
23
TestSuite/extensionmethods28.pas
Normal file
23
TestSuite/extensionmethods28.pas
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var i: integer;
|
||||
type
|
||||
t1<T>=class
|
||||
|
||||
procedure p1(a:byte; b:word);
|
||||
begin
|
||||
i := 2;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure p1<T>(self:t1<T>;c:single); extensionmethod;
|
||||
begin
|
||||
i := 3;
|
||||
end;
|
||||
|
||||
begin
|
||||
var o: t1<integer> := new t1<integer>;
|
||||
o.p1(2,3);
|
||||
assert(i = 2);
|
||||
o.p1(4);
|
||||
assert(i = 3);
|
||||
end.
|
||||
|
|
@ -2564,6 +2564,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
if (error_on_false)
|
||||
{
|
||||
if (def is common_namespace_function_node && (def as common_namespace_function_node).ConnectedToType != null && predef is common_method_node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AddError(def.loc, "FUNCTION_DEFINITION_HAVE_DIFFERENT_PARAMS_WITH_PREDEFINITION");
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -13041,7 +13041,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
if (top_function.ConnectedToType.Scope == null)
|
||||
AddError(context.top_function.loc, "EXTENSION_METHODS_FOR_CONSTRUCTED_TYPES_NOT_ALLOWED");
|
||||
top_function.ConnectedToType.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
||||
SymbolInfo si = new SymbolInfo(context.top_function);
|
||||
si.symbol_kind = symbol_kind.sk_overload_function;
|
||||
top_function.ConnectedToType.Scope.AddSymbol(top_function.name, si);
|
||||
if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind && top_function.ConnectedToType.element_type.is_generic_parameter)
|
||||
top_function.ConnectedToType.base_type.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
||||
else if (top_function.ConnectedToType.is_generic_parameter)
|
||||
|
|
|
|||
Loading…
Reference in a new issue