[svn] r7042: nemerle/trunk/ncc: testsuite/positive/typeof.n
typing/Typer.n
malekith
svnadmin at nemerle.org
Mon Dec 4 13:22:12 CET 2006
Log:
Properly use type parameters of type aliases when they are used as constructors. Resolves #676.
Author: malekith
Date: Mon Dec 4 13:22:11 2006
New Revision: 7042
Modified:
nemerle/trunk/ncc/testsuite/positive/typeof.n
nemerle/trunk/ncc/typing/Typer.n
Modified: nemerle/trunk/ncc/testsuite/positive/typeof.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/typeof.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/typeof.n Mon Dec 4 13:22:11 2006
@@ -46,6 +46,14 @@
}
}
+namespace Bug676 {
+interface A { }
+class B[T] where T : A, new() { public override ToString () : string { typeof(T).ToString () } }
+struct C : A {}
+
+type D = B.[C];
+}
+
public class TypeOfTest
{
@@ -71,6 +79,9 @@
System.Console.WriteLine (typeof (System.Collections.Generic.List[_]));
System.Console.WriteLine (typeof (System.Collections.Generic.Dictionary[_,_]));
System.Console.WriteLine (typeof (System.Collections.Generic.List[int]));
+
+
+ System.Console.WriteLine (Bug676.D());
}
}
@@ -81,5 +92,6 @@
System.Collections.Generic.List`1[T]
System.Collections.Generic.Dictionary`2[TKey,TValue]
System.Collections.Generic.List`1[System.Int32]
+Bug676.C
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Mon Dec 4 13:22:11 2006
@@ -2154,11 +2154,11 @@
}
- TypeToConstructor (pt_from : PT.PExpr, t : TypeInfo) : list [OverloadPossibility]
+ TypeToConstructor (pt_from : PT.PExpr, t : TypeInfo, add_constraint : TyVar = null) : list [OverloadPossibility]
{
match (t.GetTydecl ()) {
- | TypeDeclaration.Alias (MType.Class (t, _)) =>
- TypeToConstructor (pt_from, t)
+ | TypeDeclaration.Alias (MType.Class (t', _) as ty) =>
+ TypeToConstructor (pt_from, t', t.FreshSubst ().Apply (ty))
| _ =>
if (t.Attributes %&& NemerleAttributes.Abstract) {
ReportError (messenger,
@@ -2184,6 +2184,8 @@
def mt = MType.Fun (from, t.GetMemType ());
def ty = t.FreshSubst ().Apply (mt);
def ret_type = (ty.FixedValue :> MType.Fun).to :> MType.Class;
+ when (add_constraint != null)
+ _ = Expect (add_constraint, ret_type, "constructor");
ConstrainLeadingTyparms (pt_from, ret_type);
res = OverloadPossibility (this, ty, null, ret_type, meth) :: res;
when (meth.IsVarArgs) {
More information about the svn
mailing list