Skip to content

Commit

Permalink
Fixed a bug with saving delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Mar 7, 2017
1 parent a36831f commit 7512746
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ILRuntime/CLR/Utils/Extensions.cs
Expand Up @@ -151,7 +151,7 @@ public static object CheckCLRTypes(this Type pt, Runtime.Enviorment.AppDomain do
}
else if (obj is ILTypeInstance)
{
if (obj is IDelegateAdapter)
if (obj is IDelegateAdapter && pt != typeof(ILTypeInstance))
{
return ((IDelegateAdapter)obj).Delegate;
}
Expand Down
1 change: 1 addition & 0 deletions ILRuntime/Runtime/Intepreter/DelegateAdapter.cs
Expand Up @@ -552,6 +552,7 @@ protected DelegateAdapter(Enviorment.AppDomain appdomain, ILTypeInstance instanc
this.appdomain = appdomain;
this.instance = instance;
this.method = method;
CLRInstance = this;
}

public override bool IsValueType
Expand Down
11 changes: 11 additions & 0 deletions TestCases/DelegateTest.cs
Expand Up @@ -124,6 +124,17 @@ public static void DelegateTest11()
ILRuntimeTest.TestFramework.BaseClassTest.DoTest();
}

public static void DelegateTest12()
{
testDele += IntTest3;
Dictionary<int, TestDelegate> dic = new Dictionary<int, TestDelegate>();
dic[0] = testDele;
dic[1] = IntTest3;
Console.WriteLine(dic[0](1000));
Console.WriteLine(dic[1](1000));

}

static void CallBack(ILRuntimeTest.TestFramework.BaseClassTest a)
{
a.testField = true;
Expand Down

0 comments on commit 7512746

Please sign in to comment.