Testcase: SpillingByrefCall_Spilling
C# class introduces ref methods
using System;
public class TestClass
{
int x = 0;
public ref int Save(int y)
{
x = y;
return ref x;
}
public void Write(ref int y)
{
Console.WriteLine(y);
}
public void Write(ref int y, int z)
{
Console.WriteLine(y);
}
}
VB test code (references the above code):
Imports System.Threading.Tasks
Module Module1
Sub Main()
TestMethod().Wait()
End Sub
Async Function TestMethod() As Task
Dim inst = New TestClass
' ERROR?
' currently `ref` is spilled 'by-value' and assert fires.
inst.Write(inst.Save(Await Task.FromResult(30)), inst.Save(Await Task.FromResult(33)))
End Function
End Module
Expected:
- not sure. C# gives an error. Possibly VB should as well
Actual:
- compiler asserts. If ignored, the
ref argument is spilled by-value
It might actually be ok in VB to spill by-value. Not sure.
In any case there should not be asserts.
Also note - changing current behavior (ignoring the assert) might be a compat concern. This behavior existed since the last release.
Testcase: SpillingByrefCall_Spilling
C# class introduces ref methods
VB test code (references the above code):
Expected:
Actual:
refargument is spilled by-valueIt might actually be ok in VB to spill by-value. Not sure.
In any case there should not be asserts.
Also note - changing current behavior (ignoring the assert) might be a compat concern. This behavior existed since the last release.