Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Incorrect FieldType resolution for closed generic #913

Description

@iskiselev

Incorrect FieldType resolution for closed generic. Test case:

using System;

public static class Program
{
    public static class TmpClss<T>
    {
        public static T CallSite;
    };

    public static void Main(string[] args)
    {
        if (TmpClss<Action>.CallSite == null)
        {
            TmpClss<Action>.CallSite = () => Console.WriteLine("!");
        }
        var action = TmpClss<Action>.CallSite;
        RunMe();

        action();
    }

    public static void RunMe()
    {
        TmpClss<Action>.CallSite = () => Console.WriteLine("!!");
    }
}

Translation:

  function Program_Main (args) {
    if ($T02().CallSite === null) {
      $T02().CallSite = $T03().New(null, null, new JSIL.MethodPointerInfo($thisType, "$lMain$gb__0", $S00(), true, false));
    }
    var action = JSIL.CloneParameter(T, $T02().CallSite);
    $thisType.RunMe();
    action();
  }; 

We have problem with next line: JSIL.CloneParameter(T, $T02().CallSite). Here field type is know at compile time - it is Action, so there should not be JSConditionalStructCopyExpression at all.
Root cause of this problem:
When we create MemberIdentifier for FieldReference, owner type for field is closed generic type. Unfortunately, FieldReference still treat its type as GenericParameter "T", instead of using resolved type from owner type.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions