diff options
author | Martin Baulig <martin@novell.com> | 2007-03-15 21:02:34 +0300 |
---|---|---|
committer | Martin Baulig <martin@novell.com> | 2007-03-15 21:02:34 +0300 |
commit | 6556fbb87f821b66cd0d2bf4a9c8f59df359dff2 (patch) | |
tree | 7e7a71eb1af94c9569ab2b84913c4245efc580b8 | |
parent | 9fc8ed79533bfb8207a73e03f2a2d3a7a4a23f80 (diff) |
2007-03-15 Martin Baulig <martin@ximian.com>
Fix #79984.
* generic.cs
(TypeParameter.HasConstructorConstraint): Removed.
(ConstraintChecker.HasDefaultConstructor): Removed the
`TypeBuilder' argument here; correctly check for the ctor
constraint on type parameters.
svn path=/trunk/mcs/; revision=74406
-rw-r--r-- | mcs/gmcs/ChangeLog | 10 | ||||
-rw-r--r-- | mcs/gmcs/generic.cs | 19 | ||||
-rw-r--r-- | mcs/tests/gtest-316.cs | 36 |
3 files changed, 54 insertions, 11 deletions
diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog index c983444c9bc..c5d4d753494 100644 --- a/mcs/gmcs/ChangeLog +++ b/mcs/gmcs/ChangeLog @@ -1,5 +1,15 @@ 2007-03-15 Martin Baulig <martin@ximian.com> + Fix #79984. + + * generic.cs + (TypeParameter.HasConstructorConstraint): Removed. + (ConstraintChecker.HasDefaultConstructor): Removed the + `TypeBuilder' argument here; correctly check for the ctor + constraint on type parameters. + +2007-03-15 Martin Baulig <martin@ximian.com> + Fix #79302. * generic.cs diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs index 1ba9fb80e8d..62f368e195d 100644 --- a/mcs/gmcs/generic.cs +++ b/mcs/gmcs/generic.cs @@ -620,10 +620,6 @@ namespace Mono.CSharp { get { return constraints; } } - public bool HasConstructorConstraint { - get { return constraints != null && constraints.HasConstructorConstraint; } - } - public DeclSpace DeclSpace { get { return decl; } } @@ -930,9 +926,6 @@ namespace Mono.CSharp { MemberList list = TypeManager.FindMembers ( gc.ClassConstraint, mt, bf, filter, criteria); - Report.Debug (128, "TPARAM FIND MEMBERS #1", Name, mt, bf, - filter, criteria, gc.ClassConstraint, list.Count); - members.AddRange (list); } @@ -1655,7 +1648,7 @@ namespace Mono.CSharp { if (TypeManager.IsBuiltinType (atype) || atype.IsValueType) return true; - if (HasDefaultConstructor (ec.DeclContainer.TypeBuilder, atype)) + if (HasDefaultConstructor (atype)) return true; Report_SymbolRelatedToPreviousError (); @@ -1704,7 +1697,7 @@ namespace Mono.CSharp { return false; } - bool HasDefaultConstructor (Type containerType, Type atype) + bool HasDefaultConstructor (Type atype) { if (atype.IsAbstract) return false; @@ -1732,8 +1725,12 @@ namespace Mono.CSharp { } TypeParameter tparam = TypeManager.LookupTypeParameter (atype); - if (tparam != null) - return tparam.HasConstructorConstraint; + if (tparam != null) { + if (tparam.GenericConstraints == null) + return false; + else + return tparam.GenericConstraints.HasConstructorConstraint; + } MemberList list = TypeManager.FindMembers ( atype, MemberTypes.Constructor, diff --git a/mcs/tests/gtest-316.cs b/mcs/tests/gtest-316.cs new file mode 100644 index 00000000000..ca1f8faa1d3 --- /dev/null +++ b/mcs/tests/gtest-316.cs @@ -0,0 +1,36 @@ +// Bug #79984 +using System; + +class X +{ + static void Main () + { } +} + +class Foo +{ + public int X; +} + +abstract class Base +{ + public abstract void Method<R> () + where R : Foo, new (); +} + +class Derived : Base +{ + public override void Method<S> () + { + Method2<S> (); + // S s = new S (); + // Console.WriteLine (s.X); + } + + public void Method2<T> () + where T : Foo, new () + { + T t = new T (); + Console.WriteLine (t.X); + } +} |