[nem-bug] [Nemerle 0000697]: Can't get type of generic attribute

feedback at nemerle.org feedback at nemerle.org
Fri Jun 30 20:02:40 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=697> 
======================================================================
Reported By:                VladD2
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   697
Category:                   Compiler
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             06-30-2006 19:37 CEST
Last Modified:              06-30-2006 20:02 CEST
======================================================================
Summary:                    Can't get type of generic attribute
Description: 
Code like this:
-----------------------------------------------------------------
using System;
using System.Diagnostics;

// Try get open generic type!
[DebuggerTypeProxy(typeof(TestProxy[]))] // error!
public class Test[T]
{
  public this(val : T) { _val = val; }
  public _val : T;
}

public class TestProxy[T]
{
  public this(test : Test[T]) { _test = test; }

  mutable _test : Test[T];

  public Val : T { get { _test._val; } }
}

class Program
{
  static Main() : void
  {
    def test = Test[int](123);
    Console.WriteLine(test._val);
  }
}
-----------------------------------------------------------------
report errors:
Main.n(5,8,9,2): error : TestProxy[] is not a valid type, use just
TestProxy
Main.n(5,8,9,2): error : wrong number of type parameters to `TestProxy'
Main.n(24,16,24,20): error : cannot find any suitable indexer in ? ->
Test[?]

The same code writen in C# works fine:
-----------------------------------------------------------------
using System;
using System.Diagnostics;

[DebuggerTypeProxy(typeof(TestProxy<>))]
public class Test<T>
{
  public Test(T val) { _val = val; }
  public T _val;
}

public class TestProxy<T>
{
  public TestProxy(Test<T> test) { _test = test; }

  Test<T> _test;

  public T Val { get { return _test._val; } }
}

class Program
{
  static void Main()
  {
    Test<int> test = new Test<int>(123);
    Console.WriteLine(test._val);
  }
}
-----------------------------------------------------------------

This behaviour is very important for debugging support. For example, it is
necessary for adding simlefied debug view for list[T]. 
======================================================================

----------------------------------------------------------------------
 VladD2 - 06-30-06 19:41 
----------------------------------------------------------------------
Excuse me. A name of a theme incorrect. A correct name of a theme: "It is
impossible to receive the Type of open generic type".

----------------------------------------------------------------------
 VladD2 - 06-30-06 20:02 
----------------------------------------------------------------------
More simple example:
System.Console.WriteLine(typeof(System.Collections.Generic.List[]));

In C#:
class Program
{
  static void Main()
  {
    System.Console.WriteLine(typeof(System.Collections.Generic.List<>));
  }
}

Issue History
Date Modified  Username       Field                    Change              
======================================================================
06-30-06 19:37 VladD2         New Issue                                    
06-30-06 19:41 VladD2         Note Added: 0001323                          
06-30-06 20:02 VladD2         Note Added: 0001324                          
======================================================================




More information about the bugs mailing list