Skip to content

Commit

Permalink
Fixed Ourpalm#705
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Jul 7, 2022
1 parent 6246cc2 commit e24cdb6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ILRuntime/Runtime/Intepreter/ILIntepreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,12 @@ public object Run(ILMethod method, object instance, object[] p)
}
else
{
*objRef = *val;
if (val->ObjectType == ObjectTypes.Null && objRef->ObjectType == ObjectTypes.Object)
{
mStack[objRef->Value] = null;
}
else
*objRef = *val;
}
}
}
Expand Down
40 changes: 40 additions & 0 deletions TestCases/RefOutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,46 @@ public static void UnitTest_RefOutNull()
if (aaa != null)
throw new Exception();
}
class TestClass222
{
public TestClass222()
{
t = s++;
}
public int t;
static int s = 1;
}
class TestRefOut2Cls
{
public TestRefOut2Cls()
{
p = null;
//非null就不会有问题
//p = new TestClass();
}
public bool TryGetObject<T>(out T res) where T : TestClass222, new()
{
//用局部变量中转没问题
//var tmp = p as T;
//res = null;
//res = tmp;
//这一句现在没什么用(比如用来if判断)但没有这一句不会报错。
res = p as T;
res = new T();//这里解析器越界异常
//res = p as T;//这样也会解析器越界异常
Console.WriteLine("!!! new T");
return true;
}
TestClass222 p;
}
public static void UnitTest_RefOutNull2()
{
TestClass222 res;
TestRefOut2Cls obj = new TestRefOut2Cls();
obj.TryGetObject(out res);
if (res == null)
throw new Exception();
}
public static void UnitTest_Typeof()
{
object obj = 1;
Expand Down

0 comments on commit e24cdb6

Please sign in to comment.