[Mono-bugs] [Bug 81517][Nor] New - [GMCS] Incorrectly checks generic type member accessibility

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed May 2 14:11:23 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mike.allen at durrusa.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81517

--- shadow/81517	2007-05-02 14:11:23.000000000 -0400
+++ shadow/81517.tmp.18614	2007-05-02 14:11:23.000000000 -0400
@@ -0,0 +1,89 @@
+Bug#: 81517
+Product: Mono: Compilers
+Version: 1.2
+OS: 
+OS Details: Ubuntu 7.04
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: mike.allen at durrusa.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] Incorrectly checks generic type member accessibility
+
+Description of Problem:
+
+I'm using gmcs version 1.2.3.1 (mono-gmcs package supplied by Ubuntu 7.04).
+
+Consider the following code:
+
+namespace Test
+{
+    public class Test <T>
+    where T:
+        Test <T>
+    {
+        private int someData;
+        public void Copy (T other)
+        {
+            someData = other.someData;
+        }
+    }
+}
+
+(Now, I'm not saying that this is a good example of a generic copy method,
+but still...  ;-)
+
+If you compile this, the gmcs compiler complains about the "other.someData"
+reference saying that it is inaccessible due to its protection level.
+
+As a workaround, I found that I need to cast "other" as follows:
+
+namespace Test
+{
+    public class Test <T>
+    where T:
+        Test <T>
+    {
+        private int someData;
+        public void Copy (T other)
+        {
+            Test <T> fudge = other;
+            someData = fudge.someData;
+        }
+    }
+}
+
+and this compiles OK.
+
+Steps to reproduce the problem:
+1. Copy the first code example above into a file called "test.cs".
+2. Compile this file with the command:
+
+    gmcs -target:library -warn:4 -warnaserror test.cs
+
+Actual Results:
+
+Get the following compiler output:
+
+test.cs(10,30): error CS0122: `Test.Test<T>.someData' is inaccessible due
+to its protection level
+test.cs(7,21): (Location of the symbol related to previous error)
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+
+Clean compile with no errors.
+
+How often does this happen? 
+
+Every time.
+
+Additional Information:
+
+Compiles clean with Microsoft C# version 8.00.50727.42


More information about the mono-bugs mailing list