[svn] r6553: nemerle/trunk/ncc:
testsuite/positive/extension-methods.n typing/Typer.n
nazgul
svnadmin at nemerle.org
Fri Aug 18 23:36:51 CEST 2006
Log:
Fix extension methods resolution
Author: nazgul
Date: Fri Aug 18 23:36:48 2006
New Revision: 6553
Modified:
nemerle/trunk/ncc/testsuite/positive/extension-methods.n
nemerle/trunk/ncc/typing/Typer.n
Modified: nemerle/trunk/ncc/testsuite/positive/extension-methods.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/extension-methods.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/extension-methods.n Fri Aug 18 23:36:48 2006
@@ -42,6 +42,47 @@
}
}
+namespace Bug707 {
+ using System;
+
+ module Ext
+ {
+ public IsNullOrEmpty(this str : string) : bool
+ {
+ string.IsNullOrEmpty(str);
+ }
+ }
+
+ public module M1
+ {
+ public Sort[T](this source : array[T]) : array[T]
+ {
+ Array.Sort(source);
+ source
+ }
+ }
+
+ module StaticRedefinition {
+ public Run () : void {
+ def test(str : string)
+ {
+ Console.WriteLine(str.IsNullOrEmpty());
+ }
+
+ test("test");
+ test("");
+ test(null);
+
+ def ary = array[0,1,2,3,4,5,6,7,8,9];
+ def j = 3;
+
+ WriteLine(ary.Exists(elem => elem == j));
+
+ WriteLine(List.FromArray (array[4,1,3,8,2].Sort()));
+ }
+ }
+}
+
module Extensions
public All [T] (this objs : System.Collections.Generic.IEnumerable[T], fn : T -> bool) : bool
return :
@@ -83,6 +124,8 @@
System.Console.WriteLine (a.Where(_.StartsWith ("fo")));
System.Console.WriteLine (a.NoWhere(_.StartsWith ("fo")));
+Bug707.StaticRedefinition.Run ();
+
/*
BEGIN-OUTPUT
All : even
@@ -123,5 +166,10 @@
[2, 3]
[foo, foox]
[bar]
+False
+True
+True
+True
+[1, 2, 3, 4, 8]
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Fri Aug 18 23:36:48 2006
@@ -2444,13 +2444,6 @@
lookup (possible_type);
- when (res.IsEmpty) {
- print_errors = true;
- visited = [];
- mems.Clear ();
- lookup (possible_type);
- }
-
foreach (meth in Manager.LibrariesManager.GetExtensionMethods (name.Id, name.GetEnv (env), false))//for_completion))
{
//when (possible_type != null && !possible_type.TryProvide (meth.GetParameters ().Head.ty))
@@ -2461,6 +2454,13 @@
}
}
+ when (res.IsEmpty) {
+ print_errors = true;
+ visited = [];
+ mems.Clear ();
+ lookup (possible_type);
+ }
+
Some (res)
}
else if (IsError (obj))
More information about the svn
mailing list