Bug 324885 (MONO82215) - [GMCS] is-operator bug related to generics
Summary: [GMCS] is-operator bug related to generics
Status: RESOLVED FIXED
Alias: MONO82215
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Linux
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-29 20:55 UTC by Patrick Ulbrich
Modified: 2008-09-22 18:02 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 20:45:44 UTC


---- Reported by flipper98@gmx.net 2007-07-29 13:55:21 MST ----

Description of Problem:

The following test case shows a situation where the is-operator fails.

Steps to reproduce the problem:
See test case.

Actual Results:
is-operator type comparison (ex is NestedException) returns false, although
the compared instance is of the compared type.

Note: it works as expected if you remove the generic brackets (<T1, T2>,
<int, int>) from the class definitions, so i guess the problem is related
to generics.

Expected Results:
is-operator type comparison should return true.

How often does this happen? 
always.

Additional Information:
The problem occurs on both, mono 1.2.3.1 and mono 1.2.4.
Test case: 

using System;

namespace AnyTest
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			B b = new B();
			b.M();
		}
	}
	
	abstract class A<T1, T2>
	{
	    public void M() {
	        try {
	            M2();
	        } catch(Exception ex) {
	            if (ex is NestedException)
	                Console.WriteLine("NestedException caught: " + ex.GetType());
	            else
	                Console.WriteLine("Other Exception caught: " + ex.GetType());
	        }
	    }
	    
	    protected abstract void M2();
	    
	    protected class NestedException : Exception
	    {
	        public NestedException() : base() {}
	    }
	}
	
	class B : A<int, int>
	{
	    protected override void M2() {
	        throw new NestedException();
	    }
	}
}


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Ubuntu feisty</cf_op_sys_details>
Unknown bug field "cf_version_details" encountered while moving bug
   <cf_version_details>mono 1.2.3.1 and mono 1.2.4</cf_version_details>

Comment 2 Marek Safar 2008-09-22 18:02:26 UTC
I can no longer reproduce this issue with SVN HEAD.