Bug 318326 (MONO75334) - [GMCS] runtime is confused by usage generic method invocation from different instantiations of its generic type
Summary: [GMCS] runtime is confused by usage generic method invocation from different ...
Status: RESOLVED FIXED
Alias: MONO75334
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.0
Hardware: Other Other
: P3 - Medium : Blocker
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-21 00:38 UTC by Kamil Skalski
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
zip with the nemerle compiled binary, which is confusing runtime (955 bytes, application/octet-stream)
2005-06-21 00:41 UTC, Thomas Wiest
Details

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


---- Reported by nazgul@omega.pl 2005-06-20 17:38:07 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:
This is both a gmcs and runtime bug

Steps to reproduce the problem:
1. Try to compile code:

class List <t> {
  public void foo <b> (List <t> x) {
    System.Console.WriteLine ("{0} - {1}", typeof (t), x.GetType ());
  }
}

class C {}
class D {}


class M {
  static void Main () {
    List <D> x = new List<D> ();
    x.foo <C> (x);
    List <string> y = new List<string> ();
    y.foo <C> (y);
  }
}


2. Try to run attached binary

Actual Results:
t.cs(16) error CS1502: The best overloaded match for method 'List`1[[D, t,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].foo(List`1[[D, t,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]])' has some invalid
arguments
t.cs(16) error CS1503: Argument 1: Cannot convert from
'List`1[[System.String, mscorlib, Version=2.0.3600.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]]' to 'List`1[[D, t, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null]]'
t.cs(16) error CS1501: No overload for method `foo' takes `1' arguments
Compilation failed: 3 error(s), 0 warnings

from gmcs
and

D - List[D]
D - List[System.String]

from runtime (when running out.exe compiled by nemerle)

Expected Results:
D - List`1[D]
System.String - List`1[System.String]


How often does this happen? 
Always

Additional Information:
I'm marking it as runtime bug and a blocker, since it is very common code
pattern in our compiler and it fails with incorrect instanciations applied. 
The related gmcs bug is probably a different issue and should be given its
own bugreport, but if you compile it with csc it will give the same problem
as with nemerle.



---- Additional Comments From nazgul@omega.pl 2005-06-20 17:41:11 MST ----

Created an attachment (id=168155)
zip with the nemerle compiled binary, which is confusing runtime




---- Additional Comments From malekith@pld-linux.org 2005-06-21 05:24:51 MST ----

This is not only a problem with typeof. If the function was:

  public List<t> foo <b> (List <t> x) {
    return new List<t> ();
  }

it would return List[D] twice.



---- Additional Comments From martin@ximian.com 2005-06-21 07:48:52 MST ----

Fixed in SVN.



---- Additional Comments From nazgul@omega.pl 2005-06-23 18:43:32 MST ----

This testcase still gives the wrong output (r46435).

D - List`1[D]
D - List`1[System.String]





---- Additional Comments From martin@ximian.com 2005-06-28 09:54:29 MST ----

Fixed in SVN.

Imported an attachment (id=168155)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>mono svn 20.06.2005</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".