Bug 323793 (MONO81109) - [GMCS] implement `new T()' for unknown generic types
Summary: [GMCS] implement `new T()' for unknown generic types
Status: RESOLVED FIXED
Alias: MONO81109
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-11 15:12 UTC by Marek Safar
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

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


---- Reported by marek.safar@seznam.cz 2007-03-11 08:12:39 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:

It's seems to me we are missing this code path for
generic types instantiation (CreateInstance<T>).
However, it should be easy to implement.


Steps to reproduce the problem:
1. 

interface ITest
{
	void Test ();
}

class Tester<T> where T : ITest, new ()
{
	public void Do ()
	{
		new T ().Test ();
	}
}

class Reference : ITest
{
	public void Test ()
	{
	}
}

struct Value : ITest
{
	public void Test ()
	{
	}
}

class C
{
	static void Main ()
	{
		new Tester<Reference> ().Do ();
		new Tester<Value> ().Do ();
	}
}


Actual Results:



Expected Results:


Unhandled Exception: System.InvalidOperationException: Operation is not
valid due to the current state of the object

  at Mono.CSharp.New.AddressOf (Mono.CSharp.EmitContext ec, AddressOp Mode)
[0x00000] 

  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean
is_base, Boolean is_static, Mono.CSharp.Expression instance_expr,
System.Reflection.MethodBase method, System.Collections.ArrayList
Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] 

  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean
is_base, Boolean is_static, Mono.CSharp.Expression instance_expr,
System.Reflection.MethodBase method, System.Collections.ArrayList
Arguments, Location loc) [0x00000] 

  at Mono.CSharp.Invocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] 

  at Mono.CSharp.Invocation.EmitStatement (Mono.CSharp.EmitContext ec)
[0x00000] 

  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec)
[0x00000] 

  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] 

  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] 

  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] 

  at Mono.CSharp.EmitContext.EmitResolvedTopBlock
(Mono.CSharp.ToplevelBlock block, Boolean unreachable) [0x00000] 

  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00000] 

  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] 

  at Mono.CSharp.Method.Emit () [0x00000] 

  at Mono.CSharp.TypeContainer.EmitType () [0x00000] 

  at Mono.CSharp.RootContext.EmitCode () [0x00000] 

  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000] 

  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 


How often does this happen? 


Additional Information:



---- Additional Comments From martin@ximian.com 2007-04-10 10:20:13 MST ----

-> me.



---- Additional Comments From martin@ximian.com 2007-04-10 10:20:27 MST ----

-> assi



---- Additional Comments From martin@ximian.com 2007-04-10 12:25:30 MST ----

Fixed in SVN; added gtest-327.cs.


Unknown operating system unknown. Setting to default OS "Other".