Bug 11241 - Erroneous CS0030 error when referencing class in another assembly
Summary: Erroneous CS0030 error when referencing class in another assembly
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-03-18 18:06 UTC by Martin Potter
Modified: 2013-04-08 10:47 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Classes to compile as a library (1.20 KB, application/octet-stream)
2013-03-18 18:06 UTC, Martin Potter
Details
Program that references external library (160 bytes, application/octet-stream)
2013-03-18 18:08 UTC, Martin Potter
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Martin Potter 2013-03-18 18:06:11 UTC
Created attachment 3644 [details]
Classes to compile as a library

The compiler reports CS0030 when casting a class to an interface declared on the base class, but only if the class is in a referenced assembly; if the class is compiled as part of the assembly where the cast occurs, compilation will succeed. This is a new error since 3.0.2. To reproduce:

1. Compile the attached file, ExternalLib.cs, as a library
2. Compile an program that references the library from step 1 with the line (IEquatable<Foo>) new Baz();
3. The compiler reports CS0030 when it should not.
Comment 1 Martin Potter 2013-03-18 18:08:27 UTC
Created attachment 3645 [details]
Program that references external library
Comment 2 Martin Potter 2013-03-18 18:09:34 UTC
Running the following results in CS0030:

mcs Bug11241.cs /r:ExternalLib.dll /out:Bug11241.exe

Running the following succeeds:

mcs Bug11241.cs ExternalLib.cs /out:Bug11241.exe
Comment 3 Marek Safar 2013-03-19 13:29:11 UTC
Fixed in master