I have a project that mixes C# and Oxygene sources. It seems to me, the C# code cannot be matched to Oxygene’s implicit operator, for example,
The C# code Graph.Const( {1,2} ), should be matched to Oxygene’s Graph.Const(aTensor: Tensor), because Tensor has an implicit operator: operator implicit (array of Integer): Tensor
But it seems to me - the implicit operator cannot be matched as expected.
No. The issue seems to be a problem with mixed code.
A pure C# project, would not have this problem - the compiler will automatically/conveniently generate a temporary new []{1,2,3} for the array literal {1,2,3}.
For example, the following code runs not problem in a pure-bred C# project (Island/Windows):
class Test
{
public static implicit operator Test(int[] arr)
{
Console.WriteLine("matched~");
}
}
static class Program
{
public static Int32 Main(string[] args)
{
Console.WriteLine("The magic happens here.");
DoSomething({1,2,3}); // This is a array literal that compiler takes care of
Console.ReadLine();
return 0;
}
public static void DoSomething(Test test)
{
}
}