diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 2d8c7a324..615496f79 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -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) { diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 320119314..5da5c935b 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -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; } diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index d3cd560f2..df2c4fdbd 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -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); diff --git a/TestSuite/extensionmethods9.pas b/TestSuite/extensionmethods9.pas new file mode 100644 index 000000000..a3725d036 --- /dev/null +++ b/TestSuite/extensionmethods9.pas @@ -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. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index bfcbb6b10..c02b84c14 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -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; }