[svn] r7701: nemerle/trunk/ncc: generation/ImplementsWrapperMaker.n
generation/Typer3.n hierarchy/ClassMem...
malekith
svnadmin at nemerle.org
Mon Jun 11 16:56:59 CEST 2007
Log:
Fix part of #1021.
Author: malekith
Date: Mon Jun 11 16:56:58 2007
New Revision: 7701
Modified:
nemerle/trunk/ncc/generation/ImplementsWrapperMaker.n
nemerle/trunk/ncc/generation/Typer3.n
nemerle/trunk/ncc/hierarchy/ClassMembers.n
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
nemerle/trunk/ncc/testsuite/positive/tyvars.n
nemerle/trunk/ncc/typing/StaticTyVar.n
nemerle/trunk/ncc/typing/Subst.n
nemerle/trunk/ncc/typing/TyVarEnv.n
Modified: nemerle/trunk/ncc/generation/ImplementsWrapperMaker.n
==============================================================================
--- nemerle/trunk/ncc/generation/ImplementsWrapperMaker.n (original)
+++ nemerle/trunk/ncc/generation/ImplementsWrapperMaker.n Mon Jun 11 16:56:58 2007
@@ -39,15 +39,16 @@
{
internal CreateImplementsWrapper () : void
{
- // Message.Debug ($"check for impl wrap $this");
+ //Message.Debug ($"check for impl wrap $this");
// now we will create special wrappers implementing interface methods
// when our methods are co/contra-variant (and .NET doesn't allow it automatically)
def is_correct_impl (impl_meth : IMethod) {
- // Message.Debug ($"compare: $(current_type.GetMemType ().TypeOfMember (impl_meth)) ====== $(this.GetMemType ())");
+ //Message.Debug ($"compare: $(declaring_type.GetMemType ().TypeOfMember (impl_meth)) ====== $(this.GetFreshType ())");
if (impl_meth.GetHeader ().typarms.Length == fun_header.typarms.Length &&
declaring_type.GetMemType ().TypeOfMember (impl_meth).TryUnify (this.GetFreshType () [0]))
true
else {
+ //Message.Debug ("fail");
Util.locate (Location, MakeImplWrapper (impl_meth));
false
}
Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n (original)
+++ nemerle/trunk/ncc/generation/Typer3.n Mon Jun 11 16:56:58 2007
@@ -1118,7 +1118,7 @@
| _ => false
}
- IsThis (_ : TExpr) : bool
+ static IsThis (_ : TExpr) : bool
{
| TExpr.This => true
| TExpr.LocalRef as e
Modified: nemerle/trunk/ncc/hierarchy/ClassMembers.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/ClassMembers.n (original)
+++ nemerle/trunk/ncc/hierarchy/ClassMembers.n Mon Jun 11 16:56:58 2007
@@ -910,7 +910,7 @@
//***********************************************************************
// This members available only under completion engine.
- ThrowNotSupported[T] () : T
+ static ThrowNotSupported[T] () : T
{ throw System.NotSupportedException ("available on in code-completion use-case") }
public virtual EnsureCompiled() : void { ThrowNotSupported () }
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Mon Jun 11 16:56:58 2007
@@ -2409,11 +2409,7 @@
/* -- VALIDITY CHECKS --------------------------------------------------- */
/* ---------------------------------------------------------------------- */
- /**
- Check if types that are already bound are correctly applied.
- Check accessibility.
- */
- internal check_bound_types () : void
+ internal static check_bound_type (t : TyVar) : void
{
def check_type (t) {
| MType.Out (t)
@@ -2431,11 +2427,20 @@
}
and check_tv (t : TyVar) { check_type (t.Fix ()) }
+ check_tv (t)
+ }
+
+ /**
+ Check if types that are already bound are correctly applied.
+ Check accessibility.
+ */
+ internal check_bound_types () : void
+ {
// check accessibility of type we are aliasing
match (tydecl) {
| TypeDeclaration.Alias (t) =>
t.CheckAccessibility (this, accessibility);
- check_type (t);
+ check_bound_type (t);
| _ => ()
};
@@ -2447,13 +2452,13 @@
// which case is not mentioned by http://www.jaggersoft.com/csharp_standard/10.5.4.htm
when (this.IsInterface || !is_iface)
deriv_t.CheckAccessibility (this, accessibility);
- check_type (deriv_t);
+ check_bound_type (deriv_t);
}
foreach (tv in typarms)
foreach (t in tv.Constraints) {
t.CheckAccessibility (this, accessibility);
- check_type (t);
+ check_bound_type (t);
}
}
Modified: nemerle/trunk/ncc/testsuite/positive/tyvars.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/tyvars.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/tyvars.n Mon Jun 11 16:56:58 2007
@@ -46,6 +46,20 @@
{}
}
+namespace Bug1021a {
+public class M['M, 'S] where 'M : M['M, 'S]
+{
+}
+
+public class F['S]
+{
+ public I['M](_m : 'M) : void
+ where 'M : M['M, 'S]
+ {
+ }
+}
+}
+
/*
BEGIN-OUTPUT
END-OUTPUT
Modified: nemerle/trunk/ncc/typing/StaticTyVar.n
==============================================================================
--- nemerle/trunk/ncc/typing/StaticTyVar.n (original)
+++ nemerle/trunk/ncc/typing/StaticTyVar.n Mon Jun 11 16:56:58 2007
@@ -70,7 +70,7 @@
public LowerBound : MType
{
get {
- assert (constraints != null);
+ assert (constraints != null, $"for $this");
match (constraints) {
| [] =>
assert (InternalType.Object != null);
@@ -125,6 +125,25 @@
}
}
+ internal ApplySubst (orig_sub : Subst) : StaticTyVar
+ {
+ // we should also do a substitution on the constraints, but it appears
+ // to be tricky at best -- enabling it causes failures in Nemerle.dll
+ if (true || Constraints is []) this
+ else {
+ def sub = orig_sub.Copy ();
+ def res = StaticTyVar (this);
+ sub.Add (this, MType.TyVarRef (res));
+ def new_constraints = Constraints.Map (x => sub.Apply (x).Fix ());
+ if (new_constraints.Equals (Constraints)) this
+ else {
+ res.Constraints = new_constraints;
+ orig_sub.Add (this, MType.TyVarRef (res));
+ res
+ }
+ }
+ }
+
public SpecialConstraints : GenericParameterAttributes
{
get { special }
@@ -184,7 +203,7 @@
sub.Add (tp, MType.TyVarRef (ntp));
(ntp, tp.Constraints)
}).Map (fun (tv : StaticTyVar, constr : list [_]) {
- tv.Constraints = constr.Map (sub.MonoApply);
+ tv.Constraints = constr.Map (x => sub.Apply (x).Fix ());
tv
});
(sub, newtp)
Modified: nemerle/trunk/ncc/typing/Subst.n
==============================================================================
--- nemerle/trunk/ncc/typing/Subst.n (original)
+++ nemerle/trunk/ncc/typing/Subst.n Mon Jun 11 16:56:58 2007
@@ -113,7 +113,10 @@
MType.Intersection (List.Map (lst, MonoApply))
// | MType.TyVarRef (tv) => assert (!Option.IsSome (map.Find (tv.id))); t
- | MType.TyVarRef => t
+ | MType.TyVarRef (tv) =>
+ def tv' = tv.ApplySubst (this);
+ if (tv' : object == tv) t
+ else MType.TyVarRef (tv')
}
}
Modified: nemerle/trunk/ncc/typing/TyVarEnv.n
==============================================================================
--- nemerle/trunk/ncc/typing/TyVarEnv.n (original)
+++ nemerle/trunk/ncc/typing/TyVarEnv.n Mon Jun 11 16:56:58 2007
@@ -409,6 +409,8 @@
else (GenericParameterAttributes.None, [])
}
+ mutable to_check = [];
+
// bind constraints to what they really are
foreach (c in tp.constraints) {
match (m.Find (c.tyvar.GetName())) {
@@ -425,7 +427,8 @@
| <[ @- ]> => special |= GenericParameterAttributes.Contravariant;
| <[ @enum ]> with cty = <[ System.Enum ]>
| cty =>
- def ty = tenv.MonoBind (env, curtc, cty, check_parms);
+ def ty = tenv.MonoBind (env, curtc, cty, check_parms = false);
+ when (check_parms) to_check ::= ty;
if (subtype.Contains (ty))
Message.Error ($"constraint `$ty' is already declared for $tv");
else
@@ -519,6 +522,8 @@
tv.SetConstraints (get (tv.id));
}
+ to_check.Iter (TypeBuilder.check_bound_type);
+
(tenv, tyParams)
}
}
More information about the svn
mailing list