Skip to content

outref parameter from an interface method is compiled as byref parameter #13468

@auduchinok

Description

@auduchinok

Consider this F# code:

type I =
    abstract M: param: outref<int> -> unit

type T() =
    interface I with
        member this.M(param) = failwith "todo"

The param parameter is compiled as out parameter:

[CompilationMapping(SourceConstructFlags.ObjectType)]
[Serializable]
public interface I1
{
  void M(out int param);
}

[CompilationMapping(SourceConstructFlags.ObjectType)]
[Serializable]
public class T1 : Program.I1
{
  public T1()
  {
    Program.T1 t1 = this;
  }

  void Program.I1.M(out int param) => throw Operators.Failure("todo");
}

Consider that the interface is coming from an IL assembly (e.g. from C# project):

public interface I2
{
    void M(out int i);
}
type T2() =
    interface I2 with
        member this.M(i) = failwith "todo"

Now the parameter is being compiled as ref instead:

[CompilationMapping(SourceConstructFlags.ObjectType)]
[Serializable]
public class T2 : I2
{
  public T2()
  {
    Program.T2 t2 = this;
  }

  void I2.M(ref int i) => throw Operators.Failure("todo");
}

This doesn't seem to break anything at runtime, but the changed method signature is unexpected when working with FCS symbols and breaks a piece of analysis in our case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions