[Mono-bugs] [Bug 80359][Nor] New - Compiler error CS1540 when accessing protected member of base class when using generics

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Dec 25 19:08:21 EST 2006


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 frederik.carlier at ugent.be.

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

--- shadow/80359	2006-12-25 19:08:21.000000000 -0500
+++ shadow/80359.tmp.6261	2006-12-25 19:08:21.000000000 -0500
@@ -0,0 +1,94 @@
+Bug#: 80359
+Product: Mono: Compilers
+Version: 1.2
+OS: 
+OS Details: Ubuntu 6.10 with Feister packages for Mono
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: frederik.carlier at ugent.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Compiler error CS1540 when accessing protected member of base class when using generics
+
+Description of Problem:
+
+If, in a generic class, you access a protected property of the base class,
+the compiler returns an error.
+If you do the same in a non-generic class, no error is raised.
+
+Steps to reproduce the problem:
+1. Create the following file: dict.cs with contents
+## BEGIN OF FILE
+using System;
+using System.Collections;
+
+namespace Application
+{
+	
+	
+	public class Test<T> : DictionaryBase
+	{
+		
+		public Test()
+		{
+			Dictionary.Add(new Guid().ToString(), "Foo");
+		}
+
+		public void Add(string key, object value)
+		{
+           		this.Dictionary.Add(key, value);
+		}
+	}
+}
+## END OF FILE
+2. Compile: gmcs dict.cs
+3. Alter the file, so it looks like this:
+## BEGIN OF FILE
+using System;
+using System.Collections;
+
+namespace Application
+{
+	
+	
+	public class Test<T> : DictionaryBase
+	{
+		
+		public Test()
+		{
+			Dictionary.Add(new Guid().ToString(), "Foo");
+		}
+
+		public void Add(string key, object value)
+		{
+           		this.Dictionary.Add(key, value);
+		}
+	}
+}
+## END OF FILE
+4. Compile: gmcs dict.cs
+
+Actual Results:
+fcarlier at col-clt-04:/tmp/monobug$ gmcs -target:library dict.cs 
+fcarlier at col-clt-04:/tmp/monobug$ gmcs -target:library dict.cs 
+dict.cs(14,4): error CS1540: Cannot access protected member
+`System.Collections.DictionaryBase.Dictionary' via a qualifier of type
+`Application.Test<T>'; the qualifier must be of type `Application.Test<T>'
+(or derived from it)
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+Compilation to work file both times, independent of a generic declaration
+of the class.
+
+How often does this happen? 
+Always.
+
+Additional Information:
+This does not happen when using the .NET Framework


More information about the mono-bugs mailing list