var a := Arr(2.5,3.7);
writeln(a.Max);
This commit is contained in:
Бондарев Иван 2015-10-11 21:48:37 +02:00
parent f35fe33171
commit 7e1c6d5f75
5 changed files with 60 additions and 8 deletions

View file

@ -401,8 +401,14 @@ namespace CodeCompletion
// if (si == null) dn = compiled_type_node.get_type_node(PascalABCCompiler.NetHelper.NetHelper.FindType((_var_def_statement.vars_type as named_type_reference).names[0].name,unl));
if (ret_tn == null) return;
if (ret_tn is ProcScope)
ret_tn = new ProcType(ret_tn as ProcScope);
if (ret_tn is ProcScope)
{
if (_var_def_statement.vars_type != null)
ret_tn = new ProcType(ret_tn as ProcScope);
else
ret_tn = (ret_tn as ProcScope).return_type;
}
if (_var_def_statement.vars != null)
foreach (ident s in _var_def_statement.vars.idents)
{

View file

@ -4163,7 +4163,15 @@ namespace CodeCompletion
if (original_type != null)
return original_type.FindNameOnlyInType(name);
if (name != null) sc = internal_find(name, false);//ht[name] as SymScope;
if (sc == null && baseScope != null) return baseScope.FindNameOnlyInType(name);
if (sc == null && baseScope != null)
sc = baseScope.FindNameOnlyInType(name);
if (sc == null && implemented_interfaces != null)
foreach (TypeScope ts in implemented_interfaces)
{
sc = ts.FindNameOnlyInType(name);
if (sc != null)
break;
}
return sc;
}

View file

@ -5700,7 +5700,7 @@ end;
procedure Assert(cond: boolean);
begin
if (Environment.OSVersion.Platform = PlatformID.Unix) or (Environment.OSVersion.Platform = PlatformID.MacOSX) then
if (Environment.OSVersion.Platform = PlatformID.Unix) or (Environment.OSVersion.Platform = PlatformID.MacOSX) or IsWDE then
begin
var stackTrace := new System.Diagnostics.StackTrace(true);
var ind := 1;
@ -5708,7 +5708,15 @@ begin
ind := 0;
var currentLine := stackTrace.GetFrame(ind).GetFileLineNumber();
var currentFile := stackTrace.GetFrame(ind).GetFileName();
System.Diagnostics.Debug.Assert(cond,'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString());
if not IsWDE then
System.Diagnostics.Debug.Assert(cond,'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString())
else if not cond then
begin
var err := 'Ñáîé ïîäòâåðæäåíèÿ: '+Environment.NewLine+'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString();
writeln(err);
System.Threading.Thread.Sleep(500);
raise new Exception();
end;
end
else
System.Diagnostics.Debug.Assert(cond);
@ -5716,7 +5724,7 @@ end;
procedure Assert(cond: boolean; mes: string);
begin
if (Environment.OSVersion.Platform = PlatformID.Unix) or (Environment.OSVersion.Platform = PlatformID.MacOSX) then
if (Environment.OSVersion.Platform = PlatformID.Unix) or (Environment.OSVersion.Platform = PlatformID.MacOSX) or IsWDE then
begin
var stackTrace := new System.Diagnostics.StackTrace(true);
var ind := 1;
@ -5724,7 +5732,15 @@ begin
ind := 0;
var currentLine := stackTrace.GetFrame(ind).GetFileLineNumber();
var currentFile := stackTrace.GetFrame(ind).GetFileName();
System.Diagnostics.Debug.Assert(cond,'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString()+': '+mes);
if not IsWDE then
System.Diagnostics.Debug.Assert(cond,'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString()+': '+mes)
else if not cond then
begin
var err := 'Ñáîé ïîäòâåðæäåíèÿ: '+mes+Environment.NewLine+'Ôàéë '+currentFile+', ñòðîêà '+currentLine.ToString();
writeln(err);
System.Threading.Thread.Sleep(500);
raise new Exception();
end;
end
else
System.Diagnostics.Debug.Assert(cond, mes);

View file

@ -0,0 +1,12 @@
procedure test(obj: object);
begin
assert(abs(real(obj)-3.7)<0.0001);
end;
begin
var a := Arr(2.5,3.7);
assert(abs(a.Max-3.7)<0.0001);
var r := a.Max;
assert(abs(r-3.7)<0.0001);
test(a.Max);
end.

View file

@ -1543,7 +1543,17 @@ namespace PascalABCCompiler.TreeConverter
if (convertion_data_and_alghoritms.find_eq_method_in_list(fn, fnl) == null)
{
if (!(obj != null && fn.polymorphic_state == SemanticTree.polymorphic_state.ps_static && !fn.is_extension_method))
fnl.AddElement(fn);
{
if (fn.is_extension_method)
{
if (fn.parameters[0].type == obj.type || type_table.compare_types(fn.parameters[0].type, obj.type) == type_compare.greater_type)
fnl.AddElementFirst(fn);
else
fnl.AddElement(fn);
}
else
fnl.AddElement(fn);
}
}
si = si.Next;
}