Mixed Oxygene and C# code, implicit operator cannot be matched

Elements 2485, Island/Windows @ck @mh

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.

There must me more to this than just the language diff. Can we get a small test case?

Yes - I cleaned up and get this new Test case:
https://www.sugarsync.com/pf/D6147121_09656321_171158

shouldn’t that be new[]{1,2} ? Plain {1,2} isn’t valid as an array.

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)
    {

    }
}

@ck

@ck, @mh, some additional information for your insights:

if I put the mixed code into a .fx file, the compiler will just pass.

In other words:

For the .fx, it has:

  • Oxygene source
  • C# source

For the main executable:

  • C#, passing a array literal to a method defined in .fx, the compiler does NOT generate any warnings or errors, and the executable just runs fine.

Thanks, logged as bugs://83979

bugs://83979 got closed with status fixed.