[Mono-bugs] [Bug 342117] New: CS0310 is (incorrectly) reported when generics inherit generics with struct constraints

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 15 20:24:11 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=342117

           Summary: CS0310 is (incorrectly) reported when generics inherit
                    generics with struct constraints
           Product: Mono: Compilers
           Version: 1.2.3
          Platform: i686
        OS/Version: Kubuntu
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: bill at arrowsreach.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


CS0310 is (incorrectly) reported when a generic with a new() constraint
inherits from another generic with a struct constraint.  The Microsoft compiler
does not generate an error for this case.

====================================
Code:
====================================

  class C <a> where a : new () { }

  class D <b> : C<b> where b : struct { }

  struct Foo { }

  class X
  {
        static void Main ()
        {
          C<Foo> x;
        }
  }

====================================

I realise that this seems to contradict the rules that produce the error
CS0451: The 'new()' constraint cannot be used with the 'struct' constraint.

For example, combining both constraints on a single generic is not allowed:
  class C <a> where a: struct, new() { }

It is actually acceptable for a generic "D" to inherit from generic "C" because
a struct has an implicit default constructor, which meets the construction
constraints of "C".


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list