Bug 319296 (MONO76440) - [GMCS] compilation error: incorrect generation of error CS0122:
Summary: [GMCS] compilation error: incorrect generation of error CS0122:
Status: RESOLVED FIXED
Alias: MONO76440
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other All
: P3 - Medium : Major
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-14 20:47 UTC by Andy Waddell
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:34:51 UTC


---- Reported by awaddell@fnfr.com 2005-10-14 13:47:07 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:
I get:
error CS0122: `GenericsBugLib.MyClass<System.Int32>.ListChanged' is
inaccessible due to its protection level

on lines like 
            list.ListChanged += new ListChangedEventHandler(list_ListChanged);

even thought the event in question is publicly declared.  This only seems
to happen if the event is declared in a different assembly.

Steps to reproduce the problem:
1. Compile the following as a dll
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;


namespace GenericsBugLib
{
    public class MyClass<TItem> 
    {
        public MyClass() { }

        public event ListChangedEventHandler ListChanged;
        public void AddListChangedEventHandler(ListChangedEventHandler handler)
        {
            ListChanged += handler;
        }
        protected void OnListChanged(ListChangedEventArgs e)  {}

    }
}
"C:\Program Files\Mono-1.1.9.2\bin\gmcs" /noconfig  /nowarn:1691,67 /warn:4
/define:DEBUG;TRACE /define:MONO;HEADLESS;FIXME 
/reference:System;System.Data;System.Xml /out:mono\Debug\GenericsBugLib.dll
   /target:library Class1.cs Properties\AssemblyInfo.cs

2. Compile the following as an exe:
//#define WORKAROUND

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using GenericsBugLib;


namespace GenericsBug 
{
    class Program
    {
        static void Main(string[] args)
        {
            MyClass<int> list = new MyClass<int>();

#if ! WORKAROUND
            list.ListChanged += new ListChangedEventHandler(list_ListChanged);
#else
            list.AddListChangedEventHandler(new
ListChangedEventHandler(list_ListChanged));
#endif
        }

        static void list_ListChanged(object sender, ListChangedEventArgs e) { }
    }
}

"C:\Program Files\Mono-1.1.9.2\bin\gmcs" /noconfig  /nowarn:1691,67 /warn:4
/define:DEBUG;TRACE /define:MONO;HEADLESS;FIXME
/reference:..\GenericsBugLib\mono\Debug\GenericsBugLib.dll
/reference:System;System.Data;System.Xml /out:mono\Debug\GenericsBug.exe  
 /target:exe Program.cs Properties\AssemblyInfo.cs

3. experiment with #define WORKAROUND 

Actual Results:
w/o WORKAROUND
Program.cs(19,18): error CS0122:
`GenericsBugLib.MyClass<System.Int32>.ListChanged' is inaccessible due to
its protection level


Expected Results:
clean compile

How often does this happen? 
always

Additional Information:
compiles cleanly with MS compiler



---- Additional Comments From miguel@ximian.com 2006-01-04 12:17:33 MST ----

Am setting this priority to major.



---- Additional Comments From martin@ximian.com 2006-01-09 05:48:06 MST ----

Post-GUAM bug-fixing pass; week #2/2006.



---- Additional Comments From martin@ximian.com 2006-01-10 17:07:01 MST ----

Fixed in SVN; r55341 and r55342.



---- Additional Comments From martin@ximian.com 2006-01-10 17:08:44 MST ----

*** https://bugzilla.novell.com/show_bug.cgi?id=MONO77134 has been marked as a duplicate of this bug. ***